39 Commits

Author SHA1 Message Date
Matt Wang
80bd7bfc9f
Fix accidental disabling of forward-declared stylesheets (#1373)
PR for the issue flagged in https://github.com/just-the-docs/just-the-docs/discussions/1359#discussioncomment-7267686 (and related to #1358, #1350, etc.). This PR essentially just disables the `head-nav` stylesheet by ID instead of relying on the index; this makes the code more robust against stylesheets that are arbitrarily entered into the document (such as by JavaScript, which is the case of #1359).
2023-10-25 11:52:44 -07:00
Peter Mosses
2ccc451c2a
Fix: improve build time (#1358)
* Remove "passive" toggle

PR #1244 introduced the "passive" toggle, but just-the-docs.js subsequently disabled the only styling that used it, so it became redundant.
This removes it.

* Reduce build time for page-dependent CSS

Fix #1323

- Remove `_includes/head_nav.html`.
- Generate page-independent SCSS in `assets/css/just-the-docs-head-nav.css`.
- Link to `/assets/css/just-the-docs-head-nav.css` in `head.html`.
- Disable the above stylesheet in `assets/js/just-the-docs.js`.
- Generate page-dependent CSS in `_includes/css/activation.scss.liquid` and include in `head.html`.

* No override svg rotate

* Disable both stylesheets safely

* Move the site nav to a new include

- Fix the complete site nav
- Move the site nav to `_includes/site_nav.html`
- Cache the site nav
- Uncache `nav.html`

* Move nav and site_nav to _includes/components

* Replace id prefix

* Update breadcrumbs.html

Replace several filters by a single loop through all the pages,
but breaking as soon as possible.

Profiling indicates that this saves up to 50% of the breadcrumbs build time for the filters.

* Update just-the-docs-head-nav.css

Adjust the number of lines to keep

* Update head.html

Remove superflous type.

* Update activation.scss.liquid

Remove a superfluous closing brace.
Adjust layout.

* Use `scssify` to remove nesting

Preliminary profiling indicates that using `scssify` on the small number of nested CSS rules produced by `activation.scss.liquid` is quick enough.

* Update head.scss

Manual attempt at prettier (pending installation in Atom).

* Avoid generation of nested CSS

Local profiling indicated that using `scssify` on each page takes about 1% of the build time.

- Update `_includes/css/activation.scss.liquid` to generate non-nested CSS.
- Remove use of `scssify` from `_includes/head.html`.

* Ignore false positives from validator

Ignores: `:1.810-1.823: error: CSS: Parse Error.` and `:1.811-1.824: error: CSS: Parse Error.`; had to shift things around since the local config overrides the CI flag.

* Inline `_sass/head.css`

* Update CHANGELOG.md

---------

Co-authored-by: Matthew Wang <matt@matthewwang.me>
2023-10-01 14:47:26 +02:00
Peter Mosses
9d0ce1c22a
Fix the navigation panel (#1244)
* Fix the nav html and cache it

- Remove `active` class from nav html
- Add js to insert `active` class on link to selected page
- Include attempt to generate page-specific css for same styling when js is off

* Refactor nav, breadcrumbs, children_nav

Fix #1118

Improve the modularity of building the nav-panel, breadcrumbs, and children-nav
by making them independent. This also significantly simplifies the Liquid code.

* Manual merge of fix-leakage

Also fix order of breadcrumbs

* Fix order of breadcrumbs

* Revert layout in HTML

Revert to the previous layout in the HTML, to allow the use of `diff` to check the built site.

* Update breadcrumbs.html

Revert inclusion of single breadcrumb for top-level pages.

* Update breadcrumbs.html

Revert to the previous layout in the HTML, to allow the use of `diff` to check the built site.

* Update children_nav.html

Revert to the previous layout in the HTML, to allow the use of `diff` to check the built site.

* Delete nav_init.html

* Update sidebar.html

Caches.

* Add a comment

* Update nav.html

- Comment on independence from page.
- Remove redundant comment.
- Remove superfluous conditionals.

* Update just-the-docs.gemspec

Revert jekyll version spec change.

* Update just-the-docs.gemspec

Revert runtime dependency on kramdown-parser-gfm.

* Revert inclusion of activation.scss.liquid

Inclusion makes HTML of all pages differ from 0.5.1

* Update default.html

Restore deleted "<!DOCTYPE html>"

* Update children_nav.html

Restore line break.

* Delete activation.scss.liquid

This was merely an example of page-specific CSS for use when JS off.

* Remove an unused include parameter

`nav.html` does not depend on `include.key`.

* Generate page-specific styling for nav links and lists in the side-nav

In this PR, the code in `includes/nav.html` is fixed, and none of its elements have class `active`. When JS is enabled, `activateNav()` adds the class `active` to all nav-list-items that enclose the nav-list-link to the current page, so the navigation works as usual. Unobtrusive JS requires the same behaviour when JS is disabled.

- Add `_includes/css/activation.scss.liquid` to compute the indices in the enclosing nav-lists of the nav-list-link to the current page, and generate page-specific styling.
- Insert Liquid code in `_includes/head.html` to include the CSS generated by `_includes/css/activation.scss.liquid` (which depends on `site.color_scheme`).
- Update the toggling in `initNav()` to allow also contraction of enclosing levels when JS is enabled.

Caveat: When JS is enabled, buttons can be used to switch the colour scheme dynamically. The page-specific styling of the site-nav is generated statically, and doesn't change, so the background-image of the nav-list-link to the current page is incorrect. (I guess that could be fixed by generating a style element for each available colour scheme, and using JS to reorder the stylesheets in the DOM.)

A further issue is that the `@import` rules used in `_includes/head.html` cause duplication. Replacing them by `@use` rules would avoid duplication, but that is out of scope for this PR.

* Fix activation for collections

- Adjust generated selectors to pages in collections.
- Expand all folded collections when JS is disabled.

This PR should now make unobtrusive use of JS:

- When JS is disabled, the navigation panel shows links to the top pages in all collections (in contrast to the current version of the theme).
- When JS is enabled, folded collections remain folded until their pages are selected.

* Respect `child_nav_order`

- Assumes reverse order when set to any truthy value.

* Suppress liquid line breaks

* Cache the search for favicon.ico

- Move the code for finding the favicon.ico file to `_includes/favicon.html`.
- Replace that code in `_includes.html` by a cached include of `favicon.html`.

* Add "jekyll-include-cache" in fixtures

Needed when CI ignores the gemspec.

* Add gem "jekyll-include-cache" in fixtures

Needed when CI ignores the gemspec.

* Update head.html

- Avoid duplication of color_scheme CSS in `style` element.
- Avoid generation of whitespace by Liquid code.

* Update sorted_pages.html

- Minor optimisation.
- Minor improvements to layout of Liquid code.

* Ensure split is not at start of rules generated by css/activation.scss.liquid

A custom color scheme might not import any highlighting style rules, so we should not assume that there is anything before the first occurrence of `.site-nav`.

* Update head.html

- Add implicit import of light color scheme.
- Revert to previous Liquid code for removing color scheme rules.

* Manual resolution of merge conflicts with v0.5.2

- Copied replacement of links on nav expanders by buttons.
- Removed (page-dependent) conditions associated with `active`.

* Manual resolution of merge conflict with v0.5.2

If previously "" (neither active nor passive), then `active && passive` is true, and the target is now "active".
If previously only "active", then the target is now just "passive".
If previously only "passive", then the target is now just "active".
The state "active passive" is never used.
The value of `active` is true just when the target is left "active".

* Update fixtures/Gemfile-github-pages

Co-authored-by: Matt Wang <matt@matthewwang.me>

* Update head.html

The result of `activation.scss.liquid` is "" for pages with no `title` or with `nav_exclude`. This update  stops `head.html`  including a `style` element with an invalid body on such pages.

Note that when the result of `scssify` doesn't contain `.site-nav`, `split` produces a one-element array, so `shift` produces an empty array, and `join` then produces an empty string.

* Fix omitted `.site-nav`

Restore the previous prepending of `.site-nav`, which was dropped when suppressing the generation of an incorrect `<style>` element for pages excluded from the navigation.

* Add a footnote about `.site-nav`

* Make setTheme remove background images from nav links

With a fixed nav panel, a <style> in the <head> sets a background image to highlight the nav list link to the current page. The image color depends on site.color_scheme.

Ideally, setTheme(theme) would change the image color to match the theme/scheme. Here, for simplicity, we merely remove the image.

* Explain `nav_fold` in collections.

* Refactor

Attempt at cleaning up the duplicated nav links code and simplifying removal of the background image:

* Add function `navLink()`
* Replace `removeNavBackgroundImages()` by `removeNavBackgroundImage()`
* Replace var `siteNav` by `document.getElementById('site-nav')`
* Replace code in `scrollNav` and `activateNav` by `navLink()`
* Replace a (non-local!) reference to `siteNav` by `document`

* Disable the page-specific stylesheet when JS is enabled

The page-specific `<style>` in the `<head>` is needed only when JS is disabled. Moreover, it incorrectly overrides dynamic stylesheets set by setTheme(theme).

The page-specific stylesheet is assumed to have index 1 in the list of stylesheets. It would be safer to select it by `id`, but adding an `id` can break existing sites.

* Avoid constraint on use of `.site-nav`, and refactor

Avoid the constraint on use of `.site-nav` by determining how many occurrences are produced by `css/activation.scss.liquid` when custom color schemes are ignored.

Move the Liquid code used for generating the page-dependent style element to a new include `head_nav.html`, to simplify `head.html`.

Remove the footnote about `.site-nav` in `docs/customization.md`.

Test the styling with JS disabled, since the resulting style element is disabled by JS.

* Revert "Avoid constraint on use of `.site-nav`, and refactor"

This reverts commit 5284892a7486ef9d2af9929c8a509b89731bb233.

* Avoid constraint on use of `.site-nav`, and refactor

(This corrects a bug in the previous reverted commit for excluded pages such as 404.html.)

Avoid the constraint on use of `.site-nav` by determining how many occurrences are produced by `css/activation.scss.liquid` when custom color schemes are ignored.

Move the Liquid code used for generating the page-dependent style element to a new include `head_nav.html`, to simplify `head.html`.

Remove the footnote about `.site-nav` in `docs/customization.md`.

Test the styling with JS disabled, since the resulting style element is disabled by JS.

* Update comment

* Fix duplicate plugins setting

@mattxwang noticed that the second `plugins` setting was apparently overriding the first, leading to a missing plugin when using `fixtures/Gemfile-github-pages`.

* Avoid double inclusion of activation file

The previous changes to remove the constraint re ".site-nav" duplicated the inclusion of `css/activation.scss.liquid`.
That caused significant extra build time, which the current changes to `head_nav.html` avoid (without affecting the built site).

* Clarify collection configuration docs

* Update and clarify the CHANGELOG

---------

Co-authored-by: Matt Wang <matt@matthewwang.me>
2023-08-18 20:35:14 +02:00
Matt Wang
5e5e2438d2
Fix mermaid v10, bundle all mermaid code in component (#1190)
This PR does two things:

1. fixes using mermaid version `>= 10` from the CDN, by importing the ESM module instead
2. moves script loading code from `head.html` to the mermaid include

I've also added some light documentation to clarify how using mermaid with local paths should work (users should specify a version, and they should only use fully-minified bundles with no local references).

The nice thing about this approach is that it's a breaking change for nobody, and only adds functionality (v10 support). Eventually, we should remove support for mermaid <10, which should make this much easier!

Closes #1206.

## Context

In v10, Mermaid has implemented a few (admittedly, very frustrating to deal with) breaking changes:

1. they've removed CJS support, which is fine, *but*
2. that means that the `dist` they publish to JSDelivr now has a **different URL**: for versions `10.0.0` - `10.0.2`, **they do not have a minified bundle -- you have to load the ESM version with relative imports**
3. and, separately the `init` function has been deprecated

2 is really the issue, and so I've had to go into the code to now load mermaid by ESM by default when the user is on mermaid > v10.

I've tested this with:

- CDN version < 10 (v9)
- CDN version 10
- local path with version < 10 (v9)
- local path with version 10 (new: also loaded as an ESM module)

Separately, I chose to put all the mermaid stuff in one include because:

- I think @pdmosses requested something like this - it's a bit confusing that some mermaid code is *not* in the include, and this makes modular components ... more modular
- from a developer perspective, it's more clear what's happening with mermaid
- mermaid is not render-blocking, so it shouldn't be in the `head` anyways

---------

Co-authored-by: Peter Mosses <18308236+pdmosses@users.noreply.github.com>
2023-04-12 12:05:51 -07:00
Christian Bäuerlein
b2bbdb7040
Add configuration key to load a local version of mermaid (#1153)
Hi there!

Thank you for the great theme! I am a happy user and was delighted to see that mermaid support has landed.

In some cases the usage of jsDelivr might not be possible for technical or compliance reasons.

This commit adds a second way to include the mermaid lib by specifying a path in the mermaid config. This way a local version of the lib can be used.

It should be fully backwards compatible, not requiring any action by users that already include the lib from the CDN.

I already added some documentation, but I am also happy to extend this, if this change is generally well-received.

Cheers,
Christian
2023-02-05 14:51:48 -08:00
Peter Mosses
7cabda2983
Restore simple configuration of favicon.ico (#1095)
Avoid the need to add a link to favicon,ico when editing `_includes/head_custom.html`, and avoid creating an invalid favicon link

- Remove the content of `_includes/head_custom.html`
- Add code to `_includes/head.html` to create a link to an existing favicon,ico
- Add an explanation of favicon_ico to docs/configuration.md
- Remove the example of `includes/head_custom.html` and add an explanation of what the `<head>` element automatically includes
2022-12-27 13:09:47 -08:00
Michelle Blanchette
9bccf07faa
analytics: support multiple tracking IDs, document UA -> GA4 switch (#1029)
* Issue #1023 - note that GA4 properties are supported

* Issue #1023 - parameterize Google Analytics property script

* Issue #1023 - support a list of multiple Google Analytics tracking IDs in config

* Issue #1023 - update Google Analytics configuration doc

* Fix configuration of multiple Google Analytics properties and simplify type checking

* simplify unnecessary code repetition

* tweak Google Analytics config documentation wording
2022-12-17 23:43:55 -08:00
Matt Wang
845cd763f3
Removes favicon.html, shifts content to head_custom.html (#1027)
* Removes `favicon.html`, shifts content to `head_custom.html`
* explicit callout for custom favicon in customization docs
* Cleaner and more consistent documentation (review from @pdmosses)

Co-authored-by: Peter Mosses <18308236+pdmosses@users.noreply.github.com>
2022-12-13 11:21:20 -08:00
Tom Brouwer
c498a5690a
Fix duplicate title if jekyll-seo-tag not in users's plugins (#1040)
In case 'just-the-docs' is used as a theme, and a user does not
eplicitly include 'jekyll-seo-tag' inside the plugins list in
_config.yml, two 'title' elements were rendered. Since
jekyll-seo-tag is always available, because it's set in the plugins
list of the theme itself, the 'seo' tag will aways work, making
the seperate title and description elements obsolete.

Fixes #1008
2022-11-15 00:09:59 -08:00
Matt Wang
855427186b
Fix HTML validation issues (W3C validator) (#964)
Closes #963.

- redundant `role="navigation"` on nav elements
- redundant `type="text/javascript"` on script tags
- misplaced mermaid script tag

Note that [running the validator on the deploy preview](https://validator.w3.org/nu/?doc=https%3A%2F%2Fdeploy-preview-964--just-the-docs.netlify.app%2F) has no errors now!
2022-09-15 12:24:26 -07:00
Matt Wang
e2f1546c61
mermaid: refactor config to use mermaid_config.js include, only require mermaid.version in _config.yml (#909)
This PR has a bit of scope creep! This PR now:

- changes the mermaid opt-in logic to only check for the existence of a `mermaid` key instead of `mermaid != false`: this resolves the follow-up in #857
- changes the behaviour of mermaid configuration
    - instead of using `mermaid_init.html` with default settings, makes the include `mermaid_config.js`
    - the include is loaded directly into the contents of `mermaid_initialize`
    - by default, it is an empty object (i.e. `{}`), triggering the defaults
- updates docs
- adds an example to the markdown kitchen sink  

It does significantly change the interface provided in #857, and I apologize for the confusion. However, given the discussion in this PR, I think it's the best move forward!
2022-08-11 19:34:15 -07:00
nascosto
6907f06977
Add mermaid support (#857)
Closes #825


Co-authored-by: Matt Wang <matt@matthewwang.me>
2022-07-12 15:16:18 -07:00
Ilya Ivanov
9e52e712ae allow custom favicon code 2020-10-13 05:29:25 +07:00
marksie1988
e181626b66 merge upstream 2020-06-26 11:50:56 +01:00
marksie1988
d7050b3f04 change to relative_url 2020-06-26 10:08:11 +01:00
Patrick Marsceill
59d4802ce3
Merge branch 'improvement/custom-themes' of git://github.com/SgtSilvio/just-the-docs into SgtSilvio-improvement/custom-themes 2020-04-24 15:39:44 -04:00
Patrick Marsceill
0716ea77d6
Merge pull request #250 from Labs64/pr-anonymize_ip
Enable IP anonymization in Google Analytics (GDPR)
2020-04-24 14:47:21 -04:00
R.Brown
17cf72bd33
Update _includes/head.html
Co-Authored-By: Patrick Marsceill <pmarsceill@users.noreply.github.com>
2020-04-24 19:44:25 +02:00
Serge
aa8ca74883
Fix duplicated title and description tags
Currently just-the-docs renders two title and description tags
when used with jekyll-seo-tag. This patch fixes plugin detection
conditonal.
2020-03-22 22:51:37 -04:00
Alexey Averikhin
25331a5ffa Enable IP anonymization in Google Analytics (GDPR)
- Introduced "ga_tracking_anonymize_ip" parameter to enable/disable Google Analytics IP anonymization (to comply with GDPR).

(cherry picked from commit ce530f36fa0549c78ffe53ea6077f44f6f0b330f) (+1 squashed commit)
Squashed commits:
[69b7718] - enable GA anonymize_ip

(cherry picked from commit f2b67c632af72b61dd634b9a337200781519691e)
2019-11-12 10:27:01 +01:00
Silvio Giebl
95498ccaf8 Added just-the-docs-default.scss which includes the theme set in _config.yml 2019-08-17 15:02:53 +02:00
Silvio Giebl
f61b836f6e Fixed stylesheet link
(cherry picked from commit ac42a41ae3e36b002df52882be296c01873c0e5b)
2019-08-15 18:35:59 +02:00
Silvio Giebl
cba53a6914 Make themes more customizable
(cherry picked from commit dffb2706a158784e2f3091f895a868e373683bc8)
2019-08-15 18:35:10 +02:00
Patrick Marsceill
d01f0e29db
Make search on by default 2019-08-14 16:43:59 -04:00
Patrick Marsceill
1a2636350f
Merge branch 'v0.2.6-release' into improve-search 2019-08-14 10:43:59 -04:00
Patrick Marsceill
3ad99afb02
Merge branch 'v0.2.6-release' into update-analytics-to-gtag 2019-08-13 11:12:15 -04:00
Adam Green
aa0d8f1d40 Modified the google analytics code to match the new tags used by GA 2019-07-24 09:35:13 -04:00
hallowf
2d1babc452 Replaced old script for analytics with gtag 2019-07-04 15:52:01 +01:00
Silvio Giebl
0142d2874b Enabled customization of html head 2019-05-19 02:55:43 +02:00
Silvio Giebl
b3f52fedad Added html compression 2019-05-19 02:55:43 +02:00
Patrick Marsceill
460e9ae236
No title if SEO is enbaled 2019-05-13 16:40:28 -04:00
gebeto
25b6455ed7 add seo 2019-02-28 08:10:48 +02:00
Patrick Marsceill
aee6d1fb8c
Use analytics.js instead of tag manager 2019-02-02 13:59:41 -08:00
Patrick Marsceill
e12408d07b
Add hook for GA tracking 2019-02-02 12:32:04 -08:00
Patrick Marsceill
f264034999
If page has a description use that for meta data 2019-01-06 15:48:58 -05:00
Patrick Marsceill
d11e332dc6
Create condition for no search and add config/css 2018-11-16 11:46:43 -05:00
Patrick Marsceill
2aaff540a1
Fix assets 2018-10-22 17:17:46 -04:00
Patrick Marsceill
594385ae7b
initial commit 2017-03-24 09:47:37 -04:00
Patrick Marsceill
b7b0d0d7bf
Initial commit 2017-03-09 13:16:08 -05:00