just-the-docs 0.7.0 → 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: 6b96a130e7da963319bffcbfc09ce39881f538bfe8b56f2809251d29ab7aeb40
4
- data.tar.gz: 7a1ec7d332331653d64e2adc7e8f157adf4fbb8f0041261f0b165032861b47ca
3
+ metadata.gz: c8593eb0f4214116b46db9b1904d2585e794db893633690a78e5d77ad12c2b4f
4
+ data.tar.gz: dc7aa12e6092af9eabe4a5fd5509df6270fb197abcadff2bb4c4cb0a23993b25
5
5
  SHA512:
6
- metadata.gz: f033dfe192101707e7b6bebea2b6b0628a5d8a401a32bc6adda5bc483b126af8f98efa7eaf51dc62e399d0dfea09d39d96a91cf5c31b4a1c53d07fcb96a1a288
7
- data.tar.gz: 5e9203f6620f854339e979b74811f677357baf57746aba62d242ffe1cc1f58de0eff2e8a8596e2377f317d65af6ad8e9b379a6a532e637b7bb32404f068a216e
6
+ metadata.gz: c7673a1920061a093328ab384a5a23b25f5e7ec0a1759d09280aa89d07fe63e4df66ce343cd27265d7774ebf431cf45bd45b8ef44f91656371a9e121efd22d41
7
+ data.tar.gz: 39cf8e32b64c2973e9b463c52799c7d56ef57b42d06e46d97d3b92034ccfb131826f6e502e24528051dd067f926cbe5a8373af16a28f1bb0993c960a62e30c7e
data/CHANGELOG.md CHANGED
@@ -19,6 +19,60 @@ 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
+
22
76
  ## Release v0.7.0
23
77
 
24
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.
@@ -8,8 +8,91 @@
8
8
 
9
9
  {%- if page.url != "/" and page.parent -%}
10
10
 
11
- {%- assign pages_list = site[page.collection] | default: site.html_pages -%}
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 -%}
12
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
+
13
96
  {%- assign parent_page = nil -%}
14
97
  {%- assign grandparent_page = nil -%}
15
98
 
@@ -35,15 +118,25 @@
35
118
  {%- endif -%}
36
119
 
37
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 -%}
130
+ {%- endif -%}
131
+
132
+ {%- endif -%}
38
133
 
39
134
  <nav aria-label="Breadcrumb" class="breadcrumb-nav">
40
135
  <ol class="breadcrumb-nav-list">
41
- {% if page.parent -%}
42
- {%- if page.grand_parent %}
43
- <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>
44
138
  {%- endif %}
45
- <li class="breadcrumb-nav-list-item"><a href="{{ parent_page.url | relative_url }}">{{ page.parent }}</a></li>
46
- {% endif -%}
139
+ <li class="breadcrumb-nav-list-item">{{ nav_parent_link }}</li>
47
140
  <li class="breadcrumb-nav-list-item"><span>{{ page.title }}</span></li>
48
141
  </ol>
49
142
  </nav>
@@ -1,19 +1,17 @@
1
1
  {%- comment -%}
2
2
  Include as: {%- include css/activation.scss.liquid -%}
3
- Depends on: page, site.
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.
6
- Includes:
7
- 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.
8
7
  Overwrites:
9
- activation_no_nav_link, activation_pages, activation_pages_top_size, activation_page, activation_title,
10
- activation_first_level, activation_second_level, activation_third_level,
11
- activation_first_level_reversed, activation_second_level_reversed,
12
- activation_first_level_index, activation_second_level_index, activation_third_level_index,
13
- activation_index, activation_collection_prefix, activation_other_collection_prefix.
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.
14
14
  Should not be cached, because it depends on page.
15
- (For a site with only top-level pages, the rendering of this file is always empty.
16
- This property could be detected, and used to reduce the build time for such sites.)
17
15
  {%- endcomment -%}
18
16
 
19
17
  {%- comment -%}
@@ -37,89 +35,163 @@
37
35
  {%- endif %}
38
36
  {% endcapture -%}
39
37
 
40
- {%- if page.title == nil or page.nav_exclude == true -%}
38
+ {%- capture nav_list_link -%}
39
+ <a href="{{ page.url | relative_url }}" class="nav-list-link">
40
+ {%- endcapture -%}
41
41
 
42
- {{ activation_no_nav_link }}
42
+ {%- capture site_nav -%}
43
+ {%- include_cached components/site_nav.html -%}
44
+ {%- endcapture -%}
43
45
 
44
- {%- else -%}
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 -%}
45
64
 
46
- {%- assign activation_pages = site[page.collection]
47
- | default: site.html_pages
48
- | where_exp: "item", "item.title != nil"
49
- | where_exp: "item", "item.nav_exclude != true" -%}
65
+ {%- assign nav_splits =
66
+ nav_list_link_prefix | split: nav_list_item | pop -%}
50
67
 
