astro-accelerator-utils 0.1.4 → 0.1.5
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/navigation.mjs +4 -2
- package/lib/postQueries.d.mts +2 -2
- package/lib/postQueries.mjs +2 -2
- package/lib/v1/dates.d.mts +2 -3
- package/lib/v1/dates.mjs +1 -2
- package/lib/v1/posts.d.mts +16 -4
- package/lib/v1/posts.mjs +13 -1
- package/package.json +1 -1
package/lib/navigation.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Posts } from './v1/posts.mjs';
|
|
1
2
|
import * as PostQueries from './postQueries.mjs';
|
|
2
3
|
import * as PostFiltering from './postFiltering.mjs';
|
|
3
4
|
import * as Cache from './cache.mjs';
|
|
@@ -66,13 +67,14 @@ export function isNavPage (item) {
|
|
|
66
67
|
export async function getNavigation (currentUrl, site) {
|
|
67
68
|
|
|
68
69
|
const key = 'Navigation__getNavigation';
|
|
70
|
+
const posts = new Posts();
|
|
69
71
|
|
|
70
72
|
/** @type {NavPage[]} */
|
|
71
73
|
let pageHierarchy = await Cache.getItem(key);
|
|
72
74
|
|
|
73
75
|
if (pageHierarchy == null) {
|
|
74
|
-
const topLevelPages =
|
|
75
|
-
const allPages =
|
|
76
|
+
const topLevelPages = posts.root(site.subfolder).filter(PostFiltering.showInMenu);
|
|
77
|
+
const allPages = posts.all().filter(PostFiltering.showInMenu);
|
|
76
78
|
|
|
77
79
|
pageHierarchy = topLevelPages
|
|
78
80
|
.map(p => PostQueries.mapNavPage(p, site))
|
package/lib/postQueries.d.mts
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
export function injectFetchAll(fetcher: () => MarkdownInstance[]): void;
|
|
6
6
|
/**
|
|
7
7
|
* Replaced by Posts.all()
|
|
8
|
-
* Use Posts.all().filter(...) to filter results
|
|
8
|
+
* @deprecated Use Posts.all().filter(...) to filter results
|
|
9
9
|
* @param {PagePredicate} [filter]
|
|
10
10
|
* @returns {Promise<MarkdownInstance[]>}
|
|
11
11
|
*/
|
|
12
12
|
export function getPages(filter?: PagePredicate): Promise<MarkdownInstance[]>;
|
|
13
13
|
/**
|
|
14
14
|
* Replaced by Posts.root()
|
|
15
|
-
* Use Posts.root().filter(...) to filter results
|
|
15
|
+
* @deprecated Use Posts.root().filter(...) to filter results
|
|
16
16
|
* @param {Site} site
|
|
17
17
|
* @param {PagePredicate} [filter]
|
|
18
18
|
* @returns {Promise<MarkdownInstance[]>}
|
package/lib/postQueries.mjs
CHANGED
|
@@ -28,7 +28,7 @@ export function injectFetchAll (fetcher) {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Replaced by Posts.all()
|
|
31
|
-
* Use Posts.all().filter(...) to filter results
|
|
31
|
+
* @deprecated Use Posts.all().filter(...) to filter results
|
|
32
32
|
* @param {PagePredicate} [filter]
|
|
33
33
|
* @returns {Promise<MarkdownInstance[]>}
|
|
34
34
|
*/
|
|
@@ -51,7 +51,7 @@ export async function getPages (filter) {
|
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Replaced by Posts.root()
|
|
54
|
-
* Use Posts.root().filter(...) to filter results
|
|
54
|
+
* @deprecated Use Posts.root().filter(...) to filter results
|
|
55
55
|
* @param {Site} site
|
|
56
56
|
* @param {PagePredicate} [filter]
|
|
57
57
|
* @returns {Promise<MarkdownInstance[]>}
|
package/lib/v1/dates.d.mts
CHANGED
|
@@ -10,11 +10,10 @@ export class DateFormatter {
|
|
|
10
10
|
dateOptions: Intl.DateTimeFormatOptions;
|
|
11
11
|
/**
|
|
12
12
|
* Returns the formatted pubDate
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {string | Date} date
|
|
14
14
|
* @param {string} lang
|
|
15
|
-
* @param {Site} site
|
|
16
15
|
* @returns {string}
|
|
17
16
|
*/
|
|
18
|
-
formatDate(date:
|
|
17
|
+
formatDate(date: string | Date, lang: string): string;
|
|
19
18
|
}
|
|
20
19
|
export type Site = any;
|
package/lib/v1/dates.mjs
CHANGED
package/lib/v1/posts.d.mts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../../types/Astro").MarkdownInstance } MarkdownInstance
|
|
3
|
+
*/
|
|
1
4
|
export class Posts {
|
|
2
5
|
/**
|
|
3
6
|
* Constructor
|
|
4
|
-
* @param {() => MarkdownInstance[]} fetchAll
|
|
7
|
+
* @param {() => MarkdownInstance[]} [fetchAll]
|
|
5
8
|
*/
|
|
6
|
-
constructor(fetchAll
|
|
9
|
+
constructor(fetchAll?: () => MarkdownInstance[]);
|
|
7
10
|
fetchAll: () => any;
|
|
8
11
|
allPosts: any[];
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Gets all markdown posts in the site
|
|
14
|
+
* @returns {MarkdownInstance[]}
|
|
15
|
+
*/
|
|
16
|
+
all(): MarkdownInstance[];
|
|
17
|
+
/**
|
|
18
|
+
* Gets top-level markdown posts in the site
|
|
19
|
+
* @returns {MarkdownInstance[]}
|
|
20
|
+
*/
|
|
21
|
+
root(subfolder: any): MarkdownInstance[];
|
|
11
22
|
}
|
|
23
|
+
export type MarkdownInstance = import("../../types/Astro").MarkdownInstance;
|
package/lib/v1/posts.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../../types/Astro").MarkdownInstance } MarkdownInstance
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
export class Posts {
|
|
2
6
|
/**
|
|
3
7
|
* Constructor
|
|
4
|
-
* @param {() => MarkdownInstance[]} fetchAll
|
|
8
|
+
* @param {() => MarkdownInstance[]} [fetchAll]
|
|
5
9
|
*/
|
|
6
10
|
constructor(fetchAll) {
|
|
7
11
|
/* istanbul ignore next */
|
|
@@ -9,6 +13,10 @@ export class Posts {
|
|
|
9
13
|
this.allPosts = [];
|
|
10
14
|
}
|
|
11
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Gets all markdown posts in the site
|
|
18
|
+
* @returns {MarkdownInstance[]}
|
|
19
|
+
*/
|
|
12
20
|
all () {
|
|
13
21
|
if (this.allPosts.length === 0) {
|
|
14
22
|
const pageImportResult = this.fetchAll();
|
|
@@ -18,6 +26,10 @@ export class Posts {
|
|
|
18
26
|
return this.allPosts;
|
|
19
27
|
}
|
|
20
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Gets top-level markdown posts in the site
|
|
31
|
+
* @returns {MarkdownInstance[]}
|
|
32
|
+
*/
|
|
21
33
|
root (subfolder) {
|
|
22
34
|
const isRoot = subfolder.length == 0;
|
|
23
35
|
const expectedDepth = isRoot ? 1 : 2;
|