just-the-docs 0.6.2 → 0.8.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: c8593eb0f4214116b46db9b1904d2585e794db893633690a78e5d77ad12c2b4f
4
+ data.tar.gz: dc7aa12e6092af9eabe4a5fd5509df6270fb197abcadff2bb4c4cb0a23993b25
5
5
  SHA512:
6
- metadata.gz: 9f751827832c8b1b958bd2c4d7f3b9812c3194a6a7e7bf023131e86cd4f408bad4037d09f99281e4212390265aa8a2dad709bd6f7005941433073e0d28bf545e
7
- data.tar.gz: fd30ebd6d9b5b4af76e31b62b1ce1b9621fa2b26dc2b87972072a52d40c30f652003043a63e2b9cc8f13a882a3a8b3c9ac291c321e736dd4b499632f5193fe1b
6
+ metadata.gz: c7673a1920061a093328ab384a5a23b25f5e7ec0a1759d09280aa89d07fe63e4df66ce343cd27265d7774ebf431cf45bd45b8ef44f91656371a9e121efd22d41
7
+ data.tar.gz: 39cf8e32b64c2973e9b463c52799c7d56ef57b42d06e46d97d3b92034ccfb131826f6e502e24528051dd067f926cbe5a8373af16a28f1bb0993c960a62e30c7e
data/CHANGELOG.md CHANGED
@@ -19,6 +19,129 @@ Code changes to `main` that are *not* in the latest release:
19
19
 
20
20
  - N/A
21
21
 
