astro-accelerator-utils 0.3.90 → 0.3.92
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/index.d.mts +121 -3
- package/index.mjs +251 -8
- package/lib/v1/authors.mjs +1 -1
- package/lib/v1/navigation.mjs +1 -1
- package/lib/v1/taxonomy.mjs +1 -1
- package/package.json +2 -2
- package/lib/postFiltering.d.mts +0 -73
- package/lib/postFiltering.mjs +0 -181
- package/lib/postOrdering.d.mts +0 -32
- package/lib/postOrdering.mjs +0 -51
package/index.d.mts
CHANGED
|
@@ -1,4 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("./types/PagePredicate").PagePredicate } PagePredicate
|
|
3
|
+
* @typedef { import("./types/Astro").MarkdownInstance} MarkdownInstance
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Predicate for whether a page should appear in the sitemap
|
|
7
|
+
* @param {MarkdownInstance} p
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function showInSitemap(p: MarkdownInstance): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Predicate for whether a page should appear in the site search
|
|
13
|
+
* @param {MarkdownInstance} p
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
export function showInSearch(p: MarkdownInstance): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Predicate for whether a page should appear in the navigation menu
|
|
19
|
+
* @param {MarkdownInstance} p
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
export function showInMenu(p: MarkdownInstance): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Predicate for whether a page is an author page
|
|
25
|
+
* @param {MarkdownInstance} p
|
|
26
|
+
* @returns {boolean}
|
|
27
|
+
*/
|
|
28
|
+
export function isAuthor(p: MarkdownInstance): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Predicate for whether a page is an author page
|
|
31
|
+
* @param {MarkdownInstance} p
|
|
32
|
+
* @returns {boolean}
|
|
33
|
+
*/
|
|
34
|
+
export function notAuthor(p: MarkdownInstance): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Predicate for whether a page is a search page
|
|
37
|
+
* @param {MarkdownInstance} p
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
export function isSearch(p: MarkdownInstance): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Predicate for whether a page is an search page
|
|
43
|
+
* @param {MarkdownInstance} p
|
|
44
|
+
* @returns {boolean}
|
|
45
|
+
*/
|
|
46
|
+
export function notSearch(p: MarkdownInstance): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Predicate for whether a page has a modified date
|
|
49
|
+
* @param {MarkdownInstance} p
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
52
|
+
export function hasDate(p: MarkdownInstance): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Predicate for whether a page has a modified date
|
|
55
|
+
* @param {MarkdownInstance} p
|
|
56
|
+
* @returns {boolean}
|
|
57
|
+
*/
|
|
58
|
+
export function hasModDate(p: MarkdownInstance): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Predicate for whether a page should be listed
|
|
61
|
+
* @param {MarkdownInstance<Record<string, any>>} p
|
|
62
|
+
* @returns {boolean}
|
|
63
|
+
*/
|
|
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;
|
|
72
|
+
/**
|
|
73
|
+
* Sorts by the pubDate field
|
|
74
|
+
* @param {MarkdownInstance} a
|
|
75
|
+
* @param {MarkdownInstance} b
|
|
76
|
+
* @returns {any}
|
|
77
|
+
*/
|
|
78
|
+
export function sortByPubDate(a: MarkdownInstance, b: MarkdownInstance): any;
|
|
79
|
+
/**
|
|
80
|
+
* Sorts by the pubDate field in descending order
|
|
81
|
+
* @param {MarkdownInstance} a
|
|
82
|
+
* @param {MarkdownInstance} b
|
|
83
|
+
* @returns {any}
|
|
84
|
+
*/
|
|
85
|
+
export function sortByPubDateDesc(a: MarkdownInstance, b: MarkdownInstance): any;
|
|
86
|
+
/**
|
|
87
|
+
* Sorts by the modDate field
|
|
88
|
+
* @param {MarkdownInstance} a
|
|
89
|
+
* @param {MarkdownInstance} b
|
|
90
|
+
* @returns {any}
|
|
91
|
+
*/
|
|
92
|
+
export function sortByModDate(a: MarkdownInstance, b: MarkdownInstance): any;
|
|
93
|
+
/**
|
|
94
|
+
* Sorts by the modDate field
|
|
95
|
+
* @param {MarkdownInstance} a
|
|
96
|
+
* @param {MarkdownInstance} b
|
|
97
|
+
* @returns {any}
|
|
98
|
+
*/
|
|
99
|
+
export function sortByModDateDesc(a: MarkdownInstance, b: MarkdownInstance): any;
|
|
100
|
+
export namespace PostFiltering {
|
|
101
|
+
export { showInSitemap };
|
|
102
|
+
export { showInSearch };
|
|
103
|
+
export { showInMenu };
|
|
104
|
+
export { isAuthor };
|
|
105
|
+
export { notAuthor };
|
|
106
|
+
export { isSearch };
|
|
107
|
+
export { notSearch };
|
|
108
|
+
export { hasDate };
|
|
109
|
+
export { hasModDate };
|
|
110
|
+
export { isListable };
|
|
111
|
+
export { forTaxonomy };
|
|
112
|
+
}
|
|
113
|
+
export namespace PostOrdering {
|
|
114
|
+
export { sortByPubDate };
|
|
115
|
+
export { sortByPubDateDesc };
|
|
116
|
+
export { sortByModDate };
|
|
117
|
+
export { sortByModDateDesc };
|
|
118
|
+
}
|
|
119
|
+
export { Accelerator };
|
|
120
|
+
export type PagePredicate = import("./types/PagePredicate").PagePredicate;
|
|
121
|
+
export type MarkdownInstance = import("./types/Astro").MarkdownInstance;
|
|
1
122
|
import { Accelerator } from './lib/v1/accelerator.mjs';
|
|
2
|
-
import * as PostFiltering from './lib/postFiltering.mjs';
|
|
3
|
-
import * as PostOrdering from './lib/postOrdering.mjs';
|
|
4
|
-
export { Accelerator, PostFiltering, PostOrdering };
|
package/index.mjs
CHANGED
|
@@ -1,9 +1,252 @@
|
|
|
1
1
|
import { Accelerator } from './lib/v1/accelerator.mjs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef { import("./types/PagePredicate").PagePredicate } PagePredicate
|
|
5
|
+
* @typedef { import("./types/Astro").MarkdownInstance} MarkdownInstance
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Predicate for whether a page should appear in the sitemap
|
|
10
|
+
* @param {MarkdownInstance} p
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
export function showInSitemap (p) {
|
|
14
|
+
if (typeof p.frontmatter.navSitemap !== 'undefined'
|
|
15
|
+
&& p.frontmatter.navSitemap == false) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return isListable(p);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Predicate for whether a page should appear in the site search
|
|
24
|
+
* @param {MarkdownInstance} p
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
export function showInSearch (p) {
|
|
28
|
+
if (typeof p.frontmatter.navSearch !== 'undefined'
|
|
29
|
+
&& p.frontmatter.navSearch == false) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return isListable(p);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Predicate for whether a page should appear in the navigation menu
|
|
38
|
+
* @param {MarkdownInstance} p
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export function showInMenu (p) {
|
|
42
|
+
if (typeof p.frontmatter.navMenu !== 'undefined'
|
|
43
|
+
&& p.frontmatter.navMenu == false) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Predicate for whether a page is an author page
|
|
52
|
+
* @param {MarkdownInstance} p
|
|
53
|
+
* @returns {boolean}
|
|
54
|
+
*/
|
|
55
|
+
export function isAuthor (p) {
|
|
56
|
+
if (p?.frontmatter?.layout?.indexOf('/Author.astro') > -1) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Predicate for whether a page is an author page
|
|
65
|
+
* @param {MarkdownInstance} p
|
|
66
|
+
* @returns {boolean}
|
|
67
|
+
*/
|
|
68
|
+
export function notAuthor (p) {
|
|
69
|
+
return !isAuthor(p);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Predicate for whether a page is a search page
|
|
74
|
+
* @param {MarkdownInstance} p
|
|
75
|
+
* @returns {boolean}
|
|
76
|
+
*/
|
|
77
|
+
export function isSearch (p) {
|
|
78
|
+
if (p?.frontmatter?.layout?.indexOf('/Search.astro') > -1) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Predicate for whether a page is an search page
|
|
87
|
+
* @param {MarkdownInstance} p
|
|
88
|
+
* @returns {boolean}
|
|
89
|
+
*/
|
|
90
|
+
export function notSearch (p) {
|
|
91
|
+
return !isSearch(p);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Predicate for whether a page has a modified date
|
|
96
|
+
* @param {MarkdownInstance} p
|
|
97
|
+
* @returns {boolean}
|
|
98
|
+
*/
|
|
99
|
+
export function hasDate (p) {
|
|
100
|
+
if (p?.frontmatter?.modDate != null || p?.frontmatter?.pubDate != null) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Predicate for whether a page has a modified date
|
|
109
|
+
* @param {MarkdownInstance} p
|
|
110
|
+
* @returns {boolean}
|
|
111
|
+
*/
|
|
112
|
+
export function hasModDate (p) {
|
|
113
|
+
if (p?.frontmatter?.modDate != null) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Predicate for whether a page should be listed
|
|
122
|
+
* @param {MarkdownInstance<Record<string, any>>} p
|
|
123
|
+
* @returns {boolean}
|
|
124
|
+
*/
|
|
125
|
+
export function isListable (p) {
|
|
126
|
+
if (p.url == null || p.url === '') {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (p.frontmatter == null || p.frontmatter.layout == null) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (p.frontmatter.layout.includes('/Redirect.astro')) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (p.frontmatter.listable != null && p.frontmatter.listable == false) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (p.frontmatter.draft == true) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (p.frontmatter.pubDate != null && Date.parse(p.frontmatter.pubDate) > Date.now()) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
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
|
+
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Sorts by the pubDate field
|
|
185
|
+
* @param {MarkdownInstance} a
|
|
186
|
+
* @param {MarkdownInstance} b
|
|
187
|
+
* @returns {any}
|
|
188
|
+
*/
|
|
189
|
+
export function sortByPubDate (a, b) {
|
|
190
|
+
const dateA = a.frontmatter.pubDate || '1970-01-01';
|
|
191
|
+
const dateB = b.frontmatter.pubDate || '1970-01-01';
|
|
192
|
+
return dateA.localeCompare(dateB);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Sorts by the pubDate field in descending order
|
|
197
|
+
* @param {MarkdownInstance} a
|
|
198
|
+
* @param {MarkdownInstance} b
|
|
199
|
+
* @returns {any}
|
|
200
|
+
*/
|
|
201
|
+
export function sortByPubDateDesc (a, b) {
|
|
202
|
+
const dateA = a.frontmatter.pubDate || '1970-01-01';
|
|
203
|
+
const dateB = b.frontmatter.pubDate || '1970-01-01';
|
|
204
|
+
return dateB.localeCompare(dateA);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Sorts by the modDate field
|
|
209
|
+
* @param {MarkdownInstance} a
|
|
210
|
+
* @param {MarkdownInstance} b
|
|
211
|
+
* @returns {any}
|
|
212
|
+
*/
|
|
213
|
+
export function sortByModDate (a, b) {
|
|
214
|
+
const dateA = a.frontmatter.modDate || a.frontmatter.pubDate || '1970-01-01';
|
|
215
|
+
const dateB = b.frontmatter.modDate || b.frontmatter.pubDate || '1970-01-01';
|
|
216
|
+
return dateA.localeCompare(dateB);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Sorts by the modDate field
|
|
221
|
+
* @param {MarkdownInstance} a
|
|
222
|
+
* @param {MarkdownInstance} b
|
|
223
|
+
* @returns {any}
|
|
224
|
+
*/
|
|
225
|
+
export function sortByModDateDesc (a, b) {
|
|
226
|
+
const dateA = a.frontmatter.modDate || a.frontmatter.pubDate || '1970-01-01';
|
|
227
|
+
const dateB = b.frontmatter.modDate || b.frontmatter.pubDate || '1970-01-01';
|
|
228
|
+
return dateB.localeCompare(dateA);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export const PostFiltering = {
|
|
232
|
+
showInSitemap,
|
|
233
|
+
showInSearch,
|
|
234
|
+
showInMenu,
|
|
235
|
+
isAuthor,
|
|
236
|
+
notAuthor,
|
|
237
|
+
isSearch,
|
|
238
|
+
notSearch,
|
|
239
|
+
hasDate,
|
|
240
|
+
hasModDate,
|
|
241
|
+
isListable,
|
|
242
|
+
forTaxonomy
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export const PostOrdering = {
|
|
246
|
+
sortByPubDate,
|
|
247
|
+
sortByPubDateDesc,
|
|
248
|
+
sortByModDate,
|
|
249
|
+
sortByModDateDesc
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export { Accelerator };
|
package/lib/v1/authors.mjs
CHANGED
package/lib/v1/navigation.mjs
CHANGED
package/lib/v1/taxonomy.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-accelerator-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.92",
|
|
4
4
|
"description": "Astro utilities for Astro Accelerator.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"homepage": "https://astro.stevefenton.co.uk/",
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@cucumber/cucumber": "^13.0.0",
|
|
40
|
-
"@types/node": "^25.9.
|
|
40
|
+
"@types/node": "^25.9.3",
|
|
41
41
|
"c8": "^11.0.0",
|
|
42
42
|
"cspell": "^10.0.1",
|
|
43
43
|
"rehype-stringify": "^10.0.1",
|
package/lib/postFiltering.d.mts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef { import("../types/PagePredicate").PagePredicate } PagePredicate
|
|
3
|
-
* @typedef { import("../types/Astro").MarkdownInstance} MarkdownInstance
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Predicate for whether a page should appear in the sitemap
|
|
7
|
-
* @param {MarkdownInstance} p
|
|
8
|
-
* @returns {boolean}
|
|
9
|
-
*/
|
|
10
|
-
export function showInSitemap(p: MarkdownInstance): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Predicate for whether a page should appear in the site search
|
|
13
|
-
* @param {MarkdownInstance} p
|
|
14
|
-
* @returns {boolean}
|
|
15
|
-
*/
|
|
16
|
-
export function showInSearch(p: MarkdownInstance): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Predicate for whether a page should appear in the navigation menu
|
|
19
|
-
* @param {MarkdownInstance} p
|
|
20
|
-
* @returns {boolean}
|
|
21
|
-
*/
|
|
22
|
-
export function showInMenu(p: MarkdownInstance): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Predicate for whether a page is an author page
|
|
25
|
-
* @param {MarkdownInstance} p
|
|
26
|
-
* @returns {boolean}
|
|
27
|
-
*/
|
|
28
|
-
export function isAuthor(p: MarkdownInstance): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Predicate for whether a page is an author page
|
|
31
|
-
* @param {MarkdownInstance} p
|
|
32
|
-
* @returns {boolean}
|
|
33
|
-
*/
|
|
34
|
-
export function notAuthor(p: MarkdownInstance): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Predicate for whether a page is a search page
|
|
37
|
-
* @param {MarkdownInstance} p
|
|
38
|
-
* @returns {boolean}
|
|
39
|
-
*/
|
|
40
|
-
export function isSearch(p: MarkdownInstance): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Predicate for whether a page is an search page
|
|
43
|
-
* @param {MarkdownInstance} p
|
|
44
|
-
* @returns {boolean}
|
|
45
|
-
*/
|
|
46
|
-
export function notSearch(p: MarkdownInstance): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Predicate for whether a page has a modified date
|
|
49
|
-
* @param {MarkdownInstance} p
|
|
50
|
-
* @returns {boolean}
|
|
51
|
-
*/
|
|
52
|
-
export function hasDate(p: MarkdownInstance): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Predicate for whether a page has a modified date
|
|
55
|
-
* @param {MarkdownInstance} p
|
|
56
|
-
* @returns {boolean}
|
|
57
|
-
*/
|
|
58
|
-
export function hasModDate(p: MarkdownInstance): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Predicate for whether a page should be listed
|
|
61
|
-
* @param {MarkdownInstance<Record<string, any>>} p
|
|
62
|
-
* @returns {boolean}
|
|
63
|
-
*/
|
|
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;
|
|
72
|
-
export type PagePredicate = import("../types/PagePredicate").PagePredicate;
|
|
73
|
-
export type MarkdownInstance = import("../types/Astro").MarkdownInstance;
|
package/lib/postFiltering.mjs
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef { import("../types/PagePredicate").PagePredicate } PagePredicate
|
|
3
|
-
* @typedef { import("../types/Astro").MarkdownInstance} MarkdownInstance
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Predicate for whether a page should appear in the sitemap
|
|
8
|
-
* @param {MarkdownInstance} p
|
|
9
|
-
* @returns {boolean}
|
|
10
|
-
*/
|
|
11
|
-
export function showInSitemap (p) {
|
|
12
|
-
// User setting to remove from sitemap
|
|
13
|
-
if (typeof p.frontmatter.navSitemap !== 'undefined'
|
|
14
|
-
&& p.frontmatter.navSitemap == false) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return isListable(p);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Predicate for whether a page should appear in the site search
|
|
23
|
-
* @param {MarkdownInstance} p
|
|
24
|
-
* @returns {boolean}
|
|
25
|
-
*/
|
|
26
|
-
export function showInSearch (p) {
|
|
27
|
-
// User setting to remove from search
|
|
28
|
-
if (typeof p.frontmatter.navSearch !== 'undefined'
|
|
29
|
-
&& p.frontmatter.navSearch == false) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return isListable(p);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Predicate for whether a page should appear in the navigation menu
|
|
38
|
-
* @param {MarkdownInstance} p
|
|
39
|
-
* @returns {boolean}
|
|
40
|
-
*/
|
|
41
|
-
export function showInMenu (p) {
|
|
42
|
-
if (typeof p.frontmatter.navMenu !== 'undefined'
|
|
43
|
-
&& p.frontmatter.navMenu == false) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Predicate for whether a page is an author page
|
|
52
|
-
* @param {MarkdownInstance} p
|
|
53
|
-
* @returns {boolean}
|
|
54
|
-
*/
|
|
55
|
-
export function isAuthor (p) {
|
|
56
|
-
if (p?.frontmatter?.layout?.indexOf('/Author.astro') > -1) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Predicate for whether a page is an author page
|
|
65
|
-
* @param {MarkdownInstance} p
|
|
66
|
-
* @returns {boolean}
|
|
67
|
-
*/
|
|
68
|
-
export function notAuthor (p) {
|
|
69
|
-
return !isAuthor(p);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Predicate for whether a page is a search page
|
|
74
|
-
* @param {MarkdownInstance} p
|
|
75
|
-
* @returns {boolean}
|
|
76
|
-
*/
|
|
77
|
-
export function isSearch (p) {
|
|
78
|
-
if (p?.frontmatter?.layout?.indexOf('/Search.astro') > -1) {
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Predicate for whether a page is an search page
|
|
87
|
-
* @param {MarkdownInstance} p
|
|
88
|
-
* @returns {boolean}
|
|
89
|
-
*/
|
|
90
|
-
export function notSearch (p) {
|
|
91
|
-
return !isSearch(p);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Predicate for whether a page has a modified date
|
|
96
|
-
* @param {MarkdownInstance} p
|
|
97
|
-
* @returns {boolean}
|
|
98
|
-
*/
|
|
99
|
-
export function hasDate (p) {
|
|
100
|
-
if (p?.frontmatter?.modDate != null || p?.frontmatter?.pubDate != null) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Predicate for whether a page has a modified date
|
|
109
|
-
* @param {MarkdownInstance} p
|
|
110
|
-
* @returns {boolean}
|
|
111
|
-
*/
|
|
112
|
-
export function hasModDate (p) {
|
|
113
|
-
if (p?.frontmatter?.modDate != null) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Predicate for whether a page should be listed
|
|
122
|
-
* @param {MarkdownInstance<Record<string, any>>} p
|
|
123
|
-
* @returns {boolean}
|
|
124
|
-
*/
|
|
125
|
-
export function isListable (p) {
|
|
126
|
-
if (p.url == null || p.url === '') {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (p.frontmatter == null || p.frontmatter.layout == null) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (p.frontmatter.layout.includes('/Redirect.astro')) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (p.frontmatter.listable != null && p.frontmatter.listable == false) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (p.frontmatter.draft == true) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (p.frontmatter.pubDate != null && Date.parse(p.frontmatter.pubDate) > Date.now()) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
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
|
-
|
|
180
|
-
return true;
|
|
181
|
-
}
|
package/lib/postOrdering.d.mts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef { import("../types/Astro").MarkdownInstance} MarkdownInstance
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Sorts by the pubDate field
|
|
6
|
-
* @param {MarkdownInstance} a
|
|
7
|
-
* @param {MarkdownInstance} b
|
|
8
|
-
* @returns {any}
|
|
9
|
-
*/
|
|
10
|
-
export function sortByPubDate(a: MarkdownInstance, b: MarkdownInstance): any;
|
|
11
|
-
/**
|
|
12
|
-
* Sorts by the pubDate field in descending order
|
|
13
|
-
* @param {MarkdownInstance} a
|
|
14
|
-
* @param {MarkdownInstance} b
|
|
15
|
-
* @returns {any}
|
|
16
|
-
*/
|
|
17
|
-
export function sortByPubDateDesc(a: MarkdownInstance, b: MarkdownInstance): any;
|
|
18
|
-
/**
|
|
19
|
-
* Sorts by the modDate field
|
|
20
|
-
* @param {MarkdownInstance} a
|
|
21
|
-
* @param {MarkdownInstance} b
|
|
22
|
-
* @returns {any}
|
|
23
|
-
*/
|
|
24
|
-
export function sortByModDate(a: MarkdownInstance, b: MarkdownInstance): any;
|
|
25
|
-
/**
|
|
26
|
-
* Sorts by the modDate field
|
|
27
|
-
* @param {MarkdownInstance} a
|
|
28
|
-
* @param {MarkdownInstance} b
|
|
29
|
-
* @returns {any}
|
|
30
|
-
*/
|
|
31
|
-
export function sortByModDateDesc(a: MarkdownInstance, b: MarkdownInstance): any;
|
|
32
|
-
export type MarkdownInstance = import("../types/Astro").MarkdownInstance;
|
package/lib/postOrdering.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef { import("../types/Astro").MarkdownInstance} MarkdownInstance
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Sorts by the pubDate field
|
|
7
|
-
* @param {MarkdownInstance} a
|
|
8
|
-
* @param {MarkdownInstance} b
|
|
9
|
-
* @returns {any}
|
|
10
|
-
*/
|
|
11
|
-
export function sortByPubDate (a, b) {
|
|
12
|
-
const dateA = a.frontmatter.pubDate || '1970-01-01';
|
|
13
|
-
const dateB = b.frontmatter.pubDate || '1970-01-01';
|
|
14
|
-
return dateA.localeCompare(dateB);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Sorts by the pubDate field in descending order
|
|
19
|
-
* @param {MarkdownInstance} a
|
|
20
|
-
* @param {MarkdownInstance} b
|
|
21
|
-
* @returns {any}
|
|
22
|
-
*/
|
|
23
|
-
export function sortByPubDateDesc (a, b) {
|
|
24
|
-
const dateA = a.frontmatter.pubDate || '1970-01-01';
|
|
25
|
-
const dateB = b.frontmatter.pubDate || '1970-01-01';
|
|
26
|
-
return dateB.localeCompare(dateA);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Sorts by the modDate field
|
|
31
|
-
* @param {MarkdownInstance} a
|
|
32
|
-
* @param {MarkdownInstance} b
|
|
33
|
-
* @returns {any}
|
|
34
|
-
*/
|
|
35
|
-
export function sortByModDate (a, b) {
|
|
36
|
-
const dateA = a.frontmatter.modDate || a.frontmatter.pubDate || '1970-01-01';
|
|
37
|
-
const dateB = b.frontmatter.modDate || b.frontmatter.pubDate || '1970-01-01';
|
|
38
|
-
return dateA.localeCompare(dateB);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Sorts by the modDate field
|
|
43
|
-
* @param {MarkdownInstance} a
|
|
44
|
-
* @param {MarkdownInstance} b
|
|
45
|
-
* @returns {any}
|
|
46
|
-
*/
|
|
47
|
-
export function sortByModDateDesc (a, b) {
|
|
48
|
-
const dateA = a.frontmatter.modDate || a.frontmatter.pubDate || '1970-01-01';
|
|
49
|
-
const dateB = b.frontmatter.modDate || b.frontmatter.pubDate || '1970-01-01';
|
|
50
|
-
return dateB.localeCompare(dateA);
|
|
51
|
-
}
|