just-the-docs 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c362693d611afbf87baeba763bc457fedd9dc2c0e61704c1c843969048f43a6
4
- data.tar.gz: f3fa7e6c8ca7c926751d7221670c45457ad12e595dcccae5c2d8f025707b7630
3
+ metadata.gz: 6b96a130e7da963319bffcbfc09ce39881f538bfe8b56f2809251d29ab7aeb40
4
+ data.tar.gz: 7a1ec7d332331653d64e2adc7e8f157adf4fbb8f0041261f0b165032861b47ca
5
5
  SHA512:
6
- metadata.gz: 9f751827832c8b1b958bd2c4d7f3b9812c3194a6a7e7bf023131e86cd4f408bad4037d09f99281e4212390265aa8a2dad709bd6f7005941433073e0d28bf545e
7
- data.tar.gz: fd30ebd6d9b5b4af76e31b62b1ce1b9621fa2b26dc2b87972072a52d40c30f652003043a63e2b9cc8f13a882a3a8b3c9ac291c321e736dd4b499632f5193fe1b
6
+ metadata.gz: f033dfe192101707e7b6bebea2b6b0628a5d8a401a32bc6adda5bc483b126af8f98efa7eaf51dc62e399d0dfea09d39d96a91cf5c31b4a1c53d07fcb96a1a288
7
+ data.tar.gz: 5e9203f6620f854339e979b74811f677357baf57746aba62d242ffe1cc1f58de0eff2e8a8596e2377f317d65af6ad8e9b379a6a532e637b7bb32404f068a216e
data/CHANGELOG.md CHANGED
@@ -19,6 +19,75 @@ Code changes to `main` that are *not* in the latest release:
19
19
 
20
20
  - N/A
21
21
 
