astro-accelerator-utils 0.3.2 → 0.3.4
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 +6 -0
- package/lib/postFiltering.mjs +13 -0
- package/lib/postOrdering.d.mts +7 -0
- package/lib/postOrdering.mjs +12 -0
- package/package.json +1 -1
package/lib/postFiltering.d.mts
CHANGED
|
@@ -32,6 +32,12 @@ export function isAuthor(p: MarkdownInstance): boolean;
|
|
|
32
32
|
* @returns {boolean}
|
|
33
33
|
*/
|
|
34
34
|
export function isSearch(p: MarkdownInstance): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Predicate for whether a page has a modified date
|
|
37
|
+
* @param {MarkdownInstance} p
|
|
38
|
+
* @returns {boolean}
|
|
39
|
+
*/
|
|
40
|
+
export function hasModDate(p: MarkdownInstance): boolean;
|
|
35
41
|
/**
|
|
36
42
|
* Predicate for whether a page should be listed
|
|
37
43
|
* @param {MarkdownInstance<Record<string, any>>} p
|
package/lib/postFiltering.mjs
CHANGED
|
@@ -73,6 +73,19 @@ export function isSearch (p) {
|
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Predicate for whether a page has a modified date
|
|
78
|
+
* @param {MarkdownInstance} p
|
|
79
|
+
* @returns {boolean}
|
|
80
|
+
*/
|
|
81
|
+
export function hasModDate (p) {
|
|
82
|
+
if (p?.frontmatter?.modDate != null) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
76
89
|
/**
|
|
77
90
|
* Predicate for whether a page should be listed
|
|
78
91
|
* @param {MarkdownInstance<Record<string, any>>} p
|
package/lib/postOrdering.d.mts
CHANGED
|
@@ -22,4 +22,11 @@ export function sortByPubDateDesc(a: MarkdownInstance, b: MarkdownInstance): any
|
|
|
22
22
|
* @returns {any}
|
|
23
23
|
*/
|
|
24
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;
|
|
25
32
|
export type MarkdownInstance = import("../types/Astro").MarkdownInstance;
|
package/lib/postOrdering.mjs
CHANGED
|
@@ -37,3 +37,15 @@ export function sortByModDate (a, b) {
|
|
|
37
37
|
const dateB = b.frontmatter.modDate || b.frontmatter.pubDate || '1970-01-01';
|
|
38
38
|
return dateA.localeCompare(dateB);
|
|
39
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
|
+
}
|