astro-accelerator-utils 0.3.63 → 0.3.65
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.
- package/lib/postFiltering.d.mts +7 -0
- package/lib/postFiltering.mjs +30 -0
- package/lib/v1/navigation.d.mts +6 -0
- package/lib/v1/navigation.mjs +39 -1
- package/package.json +1 -1
package/lib/postFiltering.d.mts
CHANGED
|
@@ -62,5 +62,12 @@ export function hasModDate(p: MarkdownInstance): boolean;
|
|
|
62
62
|
* @returns {boolean}
|
|
63
63
|
*/
|
|
64
64
|
export function isListable(p: MarkdownInstance<Record<string, any>>): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Predicate for whether a page should be used to create tag and category lists.
|
|
67
|
+
* Specifically, this allows future-dated posts to cause taxonomy pages to be created,
|
|
68
|
+
* @param {MarkdownInstance<Record<string, any>>} p
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
*/
|
|
71
|
+
export function forTaxonomy(p: MarkdownInstance<Record<string, any>>): boolean;
|
|
65
72
|
export type PagePredicate = import("../types/PagePredicate").PagePredicate;
|
|
66
73
|
export type MarkdownInstance = import("../types/Astro").MarkdownInstance;
|
package/lib/postFiltering.mjs
CHANGED
|
@@ -147,5 +147,35 @@ export function isListable (p) {
|
|
|
147
147
|
return false;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Predicate for whether a page should be used to create tag and category lists.
|
|
155
|
+
* Specifically, this allows future-dated posts to cause taxonomy pages to be created,
|
|
156
|
+
* @param {MarkdownInstance<Record<string, any>>} p
|
|
157
|
+
* @returns {boolean}
|
|
158
|
+
*/
|
|
159
|
+
export function forTaxonomy (p) {
|
|
160
|
+
if (p.url == null || p.url === '') {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (p.frontmatter == null || p.frontmatter.layout == null) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (p.frontmatter.layout.includes('/Redirect.astro')) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (p.frontmatter.listable != null && p.frontmatter.listable == false) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (p.frontmatter.draft == true) {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
|
|
150
180
|
return true;
|
|
151
181
|
}
|
package/lib/v1/navigation.d.mts
CHANGED
|
@@ -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
|
package/lib/v1/navigation.mjs
CHANGED
|
@@ -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.
|
|
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
|