astro-accelerator-utils 0.3.7 → 0.3.8
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/LICENSE +201 -201
- package/README.md +19 -19
- package/index.d.mts +4 -4
- package/index.mjs +9 -9
- package/lib/postFiltering.d.mts +48 -48
- package/lib/postFiltering.mjs +116 -116
- package/lib/postOrdering.d.mts +32 -32
- package/lib/postOrdering.mjs +51 -51
- package/lib/v1/accelerator.d.mts +36 -36
- package/lib/v1/accelerator.mjs +70 -70
- package/lib/v1/authors.d.mts +28 -28
- package/lib/v1/authors.mjs +71 -71
- package/lib/v1/cache.d.mts +43 -43
- package/lib/v1/cache.mjs +99 -99
- package/lib/v1/dates.d.mts +19 -19
- package/lib/v1/dates.mjs +26 -26
- package/lib/v1/markdown.d.mts +20 -20
- package/lib/v1/markdown.mjs +45 -45
- package/lib/v1/navigation.d.mts +111 -111
- package/lib/v1/navigation.mjs +446 -427
- package/lib/v1/paging.d.mts +15 -15
- package/lib/v1/paging.mjs +77 -77
- package/lib/v1/posts.d.mts +26 -26
- package/lib/v1/posts.mjs +47 -47
- package/lib/v1/statistics-stub.d.mts +5 -5
- package/lib/v1/statistics-stub.mjs +9 -9
- package/lib/v1/statistics.d.mts +39 -39
- package/lib/v1/statistics.mjs +78 -78
- package/lib/v1/taxonomy.d.mts +62 -62
- package/lib/v1/taxonomy.mjs +144 -144
- package/lib/v1/urls.d.mts +40 -40
- package/lib/v1/urls.mjs +104 -104
- package/package.json +3 -3
- package/types/Astro.d.ts +19 -19
- package/types/AuthorList.d.ts +8 -8
- package/types/BannerImage.d.ts +4 -4
- package/types/Frontmatter.d.ts +30 -30
- package/types/Link.d.ts +6 -6
- package/types/NavPage.d.ts +22 -22
- package/types/PagePredicate.d.ts +2 -2
- package/types/Site.d.ts +43 -43
- package/types/Taxonomy.d.ts +15 -15
package/lib/postFiltering.mjs
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
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 a search page
|
|
65
|
-
* @param {MarkdownInstance} p
|
|
66
|
-
* @returns {boolean}
|
|
67
|
-
*/
|
|
68
|
-
export function isSearch (p) {
|
|
69
|
-
if (p?.frontmatter?.layout?.indexOf('/Search.astro') > -1) {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
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
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Predicate for whether a page should be listed
|
|
91
|
-
* @param {MarkdownInstance<Record<string, any>>} p
|
|
92
|
-
* @returns {boolean}
|
|
93
|
-
*/
|
|
94
|
-
export function isListable (p) {
|
|
95
|
-
if (p.url == null || p.url === '') {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (p.frontmatter == null || p.frontmatter.layout == null) {
|
|
100
|
-
console.log('No frontmatter layout for ' + p.url);
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (p.frontmatter.layout.includes('/Redirect.astro')) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (p.frontmatter.draft == true) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (p.frontmatter.pubDate != null && Date.parse(p.frontmatter.pubDate) > Date.now()) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return true;
|
|
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 a search page
|
|
65
|
+
* @param {MarkdownInstance} p
|
|
66
|
+
* @returns {boolean}
|
|
67
|
+
*/
|
|
68
|
+
export function isSearch (p) {
|
|
69
|
+
if (p?.frontmatter?.layout?.indexOf('/Search.astro') > -1) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
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
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Predicate for whether a page should be listed
|
|
91
|
+
* @param {MarkdownInstance<Record<string, any>>} p
|
|
92
|
+
* @returns {boolean}
|
|
93
|
+
*/
|
|
94
|
+
export function isListable (p) {
|
|
95
|
+
if (p.url == null || p.url === '') {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (p.frontmatter == null || p.frontmatter.layout == null) {
|
|
100
|
+
console.log('No frontmatter layout for ' + p.url);
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (p.frontmatter.layout.includes('/Redirect.astro')) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (p.frontmatter.draft == true) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (p.frontmatter.pubDate != null && Date.parse(p.frontmatter.pubDate) > Date.now()) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return true;
|
|
117
117
|
}
|
package/lib/postOrdering.d.mts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
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;
|
|
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
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
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
|
-
}
|
|
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
|
+
}
|
package/lib/v1/accelerator.d.mts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef { import("../../types/Site").Site } Site
|
|
3
|
-
*/
|
|
4
|
-
export class Accelerator {
|
|
5
|
-
/**
|
|
6
|
-
* @param {Site} site
|
|
7
|
-
*/
|
|
8
|
-
constructor(site: Site);
|
|
9
|
-
cacheMaxAge: number;
|
|
10
|
-
dateOptions: Intl.DateTimeFormatOptions;
|
|
11
|
-
siteUrl: string;
|
|
12
|
-
subfolder: string;
|
|
13
|
-
useTrailingUrlSlash: boolean;
|
|
14
|
-
captureStatistics: boolean;
|
|
15
|
-
get authors(): Authors;
|
|
16
|
-
get cache(): Cache;
|
|
17
|
-
get dateFormatter(): DateFormatter;
|
|
18
|
-
get markdown(): Markdown;
|
|
19
|
-
get navigation(): Navigation;
|
|
20
|
-
get paging(): Paging;
|
|
21
|
-
get posts(): Posts;
|
|
22
|
-
get taxonomy(): Taxonomy;
|
|
23
|
-
get urlFormatter(): UrlFormatter;
|
|
24
|
-
get statistics(): typeof StatisticsStub;
|
|
25
|
-
}
|
|
26
|
-
export type Site = import("../../types/Site").Site;
|
|
27
|
-
import { Authors } from "./authors.mjs";
|
|
28
|
-
import { Cache } from "./cache.mjs";
|
|
29
|
-
import { DateFormatter } from "./dates.mjs";
|
|
30
|
-
import { Markdown } from "./markdown.mjs";
|
|
31
|
-
import { Navigation } from "./navigation.mjs";
|
|
32
|
-
import { Paging } from "./paging.mjs";
|
|
33
|
-
import { Posts } from "./posts.mjs";
|
|
34
|
-
import { Taxonomy } from "./taxonomy.mjs";
|
|
35
|
-
import { UrlFormatter } from "./urls.mjs";
|
|
36
|
-
import { StatisticsStub } from "./statistics-stub.mjs";
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../../types/Site").Site } Site
|
|
3
|
+
*/
|
|
4
|
+
export class Accelerator {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Site} site
|
|
7
|
+
*/
|
|
8
|
+
constructor(site: Site);
|
|
9
|
+
cacheMaxAge: number;
|
|
10
|
+
dateOptions: Intl.DateTimeFormatOptions;
|
|
11
|
+
siteUrl: string;
|
|
12
|
+
subfolder: string;
|
|
13
|
+
useTrailingUrlSlash: boolean;
|
|
14
|
+
captureStatistics: boolean;
|
|
15
|
+
get authors(): Authors;
|
|
16
|
+
get cache(): Cache;
|
|
17
|
+
get dateFormatter(): DateFormatter;
|
|
18
|
+
get markdown(): Markdown;
|
|
19
|
+
get navigation(): Navigation;
|
|
20
|
+
get paging(): Paging;
|
|
21
|
+
get posts(): Posts;
|
|
22
|
+
get taxonomy(): Taxonomy;
|
|
23
|
+
get urlFormatter(): UrlFormatter;
|
|
24
|
+
get statistics(): typeof StatisticsStub;
|
|
25
|
+
}
|
|
26
|
+
export type Site = import("../../types/Site").Site;
|
|
27
|
+
import { Authors } from "./authors.mjs";
|
|
28
|
+
import { Cache } from "./cache.mjs";
|
|
29
|
+
import { DateFormatter } from "./dates.mjs";
|
|
30
|
+
import { Markdown } from "./markdown.mjs";
|
|
31
|
+
import { Navigation } from "./navigation.mjs";
|
|
32
|
+
import { Paging } from "./paging.mjs";
|
|
33
|
+
import { Posts } from "./posts.mjs";
|
|
34
|
+
import { Taxonomy } from "./taxonomy.mjs";
|
|
35
|
+
import { UrlFormatter } from "./urls.mjs";
|
|
36
|
+
import { StatisticsStub } from "./statistics-stub.mjs";
|
package/lib/v1/accelerator.mjs
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { Authors } from './authors.mjs';
|
|
2
|
-
import { Cache } from './cache.mjs';
|
|
3
|
-
import { DateFormatter } from './dates.mjs';
|
|
4
|
-
import { Markdown } from './markdown.mjs';
|
|
5
|
-
import { Navigation } from './navigation.mjs';
|
|
6
|
-
import { Paging } from './paging.mjs';
|
|
7
|
-
import { Posts } from './posts.mjs';
|
|
8
|
-
import { Taxonomy } from './taxonomy.mjs';
|
|
9
|
-
import { UrlFormatter } from './urls.mjs';
|
|
10
|
-
import { Statistics } from './statistics.mjs';
|
|
11
|
-
import { StatisticsStub } from './statistics-stub.mjs';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @typedef { import("../../types/Site").Site } Site
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export class Accelerator {
|
|
18
|
-
/**
|
|
19
|
-
* @param {Site} site
|
|
20
|
-
*/
|
|
21
|
-
constructor(site) {
|
|
22
|
-
this.cacheMaxAge = site.cacheMaxAge;
|
|
23
|
-
this.dateOptions = site.dateOptions;
|
|
24
|
-
this.siteUrl = site.url;
|
|
25
|
-
this.subfolder = site.subfolder;
|
|
26
|
-
this.useTrailingUrlSlash = site.useTrailingUrlSlash;
|
|
27
|
-
this.captureStatistics = site.captureStatistics;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get authors() {
|
|
31
|
-
return new Authors(this.posts);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get cache() {
|
|
35
|
-
return new Cache(this.cacheMaxAge);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get dateFormatter() {
|
|
39
|
-
return new DateFormatter(this.dateOptions)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get markdown() {
|
|
43
|
-
return new Markdown();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get navigation() {
|
|
47
|
-
return new Navigation(this.posts, this.urlFormatter, this.taxonomy);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get paging() {
|
|
51
|
-
return new Paging();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get posts() {
|
|
55
|
-
return new Posts(this.cache);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
get taxonomy() {
|
|
59
|
-
return new Taxonomy(this.cache, this.posts, this.urlFormatter);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
get urlFormatter() {
|
|
63
|
-
return new UrlFormatter(this.siteUrl, this.subfolder, this.useTrailingUrlSlash);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
get statistics() {
|
|
67
|
-
return (this.captureStatistics)
|
|
68
|
-
? Statistics
|
|
69
|
-
: StatisticsStub;
|
|
70
|
-
}
|
|
1
|
+
import { Authors } from './authors.mjs';
|
|
2
|
+
import { Cache } from './cache.mjs';
|
|
3
|
+
import { DateFormatter } from './dates.mjs';
|
|
4
|
+
import { Markdown } from './markdown.mjs';
|
|
5
|
+
import { Navigation } from './navigation.mjs';
|
|
6
|
+
import { Paging } from './paging.mjs';
|
|
7
|
+
import { Posts } from './posts.mjs';
|
|
8
|
+
import { Taxonomy } from './taxonomy.mjs';
|
|
9
|
+
import { UrlFormatter } from './urls.mjs';
|
|
10
|
+
import { Statistics } from './statistics.mjs';
|
|
11
|
+
import { StatisticsStub } from './statistics-stub.mjs';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef { import("../../types/Site").Site } Site
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export class Accelerator {
|
|
18
|
+
/**
|
|
19
|
+
* @param {Site} site
|
|
20
|
+
*/
|
|
21
|
+
constructor(site) {
|
|
22
|
+
this.cacheMaxAge = site.cacheMaxAge;
|
|
23
|
+
this.dateOptions = site.dateOptions;
|
|
24
|
+
this.siteUrl = site.url;
|
|
25
|
+
this.subfolder = site.subfolder;
|
|
26
|
+
this.useTrailingUrlSlash = site.useTrailingUrlSlash;
|
|
27
|
+
this.captureStatistics = site.captureStatistics;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get authors() {
|
|
31
|
+
return new Authors(this.posts);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get cache() {
|
|
35
|
+
return new Cache(this.cacheMaxAge);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get dateFormatter() {
|
|
39
|
+
return new DateFormatter(this.dateOptions)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get markdown() {
|
|
43
|
+
return new Markdown();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get navigation() {
|
|
47
|
+
return new Navigation(this.posts, this.urlFormatter, this.taxonomy);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get paging() {
|
|
51
|
+
return new Paging();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get posts() {
|
|
55
|
+
return new Posts(this.cache);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get taxonomy() {
|
|
59
|
+
return new Taxonomy(this.cache, this.posts, this.urlFormatter);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get urlFormatter() {
|
|
63
|
+
return new UrlFormatter(this.siteUrl, this.subfolder, this.useTrailingUrlSlash);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get statistics() {
|
|
67
|
+
return (this.captureStatistics)
|
|
68
|
+
? Statistics
|
|
69
|
+
: StatisticsStub;
|
|
70
|
+
}
|
|
71
71
|
}
|
package/lib/v1/authors.d.mts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef { import("../../types/AuthorList").AuthorList } AuthorList
|
|
3
|
-
* @typedef { import("../../types/Astro").MarkdownInstance } MarkdownInstance
|
|
4
|
-
* @typedef { import("../../types/Frontmatter").Frontmatter } Frontmatter
|
|
5
|
-
*/
|
|
6
|
-
export class Authors {
|
|
7
|
-
/**
|
|
8
|
-
* Constructor
|
|
9
|
-
* @param {Posts} posts
|
|
10
|
-
*/
|
|
11
|
-
constructor(posts: Posts);
|
|
12
|
-
posts: Posts;
|
|
13
|
-
/**
|
|
14
|
-
* Gets a list of authors, and exposes main author and contributors
|
|
15
|
-
* @param {Frontmatter} frontmatter
|
|
16
|
-
* @returns {AuthorList}
|
|
17
|
-
*/
|
|
18
|
-
forPost(frontmatter: Frontmatter): AuthorList;
|
|
19
|
-
/**
|
|
20
|
-
* Get a single author by id/slug
|
|
21
|
-
* @param {string} slug
|
|
22
|
-
* @returns {MarkdownInstance}
|
|
23
|
-
*/
|
|
24
|
-
info(slug: string): MarkdownInstance;
|
|
25
|
-
}
|
|
26
|
-
export type AuthorList = import("../../types/AuthorList").AuthorList;
|
|
27
|
-
export type MarkdownInstance = import("../../types/Astro").MarkdownInstance;
|
|
28
|
-
export type Frontmatter = import("../../types/Frontmatter").Frontmatter;
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../../types/AuthorList").AuthorList } AuthorList
|
|
3
|
+
* @typedef { import("../../types/Astro").MarkdownInstance } MarkdownInstance
|
|
4
|
+
* @typedef { import("../../types/Frontmatter").Frontmatter } Frontmatter
|
|
5
|
+
*/
|
|
6
|
+
export class Authors {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor
|
|
9
|
+
* @param {Posts} posts
|
|
10
|
+
*/
|
|
11
|
+
constructor(posts: Posts);
|
|
12
|
+
posts: Posts;
|
|
13
|
+
/**
|
|
14
|
+
* Gets a list of authors, and exposes main author and contributors
|
|
15
|
+
* @param {Frontmatter} frontmatter
|
|
16
|
+
* @returns {AuthorList}
|
|
17
|
+
*/
|
|
18
|
+
forPost(frontmatter: Frontmatter): AuthorList;
|
|
19
|
+
/**
|
|
20
|
+
* Get a single author by id/slug
|
|
21
|
+
* @param {string} slug
|
|
22
|
+
* @returns {MarkdownInstance}
|
|
23
|
+
*/
|
|
24
|
+
info(slug: string): MarkdownInstance;
|
|
25
|
+
}
|
|
26
|
+
export type AuthorList = import("../../types/AuthorList").AuthorList;
|
|
27
|
+
export type MarkdownInstance = import("../../types/Astro").MarkdownInstance;
|
|
28
|
+
export type Frontmatter = import("../../types/Frontmatter").Frontmatter;
|