astro-accelerator-utils 0.0.26 → 0.0.27
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 +0 -2
- package/lib/postFiltering.mjs +0 -1
- package/lib/postQueries.d.mts +3 -13
- package/lib/postQueries.mjs +8 -7
- package/package.json +1 -1
- package/types/PageFunction.d.ts +0 -2
package/lib/postFiltering.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef { import("../types/PageFunction").PageFunction } PageFunction
|
|
3
2
|
* @typedef { import("../types/PagePredicate").PagePredicate } PagePredicate
|
|
4
3
|
* @typedef { import("../types/Astro").MarkdownInstance} MarkdownInstance
|
|
5
4
|
*/
|
|
@@ -39,6 +38,5 @@ export function isSearch(p: any): boolean;
|
|
|
39
38
|
* @returns {boolean}
|
|
40
39
|
*/
|
|
41
40
|
export function isListable(p: any): boolean;
|
|
42
|
-
export type PageFunction = import("../types/PageFunction").PageFunction;
|
|
43
41
|
export type PagePredicate = import("../types/PagePredicate").PagePredicate;
|
|
44
42
|
export type MarkdownInstance = any;
|
package/lib/postFiltering.mjs
CHANGED
package/lib/postQueries.d.mts
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef { import("../types/PageFunction").PageFunction } PageFunction
|
|
3
|
-
* @typedef { import("../types/PagePredicate").PagePredicate } PagePredicate
|
|
4
|
-
* @typedef { import("../types/Frontmatter").Frontmatter } Frontmatter
|
|
5
|
-
* @typedef { import("../types/Astro").MarkdownInstance } MarkdownInstance
|
|
6
|
-
* @typedef { import("../types/AuthorList").AuthorList } AuthorList
|
|
7
|
-
*/
|
|
8
1
|
/**
|
|
9
2
|
* Fetches pages
|
|
10
|
-
* @param {PageFunction} fetchPages
|
|
11
3
|
* @param {PagePredicate} [filter]
|
|
12
4
|
* @returns {Promise<MarkdownInstance<Record<string, any>>[]>}
|
|
13
5
|
*/
|
|
14
|
-
export function getPages(
|
|
6
|
+
export function getPages(filter?: PagePredicate): Promise<MarkdownInstance<Record<string, any>>[]>;
|
|
15
7
|
/**
|
|
16
8
|
*
|
|
17
|
-
* @param {PageFunction} fetchPages
|
|
18
9
|
* @param {Frontmatter} frontmatter
|
|
19
|
-
* @returns {AuthorList}
|
|
10
|
+
* @returns {Promise<AuthorList>}
|
|
20
11
|
*/
|
|
21
|
-
export function getAuthors(
|
|
22
|
-
export type PageFunction = import("../types/PageFunction").PageFunction;
|
|
12
|
+
export function getAuthors(frontmatter: Frontmatter): Promise<AuthorList>;
|
|
23
13
|
export type PagePredicate = import("../types/PagePredicate").PagePredicate;
|
|
24
14
|
export type Frontmatter = import("../types/Frontmatter").Frontmatter;
|
|
25
15
|
export type MarkdownInstance = any;
|
package/lib/postQueries.mjs
CHANGED
|
@@ -2,25 +2,27 @@ import { getItem, setItem } from './cache.mjs';
|
|
|
2
2
|
import * as PostFiltering from './postFiltering.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @typedef { import("../types/PageFunction").PageFunction } PageFunction
|
|
6
5
|
* @typedef { import("../types/PagePredicate").PagePredicate } PagePredicate
|
|
7
6
|
* @typedef { import("../types/Frontmatter").Frontmatter } Frontmatter
|
|
8
7
|
* @typedef { import("../types/Astro").MarkdownInstance } MarkdownInstance
|
|
9
8
|
* @typedef { import("../types/AuthorList").AuthorList } AuthorList
|
|
10
9
|
*/
|
|
11
10
|
|
|
11
|
+
function fetchAll () {
|
|
12
|
+
return import.meta.glob("/src/pages/**/*.md", { eager: true });
|
|
13
|
+
}
|
|
14
|
+
|
|
12
15
|
/**
|
|
13
16
|
* Fetches pages
|
|
14
|
-
* @param {PageFunction} fetchPages
|
|
15
17
|
* @param {PagePredicate} [filter]
|
|
16
18
|
* @returns {Promise<MarkdownInstance<Record<string, any>>[]>}
|
|
17
19
|
*/
|
|
18
|
-
export async function getPages (
|
|
20
|
+
export async function getPages (filter) {
|
|
19
21
|
const key = 'PageQueries__getPages';
|
|
20
22
|
let allPages = await getItem(key);
|
|
21
23
|
|
|
22
24
|
if (allPages == null) {
|
|
23
|
-
const pageImportResult =
|
|
25
|
+
const pageImportResult = fetchAll();
|
|
24
26
|
allPages = Object.values(pageImportResult);
|
|
25
27
|
await setItem(key, allPages);
|
|
26
28
|
}
|
|
@@ -34,12 +36,11 @@ export async function getPages (fetchPages, filter) {
|
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
*
|
|
37
|
-
* @param {PageFunction} fetchPages
|
|
38
39
|
* @param {Frontmatter} frontmatter
|
|
39
40
|
* @returns {Promise<AuthorList>}
|
|
40
41
|
*/
|
|
41
|
-
export async function getAuthors (
|
|
42
|
-
const authors = await getPages(
|
|
42
|
+
export async function getAuthors (frontmatter) {
|
|
43
|
+
const authors = await getPages(fetchAll, PostFiltering.isAuthor);
|
|
43
44
|
|
|
44
45
|
/** @type {AuthorList} */
|
|
45
46
|
const result = {
|
package/package.json
CHANGED
package/types/PageFunction.d.ts
DELETED