jekyll-theme-primerpages 2.3.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6743a19e99abe8b76a3d058ea9c822f2fc69be8f9163bbd6dc2d6a68c241677
4
- data.tar.gz: c5058366ba5278bc15bb9f69739a6ff15d9fcf55e65f269751d5ebd7a308e619
3
+ metadata.gz: 6847b0a7f69ea4c02a441b86cd79b48b5f6169625c8ba137714169c0320f5490
4
+ data.tar.gz: 798afe00f735f9f7008df850938f603470f4c645e3d16e549ed3f1a559435d29
5
5
  SHA512:
6
- metadata.gz: 413b3c779e1855820c9e0eeb6b1a5be7b73b7e8a7c8f8bfc08c072a3d5fae4e942257af06077c230b4542b8671f9ed7cda8ff504532e8e797450d916769246a6
7
- data.tar.gz: 993b246fb4635465d565e4e3c4ece428d1820f3bda7e5f711d6229bf48692922514ab82e28a4a21c2c103ddc9e4033aa970d79c2a31f74b86973fce533c41bb0
6
+ metadata.gz: 9f9e8771172dc3d07ac72e54dbd3164d699ac940bcb52c3d69c0e1798c21d13d40548d33299bb7391684640a35690345d17525f5ee47b147dae69a33029a639a
7
+ data.tar.gz: 84e2ed4697bb3d730bbbb83181b42240e32f6074a26a55a773c8922a4a4ce42afc3009d3cfe4415aaf918097e1bfcd8f845e031bb6533cf61e61a38368f4328d
data/README.md CHANGED
@@ -50,6 +50,36 @@ bundle exec jekyll serve
50
50
 
51
51
  Then open `http://localhost:4000`.
52
52
 