51
- {%- assign activation_first_level_index = nil -%}
52
- {%- assign activation_second_level_index = nil -%}
53
- {%- assign activation_third_level_index = nil -%}
54
- {%- assign activation_first_level_reversed = nil -%}
55
- {%- assign activation_second_level_reversed = nil -%}
68
+ {%- assign nav_levels = "" | split: "" | push: 1 -%}
56
69
 
57
70
  {%- comment -%}
58
- The generated CSS depends on the position of the current page in each level in
59
- the navigation.
60
- {%- endcomment -%}
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*
61
75
 
62
- {%- assign activation_title = page.grand_parent | default: page.parent | default: page.title -%}
63
- {%- assign activation_first_level = activation_pages
64
- | where_exp: "item", "item.parent == nil" -%}
65
- {%- include sorted_pages.html pages = activation_first_level -%}
66
- {%- for activation_page in sorted_pages -%}
67
- {%- if activation_page.title == activation_title -%}
68
- {%- assign activation_first_level_index = forloop.index -%}
69
- {%- assign activation_first_level_reversed = activation_page.child_nav_order -%}
70
- {%- break -%}
71
- {%- endif -%}
72
- {%- endfor -%}
76
+ PAGES = nav_list (nav_list_item PAGES?)+ nav_list_end
73
77
 
74
- {%- if activation_first_level_index == nil -%}
78
+ EXTERNALS = nav_list nav_list_item+ nav_list_end
75
79
 
76
- {{ activation_no_nav_link }}
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 %}
77
129
 
78
- {%- else -%}
130
+ {%- for nav_split in nav_splits -%}
79
131
 
80
- {%- if page.grand_parent -%}
81
- {%- assign activation_title = page.parent -%}
82
- {%- assign activation_second_level = activation_pages
83
- | where_exp: "item", "item.grand_parent == nil"
84
- | where_exp: "item", "item.parent == page.grand_parent" -%}
85
- {%- elsif page.parent -%}
86
- {%- assign activation_title = page.title -%}
87
- {%- assign activation_second_level = activation_pages
88
- | where_exp: "item", "item.grand_parent == nil"
89
- | where_exp: "item", "item.parent == page.parent" -%}
90
- {%- endif -%}
91
- {%- if page.parent -%}
92
- {%- include sorted_pages.html pages = activation_second_level -%}
93
- {%- for activation_page in sorted_pages -%}
94
- {%- if activation_page.title == activation_title -%}
95
- {%- assign activation_second_level_index = forloop.index -%}
96
- {%- assign activation_second_level_reversed = activation_page.child_nav_order -%}
97
- {%- if activation_first_level_reversed -%}
98
- {%- assign activation_second_level_index = sorted_pages | size | plus: 1 | minus: activation_second_level_index -%}
99
- {%- endif -%}
100
- {%- break -%}
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 -%}
101
160
  {%- endif -%}
102
- {%- endfor -%}
103
- {%- endif -%}
104
161
 
105
- {%- if page.grand_parent -%}
106
- {%- assign activation_third_level = activation_pages
107
- | where_exp: "item", "item.parent == page.parent"
108
- | where_exp: "item", "item.grand_parent == page.grand_parent" -%}
109
- {%- include sorted_pages.html pages = activation_third_level -%}
110
- {%- assign activation_third_level = sorted_pages -%}
111
- {%- for activation_page in sorted_pages -%}
112
- {%- if activation_page.title == page.title -%}
113
- {%- assign activation_third_level_index = forloop.index -%}
114
- {%- if activation_second_level_reversed -%}
115
- {%- assign activation_third_level_index = sorted_pages | size | plus: 1 | minus: activation_third_level_index -%}
116
- {%- endif -%}
117
- {%- 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 -%}
118
173
  {%- endif -%}
119
- {%- endfor -%}
174
+
175
+ {%- endif -%}
176
+
177
+ {%- endfor -%}
178
+
179
+ {%- assign nav_levels = nav_levels | where_exp: "item", "item >= 1" -%}
180
+
120
181
  {%- endif -%}
121
182
 
122
- {%- if 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] -%}
123
195
 
124
196
  {{ activation_no_nav_link }}
125
197
 
@@ -158,34 +230,14 @@
158
230
 
159
231
  {%- else -%}
160
232
 
161
- {%- for activation_collection in site.just_the_docs.collections -%}
162
- {%- if activation_collection[0] == page.collection -%}
163
- {%- assign activation_index = forloop.index -%}
164
- {%- break -%}
165
- {%- endif -%}
166
- {%- endfor -%}
167
-
168
- {%- assign activation_pages_top_size = site.html_pages
169
- | where_exp:"item", "item.title != nil"
170
- | where_exp:"item", "item.parent == nil"
171
- | where_exp:"item", "item.nav_exclude != true"
172
- | size -%}
173
- {%- if activation_pages_top_size > 0 -%}
174
- {%- assign activation_index = activation_index | plus: 1 -%}
175
- {%- endif -%}
176
-
177
- {%- if site.nav_external_links -%}
178
- {%- assign activation_index = activation_index | plus: 1 -%}
179
- {%- endif -%}
180
-
181
233
  {%- capture activation_collection_prefix -%}