22
+ ## Release v0.7.0
23
+
24
+ Hi folks! This is a minor release that adds a new configuration option for opening external links in a new tab and provides many bugfixes (in both correctness and performance) for Just the Docs users with large sites. We anticipate that for most users, this is a straightforward upgrade. However, it introduces some potentially-breaking *internal* changes to undocumented features of the theme.
25
+
26
+ ### Migrating to `v0.7.0`
27
+
28
+ **Migration**: users will need to migrate if:
29
+
30
+ - they overrode `_includes/nav.html`, which has moved to `_includes/components/nav.html`
31
+ - they have an element with the IDs `jtd-nav-activation` or `jtd-head-nav-stylesheet`
32
+
33
+ For more, refer to the [migration guide](https://just-the-docs.com/MIGRATION/).
34
+
35
+ ### Using Release `v0.7.0`
36
+
37
+ Users who have not pinned the theme version will be **automatically upgraded to `v0.7.0` the next time they build their site**.
38
+
39
+ To use this release explicitly as a remote theme:
40
+
41
+ ```yml
42
+ remote_theme: just-the-docs/just-the-docs@v0.7.0
43
+ ```
44
+
45
+ To use this version explicitly as a gem-based theme, pin the version in your `Gemfile` and re-run `bundle install` or `bundle update just-the-docs`:
46
+
47
+ ```ruby
48
+ gem "just-the-docs", "0.7.0"
49
+ ```
50
+
51
+ To use and pin a previous version of the theme, replace the `0.7.0` with the desired release tag.
52
+
53
+ ### New Features
54
+
55
+ - Added: configuration options for opening external links in new tab by [@CarbonNeuron] in [#1360]
56
+
57
+ ### Bugfixes
58
+
59
+ - Fixed: remove href from the navigation link to the current page by [@pdmosses] in [#1356]
60
+ - Fixed: improve build time by [@pdmosses] in [#1358]
61
+ - Fixed: erroneous parentheses in `site_nav` conditional by [@mattxwang] in [#1366]
62
+ - Fixed: navigation scroll to active link regression by [@pdmosses] in [#1367]
63
+ - Fixed: invalid CSS rules in head elements by [@pdmosses] in [#1368]
64
+ - Fixed: accidental disabling of forward-declared stylesheets by [@mattxwang] in [#1373]
65
+
66
+ {: .warning }
67
+ [#1358] moved `_includes/nav.html` to the `_includes/components` directory,
68
+ Users who were overriding that file will need to adjust their sites accordingly.
69
+
70
+ ### Documentation:
71
+
72
+ - Docs: fix typos in `CHANGELOG` and `MIGRATION` by [@thapasusheel] in [#1377]
73
+
74
+ ### New Contributors
75
+
76
+ - [@CarbonNeuron] made their first contribution in [#1360]
77
+ - [@thapasusheel] made their first contribution in [#1377]
78
+
79
+ [@CarbonNeuron]: https://github.com/CarbonNeuron
80
+ [@thapasusheel]: https://github.com/thapasusheel
81
+
82
+ [#1356]: https://github.com/just-the-docs/just-the-docs/pull/1356
83
+ [#1358]: https://github.com/just-the-docs/just-the-docs/pull/1358
84
+ [#1360]: https://github.com/just-the-docs/just-the-docs/pull/1360
85
+ [#1366]: https://github.com/just-the-docs/just-the-docs/pull/1366
86
+ [#1367]: https://github.com/just-the-docs/just-the-docs/pull/1367
87
+ [#1368]: https://github.com/just-the-docs/just-the-docs/pull/1368
88
+ [#1373]: https://github.com/just-the-docs/just-the-docs/pull/1373
89
+ [#1377]: https://github.com/just-the-docs/just-the-docs/pull/1377
90
+
22
91
  ## Release v0.6.2
23
92
 
24
93
  Hi all, this is a small patch release that includes two changes: adding a missing Windows emoji font fallback, and removing some (now-unused) code introduced in 0.6.
@@ -644,7 +713,7 @@ This RC does not introduce any major user-facing features. It adds more customiz
644
713
 
645
714
  ### Trying out pre-release `v0.4.0.rc5`
646
715
 
647
- Simlar to the prior release, `v0.4.0.rc5` is a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` following immediately after. While we don't anticipate many users using this RC, it is still possible to opt-in.
716
+ Similar to the prior release, `v0.4.0.rc5` is a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` following immediately after. While we don't anticipate many users using this RC, it is still possible to opt-in.
648
717
 
649
718
  To use this RC explicitly as a remote theme:
650
719
 
@@ -745,7 +814,7 @@ Have any questions, thoughts, or concerns? We'd love to hear from you! Please [o
745
814
 
746
815
  ### Trying out pre-release `v0.4.0.rc4`
747
816
 
748
- Simlar to the prior release, `v0.4.0.rc4` is a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` coming soon. We want your help in testing the changes! As of now, the gem on RubyGems and the repository are updated to `v0.4.0.rc4`.
817
+ Similar to the prior release, `v0.4.0.rc4` is a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` coming soon. We want your help in testing the changes! As of now, the gem on RubyGems and the repository are updated to `v0.4.0.rc4`.
749
818
 
750
819
  To use this RC explicitly as a remote theme:
751
820
 
@@ -866,7 +935,7 @@ As soon as we get stable test results from major downstream users, we'll push ou
866
935
 
867
936
  ### Trying out pre-release `v0.4.0.rc3`
868
937
 
869
- Simlar to the prior release, `v0.4.0.rc3` is a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` coming soon. We want your help in testing the changes! As of now, the gem on RubyGems and the repository are updated to `v0.4.0.rc3`.
938
+ Similar to the prior release, `v0.4.0.rc3` is a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` coming soon. We want your help in testing the changes! As of now, the gem on RubyGems and the repository are updated to `v0.4.0.rc3`.
870
939
 
871
940
  To use this RC explicitly as a remote theme:
872
941
 
@@ -942,7 +1011,7 @@ The intention of this release candidate is to gather even more feedback on a pot
942
1011
 
943
1012
  ### Trying out pre-release `v0.4.0.rc2`
944
1013
 
945
- Simlar to the prior release, `v0.4.0.rc2` is a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` coming soon. We want your help in testing the changes! As of now, the gem on RubyGems and the repository are updated to `v0.4.0.rc2`.
1014
+ Similar to the prior release, `v0.4.0.rc2` is a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` coming soon. We want your help in testing the changes! As of now, the gem on RubyGems and the repository are updated to `v0.4.0.rc2`.
946
1015
 
947
1016
  To use this RC explicitly as a remote theme:
948
1017
 
@@ -1030,7 +1099,7 @@ We want your feedback! Are these changes helpful? Are our docs easy to understan
1030
1099
 
1031
1100
  ### Trying out pre-release `v0.4.0.rc1`
1032
1101
 
1033
- Due to the massive scope of these changes, we're making `v0.4.0.rc1` avaialble as a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` coming soon. We want your help in testing the changes! As of now, the gem on RubyGems and the repository are updated to `v0.4.0.rc1`.
1102
+ Due to the massive scope of these changes, we're making `v0.4.0.rc1` available as a **release candidate** for the theme (i.e., a pre-release) with release `v0.4.0` coming soon. We want your help in testing the changes! As of now, the gem on RubyGems and the repository are updated to `v0.4.0.rc1`.
1034
1103
 
1035
1104
  To use this RC explicitly as a remote theme:
1036
1105
 
@@ -1542,7 +1611,7 @@ fixes #291 #256 #293 #177
1542
1611
 
1543
1612
  ## v0.2.1
1544
1613
 
1545
- This update fixes security vulnerablities in the lodash sub-dependency and bumps other dev dependencies to their latest version.
1614
+ This update fixes security vulnerabilities in the lodash sub-dependency and bumps other dev dependencies to their latest version.
1546
1615
 
1547
1616
  ## v0.2.0
1548
1617
 
@@ -3,30 +3,38 @@
3
3
  Depends on: page, site.
4
4
  Results in: HTML for the breadcrumbs component.
5
5
  Overwrites:
6
- pages_list, parent_page, grandparent_page.
6
+ node, pages_list, parent_page, grandparent_page.
7
7
  {%- endcomment -%}
8
8
 
9
9
  {%- if page.url != "/" and page.parent -%}
10
10
 
11
- {%- assign pages_list = site[page.collection]
12
- | default: site.html_pages
13
- | where_exp: "item", "item.title != nil"
14
- | where_exp: "item", "item.has_children != nil" -%}
15
-
16
- {%- if page.grand_parent -%}
17
- {%- assign parent_page = pages_list
18
- | where: "title", page.parent
19
- | where: "parent", page.grand_parent
20
- | first -%}
21
- {%- assign grandparent_page = pages_list
22
- | where: "title", page.grand_parent
23
- | first -%}
24
- {%- else -%}
25
- {%- assign parent_page = pages_list
26
- | where: "title", page.parent
27
- | where_exp: "item", "item.parent == nil"
28
- | first -%}
29
- {%- endif -%}
11
+ {%- assign pages_list = site[page.collection] | default: site.html_pages -%}
12
+
13
+ {%- assign parent_page = nil -%}
14
+ {%- assign grandparent_page = nil -%}
15
+
16
+ {%- for node in pages_list -%}
17
+
18
+ {%- if node.has_children and page.grand_parent -%}
19
+
20
+ {%- if node.title == page.parent and node.parent == page.grand_parent -%}
21
+ {%- assign parent_page = node -%}
22
+ {%- endif -%}
23
+ {%- if node.title == page.grand_parent -%}
24
+ {%- assign grandparent_page = node -%}
25
+ {%- endif -%}
26
+ {%- if parent_page and grandparent_page -%}
27
+ {%- break -%}
28
+ {%- endif -%}
29
+
30
+ {%- elsif node.has_children and node.title == page.parent and node.parent == nil -%}
31
+
32
+ {%- assign parent_page = node -%}
33
+ {%- break -%}
34
+
35
+ {%- endif -%}
36
+
37
+ {%- endfor -%}
30
38
 
31
39
  <nav aria-label="Breadcrumb" class="breadcrumb-nav">
32
40
  <ol class="breadcrumb-nav-list">
@@ -1,5 +1,5 @@
1
1
  {%- comment -%}
2
- Include as: {%- include_cached nav.html pages=pages -%}
2
+ Include as: {%- include components/nav.html pages=pages -%}
3
3
  Depends on: include.pages.
4
4
  Results in: HTML for the navigation panel.
5
5
  Includes:
@@ -3,10 +3,9 @@
3
3
  Depends on: page(?), site.
4
4
  Results in: HTML for the side bar.
5
5
  Includes:
6
- title.html, nav.html, nav_footer_custom.html
7
- Overwrites:
8
- pages_top_size, collections_size, collection_entry,
9
- collection_key, collection_value, collection, nav_footer_custom.
6
+ title.html, components/site_nav.html, nav_footer_custom.html
7
+ Overwrites:
8
+ nav_footer_custom.
10
9
  Should not be cached, because nav_footer_custom.html might depend on page.
11
10
  {%- endcomment -%}
12
11
 
@@ -17,58 +16,8 @@
17
16
  <svg viewBox="0 0 24 24" class="icon" aria-hidden="true"><use xlink:href="#svg-menu"></use></svg>
18
17
  </button>
19
18
  </div>
20
- <nav aria-label="Main" id="site-nav" class="site-nav">
21
- {% assign pages_top_size = site.html_pages
22
- | where_exp:"item", "item.title != nil"
23
- | where_exp:"item", "item.parent == nil"
24
- | where_exp:"item", "item.nav_exclude != true"
25
- | size %}
26
- {% if pages_top_size > 0 %}
27
- {% include_cached nav.html pages=site.html_pages %}
28
- {% endif %}
29
- {%- if site.nav_external_links -%}
30
- <ul class="nav-list">
31
- {%- for node in site.nav_external_links -%}
32
- <li class="nav-list-item external">
33
- <a href="{{ node.url | absolute_url }}" class="nav-list-link external">
34
- {{ node.title }}
35
- {% unless node.hide_icon %}<svg viewBox="0 0 24 24" aria-labelledby="svg-external-link-title"><use xlink:href="#svg-external-link"></use></svg>{% endunless %}
36
- </a>
37
- </li>
38
- {%- endfor -%}
39
- </ul>
40
- {%- endif -%}
41
- {% if site.just_the_docs.collections %}
42
- {% assign collections_size = site.just_the_docs.collections | size %}
43
- {% for collection_entry in site.just_the_docs.collections %}
44
- {% assign collection_key = collection_entry[0] %}
45
- {% assign collection_value = collection_entry[1] %}
46
- {% assign collection = site[collection_key] %}
47
- {% if collection_value.nav_exclude != true %}
48
- {% if collections_size > 1 or pages_top_size > 0 %}
49
- {% if collection_value.nav_fold == true %}
50
- <ul class="nav-list nav-category-list">
51
- <li class="nav-list-item{% if page.collection == collection_key %} active{% endif %}">
52
- {%- if collection.size > 0 -%}
53
- <button class="nav-list-expander btn-reset" aria-label="Toggle collection {{ collection_value.name }}" aria-pressed="{% if page.collection == collection_key %}true{% else %}false{% endif %}">
54
- <svg viewBox="0 0 24 24" aria-hidden="true"><use xlink:href="#svg-arrow-right"></use></svg>
55
- </button>
56
- {%- endif -%}
57
- <div class="nav-category">{{ collection_value.name }}</div>
58
- {% include_cached nav.html pages=collection %}
59
- </li>
60
- </ul>
61
- {% else %}
62
- <div class="nav-category">{{ collection_value.name }}</div>
63
- {% include_cached nav.html pages=collection %}
64
- {% endif %}
65
- {% else %}
66
- {% include_cached nav.html pages=collection %}
67
- {% endif %}
68
- {% endif %}
69
- {% endfor %}
70
- {% endif %}
71
- </nav>
19
+
20
+ {% include_cached components/site_nav.html %}
72
21
 
73
22
  {% capture nav_footer_custom %}
74
23
  {%- include nav_footer_custom.html -%}
@@ -0,0 +1,67 @@
1
+ {%- comment -%}
2
+ Include as: {%- include_cached components/site_nav.html -%}
3
+ Depends on: site.
4
+ Results in: HTML for the site-nav.
5
+ Includes:
6
+ components/nav.html
7
+ Overwrites:
8
+ pages_top_size, collections_size, collection_entry,
9
+ collection_key, collection_value, collection.
10
+ {%- endcomment -%}
11
+
12
+ <nav aria-label="Main" id="site-nav" class="site-nav">
13
+ {% assign pages_top_size = site.html_pages
14
+ | where_exp:"item", "item.title != nil"
15
+ | where_exp:"item", "item.parent == nil"
16
+ | where_exp:"item", "item.nav_exclude != true"
17
+ | size %}
18
+ {% if pages_top_size > 0 %}
19
+ {% include components/nav.html pages=site.html_pages %}
20
+ {% endif %}
21
+ {%- if site.nav_external_links -%}
22
+ <ul class="nav-list">
23
+ {%- for node in site.nav_external_links -%}
24
+ <li class="nav-list-item external">
25
+ <a href="{{ node.url | absolute_url }}" class="nav-list-link external"
26
+ {% if node.opens_in_new_tab or node.opens_in_new_tab == nil and site.nav_external_links_new_tab %}
27
+ target="_blank" rel="noopener noreferrer"
28
+ {% endif %}
29
+ >
30
+ {{ node.title }}
31
+ {% unless node.hide_icon %}<svg viewBox="0 0 24 24" aria-labelledby="svg-external-link-title"><use xlink:href="#svg-external-link"></use></svg>{% endunless %}
32
+ </a>
33
+ </li>
34
+ {%- endfor -%}
35
+ </ul>
36
+ {%- endif -%}
37
+ {% if site.just_the_docs.collections %}
38
+ {% assign collections_size = site.just_the_docs.collections | size %}
39
+ {% for collection_entry in site.just_the_docs.collections %}
40
+ {% assign collection_key = collection_entry[0] %}
41
+ {% assign collection_value = collection_entry[1] %}
42
+ {% assign collection = site[collection_key] %}
43
+ {% if collection_value.nav_exclude != true %}
44
+ {% if collections_size > 1 or pages_top_size > 0 %}
45
+ {% if collection_value.nav_fold == true %}
46
+ <ul class="nav-list nav-category-list">
47
+ <li class="nav-list-item">
48
+ {%- if collection.size > 0 -%}
49
+ <button class="nav-list-expander btn-reset" aria-label="Toggle collection {{ collection_value.name }}" aria-pressed="false">
50
+ <svg viewBox="0 0 24 24" aria-hidden="true"><use xlink:href="#svg-arrow-right"></use></svg>
51
+ </button>
52
+ {%- endif -%}
53
+ <div class="nav-category">{{ collection_value.name }}</div>
54
+ {% include components/nav.html pages=collection %}
55
+ </li>
56
+ </ul>
57
+ {% else %}
58
+ <div class="nav-category">{{ collection_value.name }}</div>
59
+ {% include components/nav.html pages=collection %}
60
+ {% endif %}
61
+ {% else %}
62
+ {% include components/nav.html pages=collection %}
63
+ {% endif %}
64
+ {% endif %}
65
+ {% endfor %}
66
+ {% endif %}
67
+ </nav>
@@ -1,20 +1,47 @@
1
1
  {%- comment -%}
2
2
  Include as: {%- include css/activation.scss.liquid -%}
3
3
  Depends on: page, site.
4
- Results in: page-dependent SCSS rules for inclusion in a head style element.
4
+ Results in: page-dependent (non-nested) CSS rules for inclusion in a head style element,
5
+ which needs to be suppressed when JS is enabled.
5
6
  Includes:
6
7
  sorted_pages.html.
7
8
  Overwrites:
8
- activation_pages, activation_pages_top_size, activation_page, activation_title,
9
+ activation_no_nav_link, activation_pages, activation_pages_top_size, activation_page, activation_title,
9
10
  activation_first_level, activation_second_level, activation_third_level,
10
11
  activation_first_level_reversed, activation_second_level_reversed,
11
- activation_first_level_index, activation_second_level_index, activation_third_level_index.
12
+ activation_first_level_index, activation_second_level_index, activation_third_level_index,
13
+ activation_index, activation_collection_prefix, activation_other_collection_prefix.
12
14
  Should not be cached, because it depends on page.
13
15
  (For a site with only top-level pages, the rendering of this file is always empty.
14
- This property could be detected, and might halve the build time for such sites.)
16
+ This property could be detected, and used to reduce the build time for such sites.)
15
17
  {%- endcomment -%}
16
18
 
17
- {%- unless page.title == nil or page.nav_exclude == true -%}
19
+ {%- comment -%}
20
+ The CSS rules in activation_no_nav_link are for use on pages excluded from the main navigation.
21
+ - The first rule ensures that no nav-link has a background image.
22
+ - The other two rules ensure that all folding collections are expanded.
23
+ {%- endcomment -%}
24
+
25
+ {%- capture activation_no_nav_link %}
26
+ .site-nav ul li a {
27
+ background-image: none;
28
+ }
29
+
30
+ {%- if site.just_the_docs.collections %}
31
+ .site-nav > ul.nav-category-list > li > button svg {
32
+ transform: rotate(-90deg);
33
+ }
34
+ .site-nav > ul.nav-category-list > li.nav-list-item > ul.nav-list {
35
+ display: block;
36
+ }
37
+ {%- endif %}
38
+ {% endcapture -%}
39
+
40
+ {%- if page.title == nil or page.nav_exclude == true -%}
41
+
42
+ {{ activation_no_nav_link }}
43
+
44
+ {%- else -%}
18
45
 
19
46
  {%- assign activation_pages = site[page.collection]
20
47
  | default: site.html_pages
@@ -27,6 +54,11 @@
27
54
  {%- assign activation_first_level_reversed = nil -%}
28
55
  {%- assign activation_second_level_reversed = nil -%}
29
56
 
57
+ {%- comment -%}
58
+ The generated CSS depends on the position of the current page in each level in
59
+ the navigation.
60
+ {%- endcomment -%}
61
+
30
62
  {%- assign activation_title = page.grand_parent | default: page.parent | default: page.title -%}
31
63
  {%- assign activation_first_level = activation_pages
32
64
  | where_exp: "item", "item.parent == nil" -%}
@@ -39,7 +71,11 @@
39
71
  {%- endif -%}
40
72
  {%- endfor -%}
41
73
 
42
- {%- unless activation_first_level_index == nil -%}
74
+ {%- if activation_first_level_index == nil -%}
75
+
76
+ {{ activation_no_nav_link }}
77
+
78
+ {%- else -%}
43
79
 
44
80
  {%- if page.grand_parent -%}
45
81
  {%- assign activation_title = page.parent -%}
@@ -83,90 +119,163 @@
83
119
  {%- endfor -%}
84
120
  {%- endif -%}
85
121
 
86
- {%- unless activation_second_level_index == nil and activation_third_level_index -%}
122
+ {%- if activation_second_level_index == nil and activation_third_level_index -%}
123
+
124
+ {{ activation_no_nav_link }}
125
+
126
+ {%- else -%}
127
+
128
+ {%- comment -%}
129
+ The site-nav is:
130
+ - an optional ul.nav-list with li.nav-list-items for non-collection top-level pages
131
+ - an optional ul.nav-list with li.nav-list-item.externals
132
+ - any number of just-the-docs.collections
133
+
134
+ A non-foldable collection is:
135
+ - a div.nav-category with the collection name, followed by:
136
+ - a ul.nav-list with li.nav-list-items for its top-level pages
137
+
138
+ A foldable collection is:
139
+ - a ul.nav-list.nav-category-list with a single li.nav-list-item containing:
140
+ - an optional button with the expander svg
141
+ - a div.nav-category with the collection name
142
+ - a ul.nav-list with li.nav-list-items for its top-level pages
143
+
144
+ The generated CSS uses:
145
+ - activation_collection_prefix, to select the site-nav > ul.nav-list for the page
146
+ - activation_other_collection_prefix, to select all the other site-nav > ul.nav-lists
147
+ {%- endcomment -%}
87
148
 
88
149
  {%- if page.collection == nil -%}
89
150
 
90
151
  {%- capture activation_collection_prefix -%}
91
- .site-nav > .nav-list:nth-child(1):not(.nav-category-list)
152
+ .site-nav > ul.nav-list:first-child
153
+ {%- endcapture -%}
154
+
155
+ {%- capture activation_other_collection_prefix -%}
156
+ .site-nav > ul.nav-list:not(:first-child)
92
157
  {%- endcapture -%}
93
158
 
94
159
  {%- else -%}
95
160
 
96
161
  {%- for activation_collection in site.just_the_docs.collections -%}
97
162
  {%- if activation_collection[0] == page.collection -%}
98
- {%- assign activation_collection_index = forloop.index -%}
163
+ {%- assign activation_index = forloop.index -%}
99
164
  {%- break -%}
100
165
  {%- endif -%}
101
166
  {%- endfor -%}
102
- {%- assign activation_index = activation_collection_index -%}
167
+
103
168
  {%- assign activation_pages_top_size = site.html_pages
104
169
  | where_exp:"item", "item.title != nil"
105
170
  | where_exp:"item", "item.parent == nil"
106
171
  | where_exp:"item", "item.nav_exclude != true"
107
172
  | size -%}
108
- {%- if activation_pages_top_size > 0 -%}
173
+ {%- if activation_pages_top_size > 0 -%}
109
174
  {%- assign activation_index = activation_index | plus: 1 -%}
110
175
  {%- endif -%}
176
+
111
177
  {%- if site.nav_external_links -%}
112
178
  {%- assign activation_index = activation_index | plus: 1 -%}
113
179
  {%- endif -%}
180
+
114
181
  {%- capture activation_collection_prefix -%}
115
- .site-nav > .nav-list:nth-of-type({{ activation_index }}){% if site.just_the_docs.collections[page.collection].nav_fold == true %} > .nav-list-item > .nav-list{% endif %}
182
+ .site-nav > ul:nth-of-type({{ activation_index }})
183
+ {%- if site.just_the_docs.collections[page.collection].nav_fold %} > li > ul
184
+ {%- endif -%}
116
185
  {%- endcapture -%}
117
-
186
+
187
+ {%- capture activation_other_collection_prefix -%}
188
+ .site-nav > ul:not(:nth-of-type({{ activation_index }}))
189
+ {%- endcapture -%}
190
+
118
191
  {%- endif -%}
119
192
 
120
- // Styling for the nav-list-link to the current page:
121
- {{ activation_collection_prefix }} {
122
- > .nav-list-item:not(.external):nth-child({{ activation_first_level_index }}){%- if activation_second_level_index %} > .nav-list > .nav-list-item:nth-child({{ activation_second_level_index }}){%- if activation_third_level_index %} > .nav-list > .nav-list-item:nth-child({{ activation_third_level_index }}){% endif %}{% endif %} {
123
- > .nav-list-link {
124
- display: block;
125
- font-weight: 600;
126
- text-decoration: none;
127
- background-image: linear-gradient(
128
- -90deg,
129
- rgba($feedback-color, 1) 0%,
130
- rgba($feedback-color, 0.8) 80%,
131
- rgba($feedback-color, 0) 100%
132
- );
133
- }
134
- }
193
+ {%- comment -%}
194
+ The required background image of the link to the current page may involve SCSS.
195
+ To avoid page-dependent SCSS, all nav links initially have that background image.
196
+ The following rule removes the image from the links to all parents, siblings,
197
+ and children of the current page.
198
+ {%- endcomment %}
199
+
200
+ {% if activation_third_level_index -%}
201
+
202
+ {{ activation_collection_prefix }} > li > a,
203
+ {{ activation_collection_prefix }} > li > ul > li > a,
204
+ {{ activation_collection_prefix }} > li > ul > li > ul > li:not(:nth-child({{ activation_third_level_index }})) > a {
205
+ background-image: none;
135
206
  }
136
207
 
137
- // Styling for nav-list-expanders at first and second levels:
138
- {{ activation_collection_prefix }} {
139
- > .nav-list-item:nth-child({{ activation_first_level_index }}){%- if activation_second_level_index %},
140
- > .nav-list-item:nth-child({{ activation_first_level_index }}) > .nav-list > .nav-list-item:nth-child({{ activation_second_level_index }}){% endif %} {
141
- > .nav-list-expander svg {
142
- @if $nav-list-expander-right {
143
- transform: rotate(-90deg);
144
- } @else {
145
- transform: rotate(90deg);
146
- }
147
- }
148
-
149
- > .nav-list {
150
- display: block;
151
- }
152
- }
208
+ {%- elsif activation_second_level_index -%}
209
+
210
+ {{ activation_collection_prefix }} > li > a,
211
+ {{ activation_collection_prefix }} > li > ul > li:not(:nth-child({{ activation_second_level_index }})) > a,
212
+ {{ activation_collection_prefix }} > li > ul > li > ul > li > a {
213
+ background-image: none;
214
+ }
215
+
216
+ {%- else -%}
217
+
218
+ {{ activation_collection_prefix }} > li:not(:nth-child({{ activation_first_level_index }})) > a,
219
+ {{ activation_collection_prefix }} > li > ul > li > a,
220
+ {{ activation_collection_prefix }} > li > ul > li > ul > li > a {
221
+ background-image: none;
153
222
  }
154
223
 
155
- // Styling for nav-list-expander for categories:
156
- .site-nav > .nav-category-list > .nav-list-item {
157
- > .nav-list-expander svg {
158
- @if $nav-list-expander-right {
159
- transform: rotate(-90deg);
160
- } @else {
161
- transform: rotate(90deg);
162
- }
163
- }
164
-
165
- > .nav-list {
166
- display: block;
167
- }
224
+ {%- endif %}
225
+
226
+ {%- comment -%}
227
+ The following rule removes the image from the links to pages in other collections.
228
+ {%- endcomment %}
229
+
230
+ {{ activation_other_collection_prefix }} a,
231
+ .site-nav li.external a {
232
+ background-image: none;
168
233
  }
169
234
 
170
- {%- endunless -%}
171
- {%- endunless -%}
172
- {%- endunless -%}
235
+ {%- comment -%}
236
+ The following rule styles the link to the current page.
237
+ {%- endcomment %}
238
+
239
+ {{ activation_collection_prefix }} > li:nth-child({{ activation_first_level_index }})
240
+ {%- if activation_second_level_index %} > ul > li:nth-child({{ activation_second_level_index }})
241
+ {%- if activation_third_level_index %} > ul > li:nth-child({{ activation_third_level_index }})
242
+ {%- endif -%}
243
+ {%- endif %} > a {
244
+ font-weight: 600;
245
+ text-decoration: none;
246
+ }
247
+
248
+ {%- comment -%}
249
+ The following rules unfold all collections, and display the links to any children
250
+ of the current page.
251
+
252
+ To avoid dependence on the SCSS variable nav-list-expander-right, the direction
253
+ of the rotation of the expander icon is fixed, and corresponds to the appearance
254
+ when nav-list-expander-right is true. This results in a minor visual difference
255
+ between the appearance of active expander icons when JS is enabled/disabled and
256
+ nav-list-expander-right is false, which seems unavoidable.
257
+ {%- endcomment %}
258
+
259
+ {%- if site.just_the_docs.collections %}
260
+ .site-nav > ul.nav-category-list > li > button svg,
261
+ {% endif -%}
262
+ {{ activation_collection_prefix }} > li:nth-child({{ activation_first_level_index }}) > button svg
263
+ {%- if activation_second_level_index -%},
264
+ {{ activation_collection_prefix }} > li:nth-child({{ activation_first_level_index }}) > ul > li:nth-child({{ activation_second_level_index }}) > button svg
265
+ {%- endif %} {
266
+ transform: rotate(-90deg);
267
+ }
268
+
269
+ {%- if site.just_the_docs.collections %}
270
+ .site-nav > ul.nav-category-list > li.nav-list-item > ul.nav-list,
271
+ {% endif -%}
272
+ {{ activation_collection_prefix }} > li.nav-list-item:nth-child({{ activation_first_level_index }}) > ul.nav-list
273
+ {%- if activation_second_level_index %},
274
+ {{ activation_collection_prefix }} > li.nav-list-item:nth-child({{ activation_first_level_index }}) > ul.nav-list > li.nav-list-item:nth-child({{ activation_second_level_index }}) > ul.nav-list
275
+ {%- endif %} {
276
+ display: block;
277
+ }
278
+
279
+ {%- endif -%}
280
+ {%- endif -%}
281
+ {%- endif -%}
data/_includes/head.html CHANGED
@@ -4,8 +4,8 @@
4
4
  site.search_enabled, site.static_files, site.favicon_ico.
5
5
  Results in: HTML for the head element.
6
6
  Includes:
7
- head_nav.html, head_custom.html.
8
- Overwrites:
7
+ css/activation.scss.liquid, head_custom.html.
8
+ Overwrites:
9
9
  ga_tracking_ids, ga_property, file, favicon.
10
10
  Should not be cached, because included files depend on page.
11
11
  {%- endcomment -%}
@@ -15,8 +15,12 @@
15
15
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
16
16
 
17
17
  <link rel="stylesheet" href="{{ '/assets/css/just-the-docs-default.css' | relative_url }}">
18
-
19
- {% include head_nav.html %}
18
+
19
+ <link rel="stylesheet" href="{{ '/assets/css/just-the-docs-head-nav.css' | relative_url }}" id="jtd-head-nav-stylesheet">
20
+
21
+ <style id="jtd-nav-activation">
22
+ {% include css/activation.scss.liquid %}
23
+ </style>
20
24
 
21
25
  {% if site.ga_tracking != nil %}
22
26
  {% assign ga_tracking_ids = site.ga_tracking | split: "," %}
@@ -0,0 +1,24 @@
1
+ ---
2
+ ---
3
+ {%- if site.color_scheme and site.color_scheme != "nil" -%}
4
+ {%- assign color_scheme = site.color_scheme -%}
5
+ {%- else -%}
6
+ {%- assign color_scheme = "light" -%}
7
+ {%- endif -%}
8
+
9
+ {%- capture newline %}
10
+ {% endcapture -%}
11
+
12
+ {%- capture scss -%}
13
+ {% include css/just-the-docs.scss.liquid color_scheme=color_scheme %}
14
+ .site-nav ul li a {
15
+ background-image: linear-gradient(
16
+ -90deg,
17
+ rgba($feedback-color, 1) 0%,
18
+ rgba($feedback-color, 0.8) 80%,
19
+ rgba($feedback-color, 0) 100%
20
+ );
21
+ }
22
+ {%- endcapture -%}
23
+
24
+ {{ scss | scssify | split: newline | slice: -3, 3 | join: newline }}
@@ -38,8 +38,8 @@ function initNav() {
38
38
  const siteNav = document.getElementById('site-nav');
39
39
  const mainHeader = document.getElementById('main-header');
40
40
  const menuButton = document.getElementById('menu-button');
41
-
42
- disableHeadStyleSheet();
41
+
42
+ disableHeadStyleSheets();
43
43
 
44
44
  jtd.addEvent(menuButton, 'click', function(e){
45
45
  e.preventDefault();
@@ -68,13 +68,23 @@ function initNav() {
68
68
  {%- endif %}
69
69
  }
70
70
 
71
- // The page-specific <style> in the <head> is needed only when JS is disabled.
72
- // Moreover, it incorrectly overrides dynamic stylesheets set by setTheme(theme).
73
- // The page-specific stylesheet is assumed to have index 1 in the list of stylesheets.
71
+ // The <head> element is assumed to include the following stylesheets:
72
+ // - a <link> to /assets/css/just-the-docs-head-nav.css,
73
+ // with id 'jtd-head-nav-stylesheet'
74
+ // - a <style> containing the result of _includes/css/activation.scss.liquid.
75
+ // To avoid relying on the order of stylesheets (which can change with HTML
76
+ // compression, user-added JavaScript, and other side effects), stylesheets
77
+ // are only interacted with via ID
78
+
79
+ function disableHeadStyleSheets() {
80
+ const headNav = document.getElementById('jtd-head-nav-stylesheet');
81
+ if (headNav) {
82
+ headNav.disabled = true;
83
+ }
74
84
 
75
- function disableHeadStyleSheet() {
76
- if (document.styleSheets[1]) {
77
- document.styleSheets[1].disabled = true;
85
+ const activation = document.getElementById('jtd-nav-activation');
86
+ if (activation) {
87
+ activation.disabled = true;
78
88
  }
79
89
  }
80
90
 
@@ -491,6 +501,7 @@ function scrollNav() {
491
501
  if (targetLink) {
492
502
  const rect = targetLink.getBoundingClientRect();
493
503
  document.getElementById('site-nav').scrollBy(0, rect.top - 3*rect.height);
504
+ targetLink.removeAttribute('href');
494
505
  }
495
506
  }
496
507
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: just-the-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Marsceill
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-09-20 00:00:00.000000000 Z
12
+ date: 2023-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -100,9 +100,11 @@ files:
100
100
  - _includes/components/footer.html
101
101
  - _includes/components/header.html
102
102
  - _includes/components/mermaid.html
103
+ - _includes/components/nav.html
103
104
  - _includes/components/search_footer.html
104
105
  - _includes/components/search_header.html
105
106
  - _includes/components/sidebar.html
107
+ - _includes/components/site_nav.html
106
108
  - _includes/css/activation.scss.liquid
107
109
  - _includes/css/callouts.scss.liquid
108
110
  - _includes/css/custom.scss.liquid
@@ -112,7 +114,6 @@ files:
112
114
  - _includes/footer_custom.html
113
115
  - _includes/head.html
114
116
  - _includes/head_custom.html
115
- - _includes/head_nav.html
116
117
  - _includes/header_custom.html
117
118
  - _includes/icons/code_copy.html
118
119
  - _includes/icons/document.html
@@ -126,7 +127,6 @@ files:
126
127
  - _includes/lunr/custom-data.json
127
128
  - _includes/lunr/custom-index.js
128
129
  - _includes/mermaid_config.js
129
- - _includes/nav.html
130
130
  - _includes/nav_footer_custom.html
131
131
  - _includes/search_placeholder_custom.html
132
132
  - _includes/sorted_pages.html
@@ -179,6 +179,7 @@ files:
179
179
  - _sass/vendor/normalize.scss/normalize.scss
180
180
  - assets/css/just-the-docs-dark.scss
181
181
  - assets/css/just-the-docs-default.scss
182
+ - assets/css/just-the-docs-head-nav.css
182
183
  - assets/css/just-the-docs-light.scss
183
184
  - assets/js/just-the-docs.js
184
185
  - assets/js/vendor/lunr.min.js
@@ -1,48 +0,0 @@
1
- {%- comment -%}
2
- Include as: {%- include head_nav.html -%}
3
- Depends on: site.color_scheme.
4
- Results in: HTML for a page-specific style element.
5
- Includes:
6
- css/activation.scss.liquid.
7
- Overwrites:
8
- activation, test_scss, scss, css, index, count.
9
- Should not be cached, because css/activation.scss.liquid depends on page.
10
- {%- endcomment -%}
11
-
12
- {% capture activation %}
13
- {% include css/activation.scss.liquid %}
14
- {%- endcapture -%}
15
-
16
- {% capture test_scss %}
17
- @import "./support/support";
18
- @import "./color_schemes/light";
19
- {{ activation }}
20
- {%- endcapture -%}
21
-
22
- {%- capture scss -%}
23
- @import "./support/support";
24
- @import "./custom/setup";
25
- {% if site.color_scheme and site.color_scheme != "nil" -%}
26
- {%- assign color_scheme = site.color_scheme -%}
27
- {%- else -%}
28
- {%- assign color_scheme = "light" -%}
29
- {%- endif %}
30
- @import "./color_schemes/light";
31
- {% unless color_scheme == "light" %}
32
- @import "./color_schemes/{{ color_scheme }}";
33
- {% endunless %}
34
- {{ activation }}
35
- {%- endcapture -%}
36
-
37
- {%- comment -%}
38
- Convert to CSS, then remove the color_scheme import rules to avoid duplication.
39
- The value of count is page-dependent, but independent of custom color schemes.
40
- {%- endcomment -%}
41
- {%- assign count = test_scss | scssify | split: ".site-nav" | size -%}
42
- {%- unless count == 1 %}
43
- {%- assign index = 1 | minus: count -%}
44
- {%- assign css = scss | scssify | split: ".site-nav" | slice: index, count | join: ".site-nav" -%}
45
- <style type="text/css">
46
- {{ css | prepend: ".site-nav" }}
47
- </style>
48
- {%- endunless %}