53
+ ## Header Search
54
+
55
+ PrimerPages can show an optional Pagefind search button in the site header. Click it or press `/`
56
+ to open the search dialog.
57
+
58
+ Search and color mode are grouped together. On mobile and in the collapsed
59
+ sidebar, search uses an icon button. Use arrow keys and Enter to open a result,
60
+ or Escape to dismiss the dialog.
61
+
62
+ ```yaml
63
+ search:
64
+ enabled: true
65
+ max_results: 8
66
+ ```
67
+
68
+ Set `search.enabled` to `false` or remove the block to hide search. Pagefind is
69
+ generated after Jekyll builds the static site:
70
+
71
+ ```sh
72
+ bundle exec jekyll build
73
+ npx -y pagefind --site _site
74
+ ```
75
+
76
+ The theme loads Pagefind from `<baseurl>/pagefind/pagefind.js` and renders results in a
77
+ search dialog; it does not add a standalone search page or require a Jekyll
78
+ plugin.
79
+
80
+ See [Search with Pagefind](https://www.primerpages.com/docs/pagefind.html) for
81
+ installation options, previews, deployment setup, and troubleshooting.
82
+
53
83
  ## Documentation
54
84
 
55
85
  Full documentation is available at [primerpages.com](https://www.primerpages.com).
data/_config.yml CHANGED
@@ -36,6 +36,12 @@ repo_info: true # Show the information for the source of this project
36
36
  user_metadata: true # Show the metadata associated with the user
37
37
  profile_link: true # Show a link to the github profile for the user
38
38
 
39
+ ####################
40
+ # Header search
41
+ # search:
42
+ # enabled: true
43
+ # max_results: 8
44
+
39
45
  ####################
40
46
  # Versioned docs settings
41
47
  # versions:
@@ -5,13 +5,13 @@
5
5
  {%- assign header_icon = site.header_icon | default: "mark-github" %}
6
6
 
7
7
  <header class="AppHeader position-sticky top-0 z-2 border-bottom topbar">
8
- <div class="AppHeader-item d-flex flex-justify-between p-2 flex-items-center mb-2">
8
+ <div class="d-flex flex-justify-between p-2 flex-items-center mb-2">
9
9
  {%- if site.nav %}
10
10
  <div class="d-flex d-sm-none">
11
11
  {% include nav-overlay.html %}
12
12
  </div>
13
13
  {%- endif %}
14
- <div tabindex="-1" class="d-flex flex-1 ml-3" id="github-logo">
14
+ <div tabindex="-1" class="AppHeader-item d-flex flex-1 ml-3" id="github-logo">
15
15
  <a href="{{ site.baseurl }}/" class="AppHeader-link d-flex flex-items-center no-underline mr-3 h1">
16
16
  {%- unless header_icon == "none" %}
17
17
  {%- if header_icon == "favicon" %}
@@ -26,22 +26,22 @@
26
26
  {% include version-selector.html %}
27
27
  </span>
28
28
  </div>
29
- <div class="AppHeader-item d-flex flex-items-center">
30
- {% include toggle.html %}
31
- {%- if site.repo_info and site.repository %}
32
- <div class="AppHeader-item hide-sm">
33
- {% include mini-repo-info-card.html class="AppHeader-link no-underline" %}
34
- </div>
35
- {% endif %}
36
- {%- if site.profile_link and user.login %}
37
- <div class="AppHeader-item mr-0">
38
- <a href="https://github.com/{{ user.login }}" class="AppHeader-link d-flex flex-items-center">
39
- <img class="avatar img-cover circle" height="32" width="32" alt="{{ name }}"
40
- src="{{ user_img | relative_url }}">
41
- </a>
42
- </div>
43
- {%- endif %}
29
+ <div class="AppHeader-item">
30
+ {% include header-tools.html %}
44
31
  </div>
32
+ {%- if site.repo_info and site.repository %}
33
+ <div class="AppHeader-item hide-sm">
34
+ {% include mini-repo-info-card.html class="AppHeader-link no-underline" %}
35
+ </div>
36
+ {% endif %}
37
+ {%- if site.profile_link and user.login %}
38
+ <div class="AppHeader-item mr-0">
39
+ <a href="https://github.com/{{ user.login }}" class="AppHeader-link d-flex flex-items-center">
40
+ <img class="avatar img-cover circle" height="32" width="32" alt="{{ name }}"
41
+ src="{{ user_img | relative_url }}">
42
+ </a>
43
+ </div>
44
+ {%- endif %}
45
45
  </div>
46
46
  <div class="d-flex flex-items-center">
47
47
  {%- if site.nav %}
@@ -24,9 +24,7 @@
24
24
  <div class="d-flex flex-justify-center d-lg-none">
25
25
  {%- include nav-overlay.html %}
26
26
  </div>
27
- <div class="d-flex flex-justify-center">
28
- {% include toggle.html %}
29
- </div>
27
+ {% include header-tools.html %}
30
28
  <div class="Toolbar-collapse d-flex flex-justify-center d-none d-lg-block">
31
29
  <button id="toolbar-btn" class="btn-octicon mr-2"><span class="octicon octicon-chevron-left-16"></span></button>
32
30
  </div>
@@ -1,22 +1,18 @@
1
1
  <div class="Profile text-center mt-3">
2
2
  {%- include masthead.html %}
3
- {%- if site.repo_info and site.repository %}
4
- <div class="py-2">
5
- {% include mini-repo-info-card.html class="AppHeader-link no-underline" %}
6
- </div>
7
- {%- endif %}
8
3
  {%- if site.social_media %}
9
- <div class="py-2 px-2">
10
- {%- include social.html %}
11
- </div>
4
+ <div class="py-2 px-2">
5
+ {%- include social.html %}
6
+ </div>
12
7
  {%- endif %}
13
8
  </div>
14
- {%- if site.nav %}
15
9
  <div class="Header z-2 position-sticky top-0 topbar">
16
10
  <div class="container-xl d-flex flex-row flex-1">
11
+ {%- if site.nav %}
17
12
  <div class="d-flex flex-1 hide-sm">
18
13
  {% include nav.html %}
19
14
  </div>
15
+ {%- endif %}
20
16
  <div class="d-flex flex-sm-grow-0 flex-justify-start">
21
17
  <div class="d-flex d-sm-none">
22
18
  {% include nav-overlay.html%}
@@ -25,9 +21,15 @@
25
21
  <div class="m-2">
26
22
  {% include version-selector.html %}
27
23
  </div>
28
- {% include toggle.html %}
24
+ <div class="Header-item">
25
+ {% include header-tools.html %}
26
+ </div>
27
+ {%- if site.repo_info and site.repository %}
28
+ <div class="Header-item hide-sm">
29
+ {% include mini-repo-info-card.html class="Header-link" %}
30
+ </div>
31
+ {%- endif %}
29
32
  </div>
30
33
  </div>
31
- </div>
34
+ </div>
32
35
  </div>
33
- {%- endif %}
@@ -0,0 +1,4 @@
1
+ <div class="primerpages-header-tools" role="group" aria-label="Site tools">
2
+ {% include search.html %}
3
+ {% include toggle.html %}
4
+ </div>
@@ -18,13 +18,16 @@
18
18
  <a href="{{ site.baseurl }}/" class="Header-link h1 f4 d-flex flex-items-center">
19
19
  {%- unless header_icon == "none" %}
20
20
  {%- if header_icon == "favicon" %}
21
+ <!-- Use the favicon as the header icon -->
21
22
  <img src="{{ favicon | relative_url }}" alt="" width="24" height="24" class="mr-2" />
22
23
  {%- else %}
24
+ <!-- Use the specified Octicon as the header icon -->
23
25
  <span class="octicon octicon-{{ header_icon }}-24"></span>
24
26
  {%- endif %}
25
27
  {%- endunless %}
26
28
  </a>
27
29
  </div>
30
+
28
31
  <div class="Header-item Header-link Header-item--full">
29
32
  <a class="Header-link h3" href="{{ site.baseurl }}/">{{ name }}</a>
30
33
  <div class="d-inline-block ml-4">
@@ -32,7 +35,7 @@
32
35
  </div>
33
36
  </div>
34
37
  <div class="Header-item">
35
- {% include toggle.html %}
38
+ {% include header-tools.html %}
36
39
  </div>
37
40
  {%- if site.repo_info and site.repository %}
38
41
  <div class="Header-item hide-sm">
@@ -29,7 +29,7 @@
29
29
  </span>
30
30
  {%- endif %}
31
31
  {%- if repository.stargazers_count %}
32
- <a href="{{ repository.html_url }}/stargazers" class="mr-1 Link--muted">
32
+ <a href="{{ repository.html_url }}/stargazers" class="mr-1 Link--muted" data-proofer-ignore>
33
33
  <span class="octicon octicon-star-16 v-align-middle"></span> {{ repository.stargazers_count }}
34
34
  </a>
35
35
  {%- endif %}
@@ -0,0 +1,27 @@
1
+ {%- if site.search.enabled -%}
2
+ <dialog id="primerpages-search-dialog" class="primerpages-search-dialog color-bg-overlay box-shadow-large"
3
+ aria-label="Search this site" data-pagefind-search
4
+ data-pagefind-max-results="{{ site.search.max_results | default: 8 }}"
5
+ data-pagefind-src="{{ '/pagefind/pagefind.js' | relative_url }}">
6
+ <div class="primerpages-search-dialog__header">
7
+ <label class="sr-only" for="primerpages-search-input">Search this site</label>
8
+ <div class="primerpages-search__control position-relative flex-1">
9
+ <span class="primerpages-search__icon octicon octicon-search-16" aria-hidden="true"></span>
10
+ <input id="primerpages-search-input" class="primerpages-search__input form-control"
11
+ type="search" role="combobox" autocomplete="off" spellcheck="false" placeholder="Search this site…"
12
+ aria-autocomplete="list" aria-haspopup="listbox" aria-expanded="false"
13
+ aria-controls="primerpages-search-results" autofocus data-pagefind-input>
14
+ </div>
15
+ <button class="btn-octicon" type="button" aria-label="Close search" data-pagefind-close>
16
+ <span class="octicon octicon-x-16" aria-hidden="true"></span>
17
+ </button>
18
+ </div>
19
+ <div class="primerpages-search__dropdown" hidden data-pagefind-dropdown>
20
+ <div class="primerpages-search-dialog__section-label color-fg-muted" aria-hidden="true">Search this site</div>
21
+ <div id="primerpages-search-results" role="listbox" aria-label="Search results" data-pagefind-results></div>
22
+ <div class="primerpages-search__empty color-fg-muted" hidden data-pagefind-empty></div>
23
+ </div>
24
+ <div class="sr-only" role="status" aria-live="polite" aria-atomic="true" data-pagefind-status></div>
25
+ </dialog>
26
+ <script src="{{ '/assets/js/search.js' | relative_url }}" defer></script>
27
+ {%- endif -%}
@@ -0,0 +1,16 @@
1
+ {%- if site.search.enabled -%}
2
+ <div class="primerpages-search">
3
+ <button class="primerpages-search__launcher form-control input-sm" type="button"
4
+ aria-label="Search this site" aria-haspopup="dialog" aria-controls="primerpages-search-dialog"
5
+ aria-keyshortcuts="/" data-pagefind-launcher>
6
+ <span class="octicon octicon-search-16" aria-hidden="true"></span>
7
+ <span class="primerpages-search__launcher-label">Search…</span>
8
+ <kbd class="primerpages-search__shortcut" aria-hidden="true">/</kbd>
9
+ </button>
10
+ <button class="primerpages-search__icon-launcher btn-octicon mr-2" type="button"
11
+ aria-label="Search this site" aria-haspopup="dialog" aria-controls="primerpages-search-dialog"
12
+ aria-keyshortcuts="/" data-pagefind-launcher>
13
+ <span class="octicon octicon-search-24" aria-hidden="true"></span>
14
+ </button>
15
+ </div>
16
+ {%- endif -%}
@@ -28,6 +28,7 @@
28
28
  </div>
29
29
 
30
30
  {%- include footer.html %}
31
+ {%- include search-dialog.html %}
31
32
  </body>
32
33
 
33
34
  </html>
data/_layouts/docs.html CHANGED
@@ -38,12 +38,11 @@ Set display info
38
38
  Set edit url
39
39
  ===================================
40
40
  {% endcomment %}
41
- {%- assign github_edit_url = nil %}
41
+ {%- assign default_url = nil %}
42
42
  {%- if site.repository %}
43
- {%- assign github_edit_url = "https://www.github.com/" | append: site.repository | append: "/edit/main" %}
43
+ {%- assign default_url = "https://www.github.com/" | append: site.repository | append: "/edit/main" %}
44
44
  {%- endif %}
45
- {%- assign edit_url = page.edit_url | default: site.edit_url | default: github_edit_url %}
46
- {%- assign show_edit_url = page.show_edit_url | default: site.show_edit_url | default: true %}
45
+ {%- assign edit_url = page.edit_url | default: site.edit_url | default: default_url %}
47
46
  {%- assign awesome_nav_enabled = false %}
48
47
  {%- if site.awesome_nav and site.awesome_nav.enabled and page.awesome_nav %}
49
48
  {%- assign awesome_nav_enabled = true %}
@@ -167,8 +166,8 @@ Set edit url
167
166
  </div>
168
167
 
169
168
  <!-- Edit link -->
170
- {% if show_edit_url and edit_url %}
171
- <div class="doc-footer border-top my-8 py-5">
169
+ {% if edit_url %}
170
+ <div class="doc-edit-link border-top my-8 py-5">
172
171
  <a href="{{ edit_url }}/{{ page.path }}">
173
172
  <span class="octicon octicon-pencil-16"></span>
174
173
  Edit this page</a>
data/_sass/_main.scss CHANGED
@@ -167,6 +167,14 @@ body::before {
167
167
  color: var(--fgColor-default, var(--color-fg-default));
168
168
  }
169
169
 
170
+ .AppHeader-item {
171
+ display: flex;
172
+ margin-right: var(--base-size-16);
173
+ align-self: stretch;
174
+ align-items: center;
175
+ flex-wrap: nowrap;
176
+ }
177
+
170
178
  .version-selector__trigger {
171
179
  color: var(--fgColor-default, var(--color-fg-default));
172
180
  cursor: pointer;
@@ -215,6 +223,178 @@ body::before {
215
223
  color: var(--underlineNav-borderColor-active, var(--color-primer-border-active));
216
224
  }
217
225
 
226
+ .primerpages-search {
227
+ width: 12rem;
228
+ z-index: 20;
229
+ }
230
+
231
+ .primerpages-header-tools {
232
+ display: flex;
233
+ align-items: center;
234
+ flex-shrink: 0;
235
+ gap: 0.5rem;
236
+ }
237
+
238
+ .primerpages-header-tools .btn-octicon {
239
+ margin-right: 0 !important;
240
+ }
241
+
242
+ .Toolbar.flex-lg-column .primerpages-header-tools {
243
+ flex-direction: column;
244
+ }
245
+
246
+ .primerpages-search__control {
247
+ display: flex;
248
+ align-items: center;
249
+ }
250
+
251
+ .primerpages-search__icon {
252
+ position: absolute;
253
+ left: 0.5rem;
254
+ color: var(--fgColor-muted, var(--color-fg-muted));
255
+ pointer-events: none;
256
+ z-index: 1;
257
+ }
258
+
259
+ .primerpages-search__input {
260
+ width: 100%;
261
+ min-width: 0;
262
+ padding-left: 1.75rem;
263
+ color: var(--fgColor-default, var(--color-fg-default));
264
+ background-color: var(--bgColor-default, var(--color-canvas-default));
265
+ }
266
+
267
+ .primerpages-search__launcher {
268
+ display: flex;
269
+ align-items: center;
270
+ gap: 0.5rem;
271
+ width: 100%;
272
+ text-align: left;
273
+ color: var(--fgColor-muted, var(--color-fg-muted));
274
+ cursor: pointer;
275
+ }
276
+
277
+ .primerpages-search__shortcut { margin-left: auto; }
278
+
279
+ .primerpages-search__icon-launcher { display: none; }
280
+
281
+ .primerpages-search-dialog {
282
+ position: fixed;
283
+ inset: 0;
284
+ width: min(56rem, calc(100vw - 2rem));
285
+ max-height: 80vh;
286
+ margin: 10vh auto auto;
287
+ padding: 0;
288
+ overflow: hidden;
289
+ border: 1px solid var(--borderColor-muted, var(--color-border-muted));
290
+ border-radius: 1rem;
291
+ color: var(--fgColor-default, var(--color-fg-default));
292
+ }
293
+
294
+ .primerpages-search-dialog::backdrop { background: rgba(27, 31, 36, 0.3); }
295
+
296
+ .primerpages-search-dialog__header {
297
+ display: flex;
298
+ align-items: center;
299
+ gap: 0.75rem;
300
+ margin: 0 1rem;
301
+ padding: 0.75rem 0;
302
+ border-bottom: 1px dashed var(--borderColor-muted, var(--color-border-muted));
303
+ }
304
+
305
+ .primerpages-search-dialog .primerpages-search__input {
306
+ height: 3rem;
307
+ padding-left: 2.25rem;
308
+ border: 0;
309
+ border-radius: 0.375rem;
310
+ background: transparent;
311
+ box-shadow: none;
312
+ font-size: 1.125rem;
313
+ }
314
+
315
+ .primerpages-search-dialog .primerpages-search__input:focus-visible {
316
+ outline: 2px solid var(--focus-outlineColor, var(--color-accent-fg));
317
+ outline-offset: -2px;
318
+ }
319
+
320
+ .primerpages-search-dialog__section-label {
321
+ padding: 1.25rem 0 0.75rem;
322
+ font-size: 0.875rem;
323
+ font-weight: 600;
324
+ }
325
+
326
+ .primerpages-search__dropdown {
327
+ max-height: min(65vh, calc(80dvh - 5rem));
328
+ padding: 0 1rem 1rem;
329
+ overflow-y: auto;
330
+ }
331
+
332
+ .Toolbar.flex-lg-column .primerpages-search { width: auto; }
333
+ .Toolbar.flex-lg-column .primerpages-search__launcher { display: none; }
334
+ .Toolbar.flex-lg-column .primerpages-search__icon-launcher { display: inline-block; }
335
+
336
+ .primerpages-search__result {
337
+ position: relative;
338
+ display: block;
339
+ padding: 1.125rem 2.25rem 1.125rem 0.5rem;
340
+ color: var(--fgColor-default, var(--color-fg-default));
341
+ border-bottom: 1px dashed var(--borderColor-muted, var(--color-border-muted));
342
+ }
343
+
344
+ .primerpages-search__result:last-child {
345
+ border-bottom: 0;
346
+ }
347
+
348
+ .primerpages-search__result:hover,
349
+ .primerpages-search__result:focus,
350
+ .primerpages-search__result[aria-selected="true"] {
351
+ color: var(--fgColor-default, var(--color-fg-default));
352
+ background-color: var(--control-transparent-bgColor-hover, var(--color-action-list-item-default-hover-bg));
353
+ outline: none;
354
+ }
355
+
356
+ .primerpages-search__title,
357
+ .primerpages-search__url,
358
+ .primerpages-search__excerpt {
359
+ display: block;
360
+ overflow-wrap: anywhere;
361
+ }
362
+
363
+ .primerpages-search__title {
364
+ font-size: 1rem;
365
+ font-weight: 500;
366
+ }
367
+
368
+ .primerpages-search__url {
369
+ display: none;
370
+ }
371
+
372
+ .primerpages-search__result-arrow {
373
+ position: absolute;
374
+ top: 1.25rem;
375
+ right: 0.5rem;
376
+ color: var(--fgColor-muted, var(--color-fg-muted));
377
+ }
378
+
379
+ .primerpages-search__excerpt {
380
+ margin-top: 0.375rem;
381
+ font-size: var(--text-body-size-small, 0.75rem);
382
+ line-height: 1.4;
383
+ display: -webkit-box;
384
+ -webkit-box-orient: vertical;
385
+ -webkit-line-clamp: 2;
386
+ overflow: hidden;
387
+ }
388
+
389
+ .primerpages-search__empty {
390
+ padding: 0.75rem;
391
+ }
392
+
393
+ .Header .primerpages-search__input,
394
+ .Header .primerpages-search__dropdown {
395
+ color: var(--fgColor-default, var(--color-fg-default));
396
+ }
397
+
218
398
  .awesome-nav-chevron {
219
399
  transition: transform 0.2s ease;
220
400
  }
@@ -260,6 +440,11 @@ summary::-webkit-details-marker {
260
440
  display: none !important;
261
441
  }
262
442
 
443
+ .primerpages-search,
444
+ .primerpages-search-dialog {
445
+ display: none !important;
446
+ }
447
+
263
448
  .Related {
264
449
  display: none !important;
265
450
  }
@@ -272,3 +457,9 @@ summary::-webkit-details-marker {
272
457
  font-size: 12px;
273
458
  }
274
459
  }
460
+
461
+ @media (max-width: 543px) {
462
+ .primerpages-search { width: auto; }
463
+ .primerpages-search__launcher { display: none; }
464
+ .primerpages-search__icon-launcher { display: inline-block; }
465
+ }
@@ -0,0 +1,261 @@
1
+ (function () {
2
+ if (window.PrimerPagesSearchLoaded) {
3
+ return;
4
+ }
5
+
6
+ window.PrimerPagesSearchLoaded = true;
7
+
8
+ const roots = document.querySelectorAll("[data-pagefind-search]");
9
+
10
+ if (!roots.length) {
11
+ return;
12
+ }
13
+
14
+ let pagefindPromise;
15
+ const cancelSearches = new WeakMap();
16
+
17
+ function getPagefindBasePath(src) {
18
+ return new URL(".", new URL(src, window.location.href)).toString();
19
+ }
20
+
21
+ function loadPagefind(src) {
22
+ if (window.pagefind) {
23
+ return Promise.resolve(window.pagefind);
24
+ }
25
+
26
+ if (!pagefindPromise) {
27
+ pagefindPromise = import(src).then(async (pagefindModule) => {
28
+ const pagefind = pagefindModule.createInstance
29
+ ? pagefindModule.createInstance({
30
+ basePath: getPagefindBasePath(src),
31
+ noWorker: true,
32
+ })
33
+ : pagefindModule;
34
+
35
+ if (pagefind.init) {
36
+ await pagefind.init();
37
+ }
38
+
39
+ return pagefind;
40
+ });
41
+ }
42
+
43
+ return pagefindPromise;
44
+ }
45
+
46
+ function debounce(fn, wait) {
47
+ let timeout;
48
+
49
+ function debounced(...args) {
50
+ window.clearTimeout(timeout);
51
+ timeout = window.setTimeout(() => fn.apply(this, args), wait);
52
+ }
53
+
54
+ debounced.cancel = () => window.clearTimeout(timeout);
55
+ return debounced;
56
+ }
57
+
58
+ function stripHtml(html) {
59
+ const template = document.createElement("template");
60
+ template.innerHTML = html || "";
61
+ return template.content.textContent || template.innerText || "";
62
+ }
63
+
64
+ function escapeHtml(value) {
65
+ return String(value || "")
66
+ .replace(/&/g, "&amp;")
67
+ .replace(/</g, "&lt;")
68
+ .replace(/>/g, "&gt;")
69
+ .replace(/"/g, "&quot;")
70
+ .replace(/'/g, "&#39;");
71
+ }
72
+
73
+ function closeSearch(root) {
74
+ cancelSearches.get(root)();
75
+ const input = root.querySelector("[data-pagefind-input]");
76
+ const results = root.querySelector("[data-pagefind-results]");
77
+
78
+ root.querySelector("[data-pagefind-dropdown]").hidden = true;
79
+ results.innerHTML = "";
80
+ root.querySelector("[data-pagefind-empty]").hidden = true;
81
+ root.querySelector("[data-pagefind-status]").textContent = "";
82
+ input.setAttribute("aria-expanded", "false");
83
+ input.removeAttribute("aria-activedescendant");
84
+ }
85
+
86
+ function openSearch(root) {
87
+ const input = root.querySelector("[data-pagefind-input]");
88
+ root.querySelector("[data-pagefind-dropdown]").hidden = false;
89
+ input.setAttribute("aria-expanded", "true");
90
+ }
91
+
92
+ function renderEmpty(root, message) {
93
+ root.querySelector("[data-pagefind-results]").innerHTML = "";
94
+ const empty = root.querySelector("[data-pagefind-empty]");
95
+ empty.textContent = message;
96
+ empty.hidden = false;
97
+ root.querySelector("[data-pagefind-status]").textContent = message;
98
+ openSearch(root);
99
+ }
100
+
101
+ function renderResults(root, items) {
102
+ const results = root.querySelector("[data-pagefind-results]");
103
+
104
+ if (!items.length) {
105
+ renderEmpty(root, "No results found");
106
+ return;
107
+ }
108
+
109
+ results.innerHTML = items.map((item, index) => {
110
+ const title = item.meta && item.meta.title ? item.meta.title : item.url;
111
+ const excerpt = stripHtml(item.excerpt);
112
+ const url = escapeHtml(item.url);
113
+
114
+ return `
115
+ <a id="${escapeHtml(results.id)}-${index}" class="primerpages-search__result no-underline" href="${url}" role="option" tabindex="-1" data-pagefind-result aria-selected="false">
116
+ <span class="primerpages-search__title">${escapeHtml(title)}</span>
117
+ <span class="primerpages-search__url color-fg-muted">${url}</span>
118
+ ${excerpt ? `<span class="primerpages-search__excerpt color-fg-muted">${escapeHtml(excerpt)}</span>` : ""}
119
+ <span class="primerpages-search__result-arrow octicon octicon-arrow-up-right-16" aria-hidden="true"></span>
120
+ </a>
121
+ `;
122
+ }).join("");
123
+
124
+ root.querySelector("[data-pagefind-empty]").hidden = true;
125
+ root.querySelector("[data-pagefind-status]").textContent = `${items.length} results available. Use the up and down arrow keys to navigate.`;
126
+ openSearch(root);
127
+ }
128
+
129
+ function selectResult(root, nextIndex) {
130
+ const results = Array.from(root.querySelectorAll("[data-pagefind-result]"));
131
+
132
+ if (!results.length) {
133
+ return;
134
+ }
135
+
136
+ const selectedIndex = Math.max(0, Math.min(nextIndex, results.length - 1));
137
+
138
+ results.forEach((item) => item.setAttribute("aria-selected", "false"));
139
+ const selected = results[selectedIndex];
140
+ selected.setAttribute("aria-selected", "true");
141
+ root.querySelector("[data-pagefind-input]").setAttribute("aria-activedescendant", selected.id);
142
+ selected.scrollIntoView({ block: "nearest" });
143
+ }
144
+
145
+ roots.forEach((root) => {
146
+ const input = root.querySelector("[data-pagefind-input]");
147
+ const src = root.getAttribute("data-pagefind-src");
148
+ const maxResults = parseInt(root.getAttribute("data-pagefind-max-results"), 10) || 8;
149
+ let searchToken = 0;
150
+ let returnFocus;
151
+
152
+ const runSearch = debounce(async () => {
153
+ const query = input.value.trim();
154
+ const token = ++searchToken;
155
+
156
+ if (query.length < 2) {
157
+ closeSearch(root);
158
+ return;
159
+ }
160
+
161
+ try {
162
+ const pagefind = await loadPagefind(src);
163
+ const search = await pagefind.search(query);
164
+ const resultData = await Promise.all(
165
+ search.results.slice(0, maxResults).map((result) => result.data())
166
+ );
167
+
168
+ if (token === searchToken) {
169
+ renderResults(root, resultData);
170
+ }
171
+ } catch (error) {
172
+ if (token === searchToken) {
173
+ renderEmpty(root, "Search is unavailable");
174
+ }
175
+ }
176
+ }, 200);
177
+
178
+ // Dismissal also cancels queued searches and invalidates in-flight responses.
179
+ cancelSearches.set(root, () => {
180
+ runSearch.cancel();
181
+ searchToken++;
182
+ });
183
+
184
+ input.addEventListener("input", () => {
185
+ closeSearch(root);
186
+ runSearch();
187
+ });
188
+ input.addEventListener("keydown", (event) => {
189
+ if (event.isComposing) return;
190
+
191
+ if (event.key === "Escape") {
192
+ event.preventDefault();
193
+ event.stopPropagation();
194
+ root.close();
195
+ return;
196
+ }
197
+ if (event.key === "Tab") {
198
+ closeSearch(root);
199
+ return;
200
+ }
201
+
202
+ const results = Array.from(root.querySelectorAll("[data-pagefind-result]"));
203
+ const currentIndex = results.findIndex((item) => item.getAttribute("aria-selected") === "true");
204
+ if (event.key === "Enter" && currentIndex !== -1) {
205
+ event.preventDefault();
206
+ results[currentIndex].click();
207
+ root.close();
208
+ }
209
+ if ((event.key === "ArrowDown" || event.key === "ArrowUp") && results.length) {
210
+ event.preventDefault();
211
+ event.stopPropagation();
212
+ const nextIndex = currentIndex === -1
213
+ ? (event.key === "ArrowDown" ? 0 : results.length - 1)
214
+ : currentIndex + (event.key === "ArrowDown" ? 1 : -1);
215
+ selectResult(root, nextIndex);
216
+ }
217
+ });
218
+
219
+ function showDialog(opener = document.activeElement) {
220
+ if (root.open) return;
221
+ returnFocus = opener;
222
+ root.showModal();
223
+ input.focus();
224
+ input.select();
225
+ if (input.value.trim().length >= 2) runSearch();
226
+ }
227
+
228
+ document.querySelectorAll("[data-pagefind-launcher]").forEach((launcher) => {
229
+ launcher.addEventListener("click", () => showDialog(launcher));
230
+ });
231
+ root.querySelector("[data-pagefind-close]").addEventListener("click", () => root.close());
232
+ root.addEventListener("cancel", (event) => {
233
+ event.preventDefault();
234
+ root.close();
235
+ });
236
+ root.addEventListener("close", () => {
237
+ closeSearch(root);
238
+ if (returnFocus && returnFocus.isConnected) returnFocus.focus();
239
+ });
240
+ root.addEventListener("click", (event) => {
241
+ if (event.target === root) {
242
+ const bounds = root.getBoundingClientRect();
243
+ if (event.clientX < bounds.left || event.clientX > bounds.right ||
244
+ event.clientY < bounds.top || event.clientY > bounds.bottom) root.close();
245
+ }
246
+ });
247
+ document.addEventListener("keydown", (event) => {
248
+ if (event.key !== "/" || event.defaultPrevented || event.isComposing ||
249
+ event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
250
+ const target = event.target;
251
+ if (target.isContentEditable || target.closest("input, textarea, select, [role='textbox']")) return;
252
+ event.preventDefault();
253
+ showDialog();
254
+ });
255
+
256
+ // Mouse selection should not move DOM focus out of the combobox.
257
+ root.addEventListener("mousedown", (event) => {
258
+ if (event.target.closest("[data-pagefind-result]")) event.preventDefault();
259
+ });
260
+ });
261
+ })();
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-primerpages
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allison Thackston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-06 00:00:00.000000000 Z
11
+ date: 2026-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -98,6 +98,7 @@ files:
98
98
  - _includes/header-appbar.html
99
99
  - _includes/header-sidebar.html
100
100
  - _includes/header-stacked.html
101
+ - _includes/header-tools.html
101
102
  - _includes/header-topbar.html
102
103
  - _includes/link-card.html
103
104
  - _includes/links.html
@@ -120,6 +121,8 @@ files:
120
121
  - _includes/repo-card.html
121
122
  - _includes/repositories.html
122
123
  - _includes/resolve-versioning.html
124
+ - _includes/search-dialog.html
125
+ - _includes/search.html
123
126
  - _includes/social.html
124
127
  - _includes/toggle.html
125
128
  - _includes/user-metadata.html
@@ -155,6 +158,7 @@ files:
155
158
  - assets/img/user-image.jpg
156
159
  - assets/js/anchor-links.js
157
160
  - assets/js/mermaid.js
161
+ - assets/js/search.js
158
162
  - assets/js/theme-toggle.js
159
163
  - assets/js/topbar.js
160
164
  - assets/js/versioning.js