22
+ Docs changes made since the latest release:
23
+
24
+ - N/A
25
+
26
+ ## Release v0.8.0
27
+
28
+ Hi folks! This first minor release of 2024 has a short number of changes: a large improvement of build times for large sites, a new keyboard shortcut to focus the search bar, and sidebar navigation bugfixes for "pretty" URLs (with `.html` omitted) and the clickable area on Safari. This release has no explicit breaking changes and should be a straightforward upgrade for most (if not all) users.
29
+
30
+ ### Using Release `v0.8.0`
31
+
32
+ Users who have not pinned the theme version will be **automatically upgraded to `v0.8.0` the next time they build their site**.
33
+
34
+ To use this release explicitly as a remote theme:
35
+
36
+ ```yml
37
+ remote_theme: just-the-docs/just-the-docs@v0.8.0
38
+ ```
39
+
40
+ 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`:
41
+
42
+ ```ruby
43
+ gem "just-the-docs", "0.8.0"
44
+ ```
45
+
46
+ To use and pin a previous version of the theme, replace the `0.8.0` with the desired release tag.
47
+
48
+ ### New Features
49
+
50
+ - Added: configurable keyboard shortcut to focus search input by [@kcromanpl-bajra] in [#1411]
51
+
52
+ ### Bugfixes
53
+
54
+ - Fixed: quicker build by [@pdmosses] in [#1397]
55
+ - Fixed: incorrect navigation when `.html` omitted from URL by [@pdmosses] in [#1374]
56
+ - Fixed: incorrect positioning of clickable area for navigation links on Safari by [@mattxwang] in [#1403]
57
+
58
+ ### Documentation
59
+
60
+ - Add documentation to "Navigation Structure" on grouping pages with collections by [@mitchnemirov] in [#1390]
61
+
62
+ ### New Contributors
63
+
64
+ - [@mitchnemirov] made their first contribution in [#1390]
65
+ - [@kcromanpl-bajra] made their first contribution in [#1411]
66
+
67
+ [@mitchnemirov]: https://github.com/mitchnemirov
68
+ [@kcromanpl-bajra]: https://github.com/kcromanpl-bajra
69
+
70
+ [#1374]: https://github.com/just-the-docs/just-the-docs/pull/1374
71
+ [#1390]: https://github.com/just-the-docs/just-the-docs/pull/1390
72
+ [#1397]: https://github.com/just-the-docs/just-the-docs/pull/1397
73
+ [#1403]: https://github.com/just-the-docs/just-the-docs/pull/1403
74
+ [#1411]: https://github.com/just-the-docs/just-the-docs/pull/1411
75
+
76
+ ## Release v0.7.0
77
+
78
+ 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.
79
+
80
+ ### Migrating to `v0.7.0`
81
+
82
+ **Migration**: users will need to migrate if:
83
+
84
+ - they overrode `_includes/nav.html`, which has moved to `_includes/components/nav.html`
85
+ - they have an element with the IDs `jtd-nav-activation` or `jtd-head-nav-stylesheet`
86
+
87
+ For more, refer to the [migration guide](https://just-the-docs.com/MIGRATION/).
88
+
89
+ ### Using Release `v0.7.0`
90
+
91
+ Users who have not pinned the theme version will be **automatically upgraded to `v0.7.0` the next time they build their site**.
92
+
93
+ To use this release explicitly as a remote theme:
94
+
95
+ ```yml
96
+ remote_theme: just-the-docs/just-the-docs@v0.7.0
97
+ ```
98
+
99
+ 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`:
100
+
101
+ ```ruby
102
+ gem "just-the-docs", "0.7.0"
103
+ ```
104
+
105
+ To use and pin a previous version of the theme, replace the `0.7.0` with the desired release tag.
106
+
107
+ ### New Features
108
+
109
+ - Added: configuration options for opening external links in new tab by [@CarbonNeuron] in [#1360]
110
+
111
+ ### Bugfixes
112
+
113
+ - Fixed: remove href from the navigation link to the current page by [@pdmosses] in [#1356]
114
+ - Fixed: improve build time by [@pdmosses] in [#1358]
115
+ - Fixed: erroneous parentheses in `site_nav` conditional by [@mattxwang] in [#1366]
116
+ - Fixed: navigation scroll to active link regression by [@pdmosses] in [#1367]
117
+ - Fixed: invalid CSS rules in head elements by [@pdmosses] in [#1368]
118
+ - Fixed: accidental disabling of forward-declared stylesheets by [@mattxwang] in [#1373]
119
+
120
+ {: .warning }
121
+ [#1358] moved `_includes/nav.html` to the `_includes/components` directory,
122
+ Users who were overriding that file will need to adjust their sites accordingly.
123
+
124
+ ### Documentation:
125
+
126
+ - Docs: fix typos in `CHANGELOG` and `MIGRATION` by [@thapasusheel] in [#1377]
127
+
128
+ ### New Contributors
129
+
130
+ - [@CarbonNeuron] made their first contribution in [#1360]
131
+ - [@thapasusheel] made their first contribution in [#1377]
132
+
133
+ [@CarbonNeuron]: https://github.com/CarbonNeuron
134
+ [@thapasusheel]: https://github.com/thapasusheel
135
+
136
+ [#1356]: https://github.com/just-the-docs/just-the-docs/pull/1356
137
+ [#1358]: https://github.com/just-the-docs/just-the-docs/pull/1358
138
+ [#1360]: https://github.com/just-the-docs/just-the-docs/pull/1360
139
+ [#1366]: https://github.com/just-the-docs/just-the-docs/pull/1366
140
+ [#1367]: https://github.com/just-the-docs/just-the-docs/pull/1367
141
+ [#1368]: https://github.com/just-the-docs/just-the-docs/pull/1368
142
+ [#1373]: https://github.com/just-the-docs/just-the-docs/pull/1373
143
+ [#1377]: https://github.com/just-the-docs/just-the-docs/pull/1377
144
+
22
145
  ## Release v0.6.2
23
146
 
24
147
  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 +767,7 @@ This RC does not introduce any major user-facing features. It adds more customiz
644
767
 
645
768
  ### Trying out pre-release `v0.4.0.rc5`
646
769
 
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.
770
+ 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
771
 
649
772
  To use this RC explicitly as a remote theme:
650
773
 
@@ -745,7 +868,7 @@ Have any questions, thoughts, or concerns? We'd love to hear from you! Please [o
745
868
 
746
869
  ### Trying out pre-release `v0.4.0.rc4`
747
870
 
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`.
871
+ 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
872
 
750
873
  To use this RC explicitly as a remote theme:
751
874
 
@@ -866,7 +989,7 @@ As soon as we get stable test results from major downstream users, we'll push ou
866
989
 
867
990
  ### Trying out pre-release `v0.4.0.rc3`
868
991
 
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`.
992
+ 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
993
 
871
994
  To use this RC explicitly as a remote theme:
872
995
 
@@ -942,7 +1065,7 @@ The intention of this release candidate is to gather even more feedback on a pot
942
1065
 
943
1066
  ### Trying out pre-release `v0.4.0.rc2`
944
1067
 
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`.
1068
+ 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
1069
 
947
1070
  To use this RC explicitly as a remote theme:
948
1071
 
@@ -1030,7 +1153,7 @@ We want your feedback! Are these changes helpful? Are our docs easy to understan
1030
1153
 
1031
1154
  ### Trying out pre-release `v0.4.0.rc1`
1032
1155
 
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`.
1156
+ 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
1157
 
1035
1158
  To use this RC explicitly as a remote theme:
1036
1159
 
@@ -1542,7 +1665,7 @@ fixes #291 #256 #293 #177
1542
1665
 
1543
1666
  ## v0.2.1
1544
1667
 
1545
- This update fixes security vulnerablities in the lodash sub-dependency and bumps other dev dependencies to their latest version.
1668
+ This update fixes security vulnerabilities in the lodash sub-dependency and bumps other dev dependencies to their latest version.
1546
1669
 
1547
1670
  ## v0.2.0
1548
1671
 
@@ -3,39 +3,140 @@
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 -%}
11
+ {%- capture nav_list_link -%}
12
+ <a href="{{ page.url | relative_url }}" class="nav-list-link">
13
+ {%- endcapture -%}
14
+
15
+ {%- capture site_nav -%}
16
+ {%- include_cached components/site_nav.html -%}
17
+ {%- endcapture -%}
18
+
19
+ {%- if site_nav contains nav_list_link -%}
20
+
21
+ {%- capture nav_list_simple -%}
22
+ <ul class="nav-list">
23
+ {%- endcapture -%}
24
+
25
+ {%- capture nav_list_link_class %} class="nav-list-link">
26
+ {%- endcapture -%}
27
+
28
+ {%- capture nav_category -%}
29
+ <div class="nav-category">
30
+ {%- endcapture -%}
31
+
32
+ {%- assign nav_anchor_splits =
33
+ site_nav | split: nav_list_link |
34
+ first | split: nav_category |
35
+ last | split: "</a>" -%}
36
+
37
+ {%- comment -%}
38
+ The ordinary pages (if any) and the collections pages (if any) are separated by
39
+ occurrences of nav_category.
40
+
41
+ Any ancestor nav-links of the page are contained in the last group of pages,
42
+ immediately preceding nav-lists. After splitting at "</a>", the anchor that
43
+ was split is a potential ancestor link when the following split starts with
44
+ a nav-list.
45
+
46
+ The array nav_breadcrumbs is the stack of current potential ancestors of the
47
+ current page. A split that contains one or more "</ul>"s requires that number
48
+ of potential ancestors to be popped from the stack.
49
+
50
+ The number of occurrences of a string in nav_split_next is computed by removing
51
+ them all, then dividing the resulting size difference by the length of the string.
52
+ {%- endcomment %}
53
+
54
+ {%- assign nav_breadcrumbs = "" | split: "" -%}
55
+
56
+ {%- for nav_split in nav_anchor_splits -%}
57
+ {%- unless forloop.last -%}
58
+
59
+ {%- assign nav_split_next = nav_anchor_splits[forloop.index] | trim -%}
60
+
61
+ {%- assign nav_split_test =
62
+ nav_split_next | remove_first: nav_list_simple | prepend: nav_list_simple -%}
63
+ {%- if nav_split_test == nav_split_next -%}
64
+ {%- assign nav_breadcrumb_link =
65
+ nav_split | split: "<a " | last | prepend: "<a " |
66
+ replace: nav_list_link_class, ">" | append: "</a>" -%}
67
+ {%- assign nav_breadcrumbs = nav_breadcrumbs | push: nav_breadcrumb_link -%}
68
+ {%- endif -%}
69
+
70
+ {%- if nav_split_next contains "</ul>" -%}
71
+ {%- assign nav_list_end_less = nav_split_next | remove: "</ul>" -%}
72
+ {%- assign nav_list_end_count =
73
+ nav_split_next.size | minus: nav_list_end_less.size | divided_by: 5 -%}
74
+ {% for nav_end_index in (1..nav_list_end_count) %}
75
+ {%- assign nav_breadcrumbs = nav_breadcrumbs | pop -%}
76
+ {%- endfor -%}
77
+ {%- endif -%}
78
+
79
+ {%- endunless -%}
80
+ {%- endfor -%}
81
+
82
+ {%- assign nav_parent_link = nav_breadcrumbs[-1] -%}
83
+ {%- assign nav_grandparent_link = nav_breadcrumbs[-2] -%}
84
+
85
+ {%- else -%}
86
+
87
+ {%- comment -%}
88
+ Pages whose links are excluded from the main navigation may still have
89
+ breadcrumbs. Determining them appears to require inspecting the front matter
90
+ of all the pages in the same group. For sites with 100s of pages, this is too
91
+ inefficient in Jekyll 3 (also when the for-loop is replaced by where-filters).
92
+ {%- endcomment -%}
93
+
94
+ {%- assign pages_list = site[page.collection] | default: site.html_pages -%}
95
+
96
+ {%- assign parent_page = nil -%}
97
+ {%- assign grandparent_page = nil -%}
98
+
99
+ {%- for node in pages_list -%}
100
+
101
+ {%- if node.has_children and page.grand_parent -%}
102
+
103
+ {%- if node.title == page.parent and node.parent == page.grand_parent -%}
104
+ {%- assign parent_page = node -%}
105
+ {%- endif -%}
106
+ {%- if node.title == page.grand_parent -%}
107
+ {%- assign grandparent_page = node -%}
108
+ {%- endif -%}
109
+ {%- if parent_page and grandparent_page -%}
110
+ {%- break -%}
111
+ {%- endif -%}
112
+
113
+ {%- elsif node.has_children and node.title == page.parent and node.parent == nil -%}
114
+
115
+ {%- assign parent_page = node -%}
116
+ {%- break -%}
117
+
118
+ {%- endif -%}
119
+
120
+ {%- endfor -%}
121
+
122
+ {%- capture nav_parent_link -%}
123
+ <a href="{{ parent_page.url | relative_url }}">{{ page.parent }}</a>
124
+ {%- endcapture -%}
125
+
126
+ {%- if page.grand_parent %}
127
+ {%- capture nav_grandparent_link -%}
128
+ <a href="{{ grandparent_page.url | relative_url }}">{{ page.grand_parent }}</a>
129
+ {%- endcapture -%}
29
130
  {%- endif -%}
30
131
 
132
+ {%- endif -%}
133
+
31
134
  <nav aria-label="Breadcrumb" class="breadcrumb-nav">
32
135
  <ol class="breadcrumb-nav-list">
33
- {% if page.parent -%}
34
- {%- if page.grand_parent %}
35
- <li class="breadcrumb-nav-list-item"><a href="{{ grandparent_page.url | relative_url }}">{{ page.grand_parent }}</a></li>
136
+ {%- if nav_grandparent_link %}
137
+ <li class="breadcrumb-nav-list-item">{{ nav_grandparent_link }}</li>
36
138
  {%- endif %}
37
- <li class="breadcrumb-nav-list-item"><a href="{{ parent_page.url | relative_url }}">{{ page.parent }}</a></li>
38
- {% endif -%}
139
+ <li class="breadcrumb-nav-list-item">{{ nav_parent_link }}</li>
39
140
  <li class="breadcrumb-nav-list-item"><span>{{ page.title }}</span></li>
40
141
  </ol>
41
142
  </nav>
@@ -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,172 +1,332 @@
1
1
  {%- comment -%}
2
2
  Include as: {%- include css/activation.scss.liquid -%}
3
- Depends on: page, site.
4
- Results in: page-dependent SCSS rules for inclusion in a head style element.
5
- Includes:
6
- sorted_pages.html.
3
+ Depends on: page.
4
+ Results in: page-dependent CSS rules for inclusion in a style element,
5
+ which needs to be disabled when JS is enabled.
6
+ Includes: components/site_nav.html.
7
7
  Overwrites:
8
- activation_pages, activation_pages_top_size, activation_page, activation_title,
9
- activation_first_level, activation_second_level, activation_third_level,
10
- activation_first_level_reversed, activation_second_level_reversed,
11
- activation_first_level_index, activation_second_level_index, activation_third_level_index.
8
+ activation_no_nav_link, nav_list_link, site_nav,
9
+ nav_list, nav_list_end, nav_list_item, nav_category_list,
10
+ nav_list_link_prefix, nav_splits, nav_split, nav_levels,
11
+ nav_list_less, nav_list_count, nav_end_less, nav_end_count,
12
+ nav_index, nav_slice_size,
13
+ activation_collection_prefix, activation_other_collection_prefix.
12
14
  Should not be cached, because it depends on page.
13
- (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.)
15
15
  {%- endcomment -%}
16
16
 
17
- {%- unless page.title == nil or page.nav_exclude == true -%}
18
-
19
- {%- assign activation_pages = site[page.collection]
20
- | default: site.html_pages
21
- | where_exp: "item", "item.title != nil"
22
- | where_exp: "item", "item.nav_exclude != true" -%}
23
-
24
- {%- assign activation_first_level_index = nil -%}
25
- {%- assign activation_second_level_index = nil -%}
26
- {%- assign activation_third_level_index = nil -%}
27
- {%- assign activation_first_level_reversed = nil -%}
28
- {%- assign activation_second_level_reversed = nil -%}
29
-
30
- {%- assign activation_title = page.grand_parent | default: page.parent | default: page.title -%}
31
- {%- assign activation_first_level = activation_pages
32
- | where_exp: "item", "item.parent == nil" -%}
33
- {%- include sorted_pages.html pages = activation_first_level -%}
34
- {%- for activation_page in sorted_pages -%}
35
- {%- if activation_page.title == activation_title -%}
36
- {%- assign activation_first_level_index = forloop.index -%}
37
- {%- assign activation_first_level_reversed = activation_page.child_nav_order -%}
38
- {%- break -%}
39
- {%- endif -%}
40
- {%- endfor -%}
17
+ {%- comment -%}
18
+ The CSS rules in activation_no_nav_link are for use on pages excluded from the main navigation.
19
+ - The first rule ensures that no nav-link has a background image.
20
+ - The other two rules ensure that all folding collections are expanded.
21
+ {%- endcomment -%}
41
22
 
42
- {%- unless activation_first_level_index == nil -%}
43
-
44
- {%- if page.grand_parent -%}
45
- {%- assign activation_title = page.parent -%}
46
- {%- assign activation_second_level = activation_pages
47
- | where_exp: "item", "item.grand_parent == nil"
48
- | where_exp: "item", "item.parent == page.grand_parent" -%}
49
- {%- elsif page.parent -%}
50
- {%- assign activation_title = page.title -%}
51
- {%- assign activation_second_level = activation_pages
52
- | where_exp: "item", "item.grand_parent == nil"
53
- | where_exp: "item", "item.parent == page.parent" -%}
54
- {%- endif -%}
55
- {%- if page.parent -%}
56
- {%- include sorted_pages.html pages = activation_second_level -%}
57
- {%- for activation_page in sorted_pages -%}
58
- {%- if activation_page.title == activation_title -%}
59
- {%- assign activation_second_level_index = forloop.index -%}
60
- {%- assign activation_second_level_reversed = activation_page.child_nav_order -%}
61
- {%- if activation_first_level_reversed -%}
62
- {%- assign activation_second_level_index = sorted_pages | size | plus: 1 | minus: activation_second_level_index -%}
63
- {%- endif -%}
64
- {%- break -%}
23
+ {%- capture activation_no_nav_link %}
24
+ .site-nav ul li a {
25
+ background-image: none;
26
+ }
27
+
28
+ {%- if site.just_the_docs.collections %}
29
+ .site-nav > ul.nav-category-list > li > button svg {
30
+ transform: rotate(-90deg);
31
+ }
32
+ .site-nav > ul.nav-category-list > li.nav-list-item > ul.nav-list {
33
+ display: block;
34
+ }
35
+ {%- endif %}
36
+ {% endcapture -%}
37
+
38
+ {%- capture nav_list_link -%}
39
+ <a href="{{ page.url | relative_url }}" class="nav-list-link">
40
+ {%- endcapture -%}
41
+
42
+ {%- capture site_nav -%}
43
+ {%- include_cached components/site_nav.html -%}
44
+ {%- endcapture -%}
45
+
46
+ {%- if site_nav contains nav_list_link -%}
47
+
48
+ {%- capture nav_list -%}
49
+ <ul class="nav-list
50
+ {%- endcapture -%}
51
+
52
+ {%- assign nav_list_end = "</ul>" -%}
53
+
54
+ {%- capture nav_list_item -%}
55
+ <li class="nav-list-item
56
+ {%- endcapture -%}
57
+
58
+ {%- capture nav_category_list -%}
59
+ <ul class="nav-list nav-category-list">
60
+ {%- endcapture -%}
61
+
62
+ {%- assign nav_list_link_prefix =
63
+ site_nav | split: nav_list_link | first | append: nav_list_link -%}
64
+
65
+ {%- assign nav_splits =
66
+ nav_list_link_prefix | split: nav_list_item | pop -%}
67
+
68
+ {%- assign nav_levels = "" | split: "" | push: 1 -%}
69
+
70
+ {%- comment -%}
71
+ The pattern of occurrences of list and list-item tags in the site_nav string
72
+ is included in the language defined by the following context-free grammar:
73
+
74
+ site_nav = PAGES? EXTERNALS? COLLECTION*
75
+
76
+ PAGES = nav_list (nav_list_item PAGES?)+ nav_list_end
77
+
78
+ EXTERNALS = nav_list nav_list_item+ nav_list_end
79
+
80
+ COLLECTION = nav_list (nav_list_item PAGES?)* nav_list_end
81
+ | nav_category_list
82
+ nav_list_item nav_list (nav_list_item PAGES?)* nav_list_end
83
+ nav_list_end
84
+
85
+ To determine the path in the site_nav to the nav_list_link for the current page,
86
+ the prefix of nav_list_link in site_nav is split at each nav_list_item to give
87
+ an array of nav_splits.
88
+
89
+ In site_nav, occurrences of nav_list must be separated by at least one
90
+ nav_list_item or nav_list_end. Moreover, when a nav_list_end is followed by a
91
+ nav_list without an intervening nav_list_item, that nav_list must start either
92
+ a list of external links or a collection. And when a nav_list is followed by a
93
+ nav_list_end without an intervening nav_list_item, they form an empty collection.
94
+
95
+ nav_levels is the path determined by the previously inspected nav_splits.
96
+ How many times nav_list and nav_list_end occur in the current nav_split
97
+ determines how to update the path.
98
+
99
+ A nav_split can contain any number of empty non-foldable collections.
100
+ The path element produced by the outer nav_list of a foldable collection is
101
+ irrelevant; it is set to zero and subsequently removed.
102
+
103
+ The number of occurrences of a string in a nav_split is computed by removing
104
+ them all, then dividing the resulting size difference by the length of the string.
105
+
106
+ Case analysis on (nav_list_count, nav_list_end_count):
107
+
108
+ - when (0, 0), the nav_split was between two nav_list_items at the same level;
109
+
110
+ - when (0, N+1), all the nav_list_ends in the nav_split are in PAGES or in one
111
+ COLLECTION;
112
+
113
+ - when (M+1, 0), M must be 0 (because two nav_lists in the same nav_split must
114
+ be separated by at least one nav_list_end);
115
+
116
+ - when (M+1, N+1), the nav_split must contain either:
117
+ - the end of PAGES followed by the start of EXTERNALS, or
118
+ - the end of PAGES followed by the start of a COLLECTION, or
119
+ - the end of EXTERNALS followed by the start of a COLLECTION, or
120
+ - the end of one COLLECTION followed by the start of another, or
121
+ - (in the first nav_split) one or more empty non-foldable COLLECTIONS
122
+ followed by the start of a COLLECTION.
123
+ In general, nav_levels[0] here needs to be incremented by nav_list_count.
124
+ However, a nav_split that contains the end of an empty foldable collection
125
+ followed by the just the start of a collection has two occurrences of nav_list,
126
+ and the increment needs to be one less; similarly when the first nav_split
127
+ starts with an empty non-foldable collection.
128
+ {%- endcomment %}
129
+
130
+ {%- for nav_split in nav_splits -%}
131
+
132
+ {%- assign nav_list_less = nav_split | remove: nav_list -%}
133
+ {%- assign nav_list_count =
134
+ nav_split.size | minus: nav_list_less.size |
135
+ divided_by: nav_list.size -%}
136
+
137
+ {%- assign nav_list_end_less = nav_split | remove: nav_list_end -%}
138
+ {%- assign nav_list_end_count =
139
+ nav_split.size | minus: nav_list_end_less.size |
140
+ divided_by: nav_list_end.size -%}
141
+
142
+ {%- if nav_list_count == 0 and nav_list_end_count == 0 -%}
143
+
144
+ {%- assign nav_index = nav_levels[-1] | plus: 1 -%}
145
+ {%- assign nav_levels = nav_levels | pop | push: nav_index -%}
146
+
147
+ {%- elsif nav_list_count == 0 and nav_list_end_count >= 1 -%}
148
+
149
+ {%- assign nav_slice_size = nav_levels.size | minus: nav_list_end_count -%}
150
+ {%- assign nav_levels = nav_levels | slice: 0, nav_slice_size -%}
151
+ {%- assign nav_index = nav_levels[-1] | plus: 1 -%}
152
+ {%- assign nav_levels = nav_levels | pop | push: nav_index -%}
153
+
154
+ {%- elsif nav_list_count == 1 and nav_list_end_count == 0 -%}
155
+
156
+ {%- if nav_split contains nav_category_list -%}
157
+ {%- assign nav_levels = nav_levels | push: 0 -%}
158
+ {%- else -%}
159
+ {%- assign nav_levels = nav_levels | push: 1 -%}
65
160
  {%- endif -%}
66
- {%- endfor -%}
67
- {%- endif -%}
68
161
 
69
- {%- if page.grand_parent -%}
70
- {%- assign activation_third_level = activation_pages
71
- | where_exp: "item", "item.parent == page.parent"
72
- | where_exp: "item", "item.grand_parent == page.grand_parent" -%}
73
- {%- include sorted_pages.html pages = activation_third_level -%}
74
- {%- assign activation_third_level = sorted_pages -%}
75
- {%- for activation_page in sorted_pages -%}
76
- {%- if activation_page.title == page.title -%}
77
- {%- assign activation_third_level_index = forloop.index -%}
78
- {%- if activation_second_level_reversed -%}
79
- {%- assign activation_third_level_index = sorted_pages | size | plus: 1 | minus: activation_third_level_index -%}
80
- {%- endif -%}
81
- {%- break -%}
162
+ {%- elsif nav_list_count >= 1 and nav_list_end_count >= 1 -%}
163
+
164
+ {%- assign nav_index = nav_levels[0] | plus: nav_list_count -%}
165
+ {%- if nav_levels[-1] == 0 or forloop.first -%}
166
+ {%- assign nav_index = nav_index | minus: 1 -%}
167
+ {%- endif -%}
168
+ {%- assign nav_levels = nav_levels | slice: 0, 0 | push: nav_index -%}
169
+ {%- if nav_split contains nav_category_list -%}
170
+ {%- assign nav_levels = nav_levels | push: 0 -%}
171
+ {%- else -%}
172
+ {%- assign nav_levels = nav_levels | push: 1 -%}
82
173
  {%- endif -%}
83
- {%- endfor -%}
174
+
175
+ {%- endif -%}
176
+
177
+ {%- endfor -%}
178
+
179
+ {%- assign nav_levels = nav_levels | where_exp: "item", "item >= 1" -%}
180
+
84
181
  {%- endif -%}
85
182
 
86
- {%- unless activation_second_level_index == nil and activation_third_level_index -%}
183
+ {%- comment -%}
184
+ The generated CSS depends on the position of the current page in each level in
185
+ the navigation.
186
+ {%- endcomment -%}
187
+
188
+ {%- if nav_levels[1] == nil -%}
189
+
190
+ {{ activation_no_nav_link }}
191
+
192
+ {%- else -%}
193
+
194
+ {%- if nav_levels[2] == nil and nav_levels[3] -%}
195
+
196
+ {{ activation_no_nav_link }}
197
+
198
+ {%- else -%}
199
+
200
+ {%- comment -%}
201
+ The site-nav is:
202
+ - an optional ul.nav-list with li.nav-list-items for non-collection top-level pages
203
+ - an optional ul.nav-list with li.nav-list-item.externals
204
+ - any number of just-the-docs.collections
205
+
206
+ A non-foldable collection is:
207
+ - a div.nav-category with the collection name, followed by:
208
+ - a ul.nav-list with li.nav-list-items for its top-level pages
209
+
210
+ A foldable collection is:
211
+ - a ul.nav-list.nav-category-list with a single li.nav-list-item containing:
212
+ - an optional button with the expander svg
213
+ - a div.nav-category with the collection name
214
+ - a ul.nav-list with li.nav-list-items for its top-level pages
215
+
216
+ The generated CSS uses:
217
+ - activation_collection_prefix, to select the site-nav > ul.nav-list for the page
218
+ - activation_other_collection_prefix, to select all the other site-nav > ul.nav-lists
219
+ {%- endcomment -%}
87
220
 
88
221
  {%- if page.collection == nil -%}
89
222
 
90
223
  {%- capture activation_collection_prefix -%}
91
- .site-nav > .nav-list:nth-child(1):not(.nav-category-list)
224
+ .site-nav > ul.nav-list:first-child
225
+ {%- endcapture -%}
226
+
227
+ {%- capture activation_other_collection_prefix -%}
228
+ .site-nav > ul.nav-list:not(:first-child)
92
229
  {%- endcapture -%}
93
230
 
94
231
  {%- else -%}
95
232
 
96
- {%- for activation_collection in site.just_the_docs.collections -%}
97
- {%- if activation_collection[0] == page.collection -%}
98
- {%- assign activation_collection_index = forloop.index -%}
99
- {%- break -%}
100
- {%- endif -%}
101
- {%- endfor -%}
102
- {%- assign activation_index = activation_collection_index -%}
103
- {%- assign activation_pages_top_size = site.html_pages
104
- | where_exp:"item", "item.title != nil"
105
- | where_exp:"item", "item.parent == nil"
106
- | where_exp:"item", "item.nav_exclude != true"
107
- | size -%}
108
- {%- if activation_pages_top_size > 0 -%}
109
- {%- assign activation_index = activation_index | plus: 1 -%}
110
- {%- endif -%}
111
- {%- if site.nav_external_links -%}
112
- {%- assign activation_index = activation_index | plus: 1 -%}
113
- {%- endif -%}
114
233
  {%- 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 %}
234
+ .site-nav > ul:nth-of-type({{ nav_levels[0] }})
235
+ {%- if site.just_the_docs.collections[page.collection].nav_fold %} > li > ul
236
+ {%- endif -%}
116
237
  {%- endcapture -%}
117
-
238
+
239
+ {%- capture activation_other_collection_prefix -%}
240
+ .site-nav > ul:not(:nth-of-type({{ nav_levels[0] }}))
241
+ {%- endcapture -%}
242
+
118
243
  {%- endif -%}
119
244
 
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
- }
245
+ {%- comment -%}
246
+ The required background image of the link to the current page may involve SCSS.
247
+ To avoid page-dependent SCSS, all nav links initially have that background image.
248
+ The following rule removes the image from the links to all parents, siblings,
249
+ and children of the current page.
250
+ {%- endcomment %}
251
+
252
+ {% if nav_levels[3] -%}
253
+
254
+ {{ activation_collection_prefix }} > li > a,
255
+ {{ activation_collection_prefix }} > li > ul > li > a,
256
+ {{ activation_collection_prefix }} > li > ul > li > ul > li:not(:nth-child({{ nav_levels[3] }})) > a {
257
+ background-image: none;
135
258
  }
136
259
 
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
- }
260
+ {%- elsif nav_levels[2] -%}
261
+
262
+ {{ activation_collection_prefix }} > li > a,
263
+ {{ activation_collection_prefix }} > li > ul > li:not(:nth-child({{ nav_levels[2] }})) > a,
264
+ {{ activation_collection_prefix }} > li > ul > li > ul > li > a {
265
+ background-image: none;
153
266
  }
154
267
 
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
- }
268
+ {%- else -%}
269
+
270
+ {{ activation_collection_prefix }} > li:not(:nth-child({{ nav_levels[1] }})) > a,
271
+ {{ activation_collection_prefix }} > li > ul > li > a,
272
+ {{ activation_collection_prefix }} > li > ul > li > ul > li > a {
273
+ background-image: none;
168
274
  }
169
275
 
170
- {%- endunless -%}
171
- {%- endunless -%}
172
- {%- endunless -%}
276
+ {%- endif %}
277
+
278
+ {%- comment -%}
279
+ The following rule removes the image from the links to pages in other collections.
280
+ {%- endcomment %}
281
+
282
+ {{ activation_other_collection_prefix }} a,
283
+ .site-nav li.external a {
284
+ background-image: none;
285
+ }
286
+
287
+ {%- comment -%}
288
+ The following rule styles the link to the current page.
289
+ {%- endcomment %}
290
+
291
+ {{ activation_collection_prefix }} > li:nth-child({{ nav_levels[1] }})
292
+ {%- if nav_levels[2] %} > ul > li:nth-child({{ nav_levels[2] }})
293
+ {%- if nav_levels[3] %} > ul > li:nth-child({{ nav_levels[3] }})
294
+ {%- endif -%}
295
+ {%- endif %} > a {
296
+ font-weight: 600;
297
+ text-decoration: none;
298
+ }
299
+
300
+ {%- comment -%}
301
+ The following rules unfold all collections, and display the links to any children
302
+ of the current page.
303
+
304
+ To avoid dependence on the SCSS variable nav-list-expander-right, the direction
305
+ of the rotation of the expander icon is fixed, and corresponds to the appearance
306
+ when nav-list-expander-right is true. This results in a minor visual difference
307
+ between the appearance of active expander icons when JS is enabled/disabled and
308
+ nav-list-expander-right is false, which seems unavoidable.
309
+ {%- endcomment %}
310
+
311
+ {%- if site.just_the_docs.collections %}
312
+ .site-nav > ul.nav-category-list > li > button svg,
313
+ {% endif -%}
314
+ {{ activation_collection_prefix }} > li:nth-child({{ nav_levels[1] }}) > button svg
315
+ {%- if nav_levels[2] -%},
316
+ {{ activation_collection_prefix }} > li:nth-child({{ nav_levels[1] }}) > ul > li:nth-child({{ nav_levels[2] }}) > button svg
317
+ {%- endif %} {
318
+ transform: rotate(-90deg);
319
+ }
320
+
321
+ {%- if site.just_the_docs.collections %}
322
+ .site-nav > ul.nav-category-list > li.nav-list-item > ul.nav-list,
323
+ {% endif -%}
324
+ {{ activation_collection_prefix }} > li.nav-list-item:nth-child({{ nav_levels[1] }}) > ul.nav-list
325
+ {%- if nav_levels[2] %},
326
+ {{ activation_collection_prefix }} > li.nav-list-item:nth-child({{ nav_levels[1] }}) > ul.nav-list > li.nav-list-item:nth-child({{ nav_levels[2] }}) > ul.nav-list
327
+ {%- endif %} {
328
+ display: block;
329
+ }
330
+
331
+ {%- endif -%}
332
+ {%- endif -%}
@@ -1,29 +1,37 @@
1
1
  {%- comment -%}
2
- This file can be used to fix the HTML produced by Jekyll for highlighted
3
- code with line numbers.
2
+ This file was previously used to "fix" the HTML produced by Jekyll for
3
+ highlighted code with line numbers. While it often resolves layout issues
4
+ from the missing HTML tags, it still generates invalid HTML (by placing
5
+ a `<table>` element within a `<code>` block). As such, we no longer
6
+ recommend using this workaround. For more information, see the
7
+ "Code snippets with line numbers" docs page:
8
+ https://just-the-docs.com/docs/ui-components/code/line-numbers/
9
+ (or, docs/ui-components/line-nos.md/)
4
10
 
5
- It works with `{% highlight some_language linenos %}...{% endhighlight %}`
6
- and with the Kramdown option to add line numbers to fenced code.
11
+ The next portion of this file, including the comments and the workaround,
12
+ are preserved for backwards comptability.
7
13
 
8
- The implementation was derived from the workaround provided by
14
+ ACKNOWLEDGEMENTS
15
+
16
+ The implementation was derived from the workaround provided by
9
17
  Dmitry Hrabrov (DeXP) at
10
18
  https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-188144901
11
19
 
12
- EXPLANATION
20
+ EXPLANATION (OLD)
13
21
 
14
- The HTML produced by Rouge highlighting with lie numbers is of the form
15
- `code table`. Jekyll (<= 4.1.1) always wraps the highlighted HTML
22
+ The HTML produced by Rouge highlighting with line numbers is of the form
23
+ `code table`. Jekyll always wraps the highlighted HTML
16
24
  with `pre`. This wrapping is not only unnecessary, but also transforms
17
25
  the conforming HTML produced by Rouge to non-conforming HTML, which
18
- results in HTML validation error reports.
26
+ results in HTML validation error reports.
19
27
 
20
28
  The fix removes the outer `pre` tags whenever they contain the pattern
21
29
  `<table class="rouge-table">`.
22
-
30
+
23
31
  Apart from avoiding HTML validation errors, the fix allows the use of
24
32
  the [Jekyll layout for compressing HTML](http://jch.penibelst.de),
25
33
  which relies on `pre` tags not being nested, according to
26
- https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-172069842
34
+ https://github.com/penibelst/jekyll-compress-html/issues/71#issuecomment-172069842
27
35
 
28
36
  USAGE
29
37
 
@@ -48,7 +56,7 @@ Some code
48
56
 
49
57
  CAVEATS
50
58
 
51
- The above does not work when `Some code` happens to contain the matched string
59
+ The above does not work when `Some code` happens to contain the matched string
52
60
  `<table class="rouge-table">`.
53
61
 
54
62
  The use of this file overwrites the variable `fix_linenos_code` with `nil`.
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
 
@@ -135,6 +145,18 @@ function searchLoaded(index, docs) {
135
145
  var currentInput;
136
146
  var currentSearchIndex = 0;
137
147
 
148
+ {%- if site.search.focus_shortcut_key %}
149
+ // add event listener on ctrl + <focus_shortcut_key> for showing the search input
150
+ jtd.addEvent(document, 'keydown', function (e) {
151
+ if ((e.ctrlKey || e.metaKey) && e.key === '{{ site.search.focus_shortcut_key }}') {
152
+ e.preventDefault();
153
+
154
+ mainHeader.classList.add('nav-open');
155
+ searchInput.focus();
156
+ }
157
+ });
158
+ {%- endif %}
159
+
138
160
  function showSearch() {
139
161
  document.documentElement.classList.add('search-active');
140
162
  }
@@ -477,11 +499,28 @@ jtd.setTheme = function(theme) {
477
499
  // and not have the slash on GitHub Pages
478
500
 
479
501
  function navLink() {
480
- var href = document.location.pathname;
481
- if (href.endsWith('/') && href != '/') {
482
- href = href.slice(0, -1);
502
+ var pathname = document.location.pathname;
503
+
504
+ var navLink = document.getElementById('site-nav').querySelector('a[href="' + pathname + '"]');
505
+ if (navLink) {
506
+ return navLink;
507
+ }
508
+
509
+ // The `permalink` setting may produce navigation links whose `href` ends with `/` or `.html`.
510
+ // To find these links when `/` is omitted from or added to pathname, or `.html` is omitted:
511
+
512
+ if (pathname.endsWith('/') && pathname != '/') {
513
+ pathname = pathname.slice(0, -1);
483
514
  }
484
- return document.getElementById('site-nav').querySelector('a[href="' + href + '"], a[href="' + href + '/"]');
515
+
516
+ if (pathname != '/') {
517
+ navLink = document.getElementById('site-nav').querySelector('a[href="' + pathname + '"], a[href="' + pathname + '/"], a[href="' + pathname + '.html"]');
518
+ if (navLink) {
519
+ return navLink;
520
+ }
521
+ }
522
+
523
+ return null; // avoids `undefined`
485
524
  }
486
525
 
487
526
  // Scroll site-nav to ensure the link to the current page is visible
@@ -489,8 +528,8 @@ function navLink() {
489
528
  function scrollNav() {
490
529
  const targetLink = navLink();
491
530
  if (targetLink) {
492
- const rect = targetLink.getBoundingClientRect();
493
- document.getElementById('site-nav').scrollBy(0, rect.top - 3*rect.height);
531
+ targetLink.scrollIntoView({ block: "center" });
532
+ targetLink.removeAttribute('href');
494
533
  }
495
534
  }
496
535
 
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.8.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: 2024-02-23 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 %}