astro-accelerator-utils 0.3.63 → 0.3.64

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.
@@ -91,6 +91,12 @@ export class Navigation {
91
91
  * @returns {NavPage}
92
92
  */
93
93
  mapNavPage(page: MarkdownInstance): NavPage;
94
+ /**
95
+ * Converts a MarkdownInstance into a NavPage
96
+ * @param {MarkdownInstance} page
97
+ * @returns {NavPage}
98
+ */
99
+ mapCrumbNavPage(page: MarkdownInstance): NavPage;
94
100
  /**
95
101
  * Checks whether the item is a NavPage
96
102
  * @param {NavPage | 'auto' | 'tags' | 'toptags' | 'categories'} item
@@ -56,7 +56,7 @@ export class Navigation {
56
56
  const match = this.popMatchingPage(allPages, path);
57
57
 
58
58
  if (match) {
59
- navPages.push(this.mapNavPage(match));
59
+ navPages.push(this.mapCrumbNavPage(match));
60
60
  }
61
61
  });
62
62
 
@@ -406,6 +406,44 @@ export class Navigation {
406
406
  return entry;
407
407
  }
408
408
 
409
+ /**
410
+ * Converts a MarkdownInstance into a NavPage
411
+ * @param {MarkdownInstance} page
412
+ * @returns {NavPage}
413
+ */
414
+ mapCrumbNavPage(page) {
415
+ let url = page.url == null || (page.url ?? '').length == 0
416
+ ? '/'
417
+ : page.url;
418
+
419
+ // Send visitors straight to the first page
420
+ if (page.frontmatter.paged) {
421
+ url += '/1/';
422
+ }
423
+
424
+ url = this.urlFormatter.addSlashToAddress(url);
425
+
426
+ if (page.frontmatter.layout == 'src/layouts/Redirect.astro') {
427
+ // Skips past the redirect
428
+ url = page.frontmatter.redirect;
429
+ }
430
+
431
+ /** @type {NavPage} */
432
+ const entry = {
433
+ fullTitle: page.frontmatter.title,
434
+ section: page.frontmatter.navSection ?? page.frontmatter.navTitle ?? page.frontmatter.title,
435
+ title: page.frontmatter.crumbTitle ?? page.frontmatter.navTitle ?? page.frontmatter.title,
436
+ url: url,
437
+ order: page.frontmatter.navOrder ?? Number.MAX_SAFE_INTEGER,
438
+ children: [],
439
+ // These are later set to the correct value, but not now as we want to cache
440
+ isOpen: false,
441
+ ariaCurrent: false
442
+ }
443
+
444
+ return entry;
445
+ }
446
+
409
447
 
410
448
  /**
411
449
  * Checks whether the item is a NavPage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-accelerator-utils",
3
- "version": "0.3.63",
3
+ "version": "0.3.64",
4
4
  "description": "Astro utilities for Astro Accelerator.",
5
5
  "main": "index.mjs",
6
6
  "type": "module",