182
- .site-nav > ul:nth-of-type({{ activation_index }})
234
+ .site-nav > ul:nth-of-type({{ nav_levels[0] }})
183
235
  {%- if site.just_the_docs.collections[page.collection].nav_fold %} > li > ul
184
236
  {%- endif -%}
185
237
  {%- endcapture -%}
186
238
 
187
239
  {%- capture activation_other_collection_prefix -%}
188
- .site-nav > ul:not(:nth-of-type({{ activation_index }}))
240
+ .site-nav > ul:not(:nth-of-type({{ nav_levels[0] }}))
189
241
  {%- endcapture -%}
190
242
 
191
243
  {%- endif -%}
@@ -197,25 +249,25 @@
197
249
  and children of the current page.
198
250
  {%- endcomment %}
199
251
 
200
- {% if activation_third_level_index -%}
252
+ {% if nav_levels[3] -%}
201
253
 
202
254
  {{ activation_collection_prefix }} > li > a,
203
255
  {{ activation_collection_prefix }} > li > ul > li > a,
204
- {{ activation_collection_prefix }} > li > ul > li > ul > li:not(:nth-child({{ activation_third_level_index }})) > a {
256
+ {{ activation_collection_prefix }} > li > ul > li > ul > li:not(:nth-child({{ nav_levels[3] }})) > a {
205
257
  background-image: none;
206
258
  }
207
259
 
208
- {%- elsif activation_second_level_index -%}
260
+ {%- elsif nav_levels[2] -%}
209
261
 
210
262
  {{ activation_collection_prefix }} > li > a,
211
- {{ activation_collection_prefix }} > li > ul > li:not(:nth-child({{ activation_second_level_index }})) > a,
263
+ {{ activation_collection_prefix }} > li > ul > li:not(:nth-child({{ nav_levels[2] }})) > a,
212
264
  {{ activation_collection_prefix }} > li > ul > li > ul > li > a {
213
265
  background-image: none;
214
266
  }
215
267
 
216
268
  {%- else -%}
217
269
 
218
- {{ activation_collection_prefix }} > li:not(:nth-child({{ activation_first_level_index }})) > a,
270
+ {{ activation_collection_prefix }} > li:not(:nth-child({{ nav_levels[1] }})) > a,
219
271
  {{ activation_collection_prefix }} > li > ul > li > a,
220
272
  {{ activation_collection_prefix }} > li > ul > li > ul > li > a {
221
273
  background-image: none;
@@ -236,9 +288,9 @@
236
288
  The following rule styles the link to the current page.
237
289
  {%- endcomment %}
238
290
 
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 }})
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] }})
242
294
  {%- endif -%}
243
295
  {%- endif %} > a {
244
296
  font-weight: 600;
@@ -259,9 +311,9 @@
259
311
  {%- if site.just_the_docs.collections %}
260
312
  .site-nav > ul.nav-category-list > li > button svg,
261
313
  {% 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
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
265
317
  {%- endif %} {
266
318
  transform: rotate(-90deg);
267
319
  }
@@ -269,13 +321,12 @@
269
321
  {%- if site.just_the_docs.collections %}
270
322
  .site-nav > ul.nav-category-list > li.nav-list-item > ul.nav-list,
271
323
  {% 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
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
275
327
  {%- endif %} {
276
328
  display: block;
277
329
  }
278
330
 
279
331
  {%- endif -%}
280
332
  {%- endif -%}
281
- {%- 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`.
@@ -145,6 +145,18 @@ function searchLoaded(index, docs) {
145
145
  var currentInput;
146
146
  var currentSearchIndex = 0;
147
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
+
148
160
  function showSearch() {
149
161
  document.documentElement.classList.add('search-active');
150
162
  }
@@ -487,11 +499,28 @@ jtd.setTheme = function(theme) {
487
499
  // and not have the slash on GitHub Pages
488
500
 
489
501
  function navLink() {
490
- var href = document.location.pathname;
491
- if (href.endsWith('/') && href != '/') {
492
- 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;
493
507
  }
494
- return document.getElementById('site-nav').querySelector('a[href="' + href + '"], a[href="' + href + '/"]');
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);
514
+ }
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`
495
524
  }
496
525
 
497
526
  // Scroll site-nav to ensure the link to the current page is visible
@@ -499,8 +528,7 @@ function navLink() {
499
528
  function scrollNav() {
500
529
  const targetLink = navLink();
501
530
  if (targetLink) {
502
- const rect = targetLink.getBoundingClientRect();
503
- document.getElementById('site-nav').scrollBy(0, rect.top - 3*rect.height);
531
+ targetLink.scrollIntoView({ block: "center" });
504
532
  targetLink.removeAttribute('href');
505
533
  }
506
534
  }
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.7.0
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-10-25 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