astro-accelerator-utils 0.0.19 → 0.0.21
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 +1 -1
- package/index.mjs +1 -1
- package/lib/Cache.d.mts +2 -2
- package/lib/{Cache.mjs → cache.mjs} +2 -2
- package/lib/dates.d.mts +8 -4
- package/lib/dates.mjs +6 -2
- package/lib/postFiltering.d.mts +20 -12
- package/lib/postFiltering.mjs +12 -6
- package/lib/postOrdering.d.mts +13 -9
- package/lib/postOrdering.mjs +10 -6
- package/lib/postQueries.d.mts +12 -4
- package/lib/postQueries.mjs +9 -3
- package/lib/urls.d.mts +6 -2
- package/lib/urls.mjs +5 -1
- package/package.json +3 -2
- package/types/Markdown.d.ts +4 -0
- package/types/PageFunction.d.ts +2 -0
- package/types/PagePredicate.d.ts +2 -0
- package/types/Site.d.ts +34 -0
package/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as PostQueries from "./lib/postQueries.mjs";
|
|
2
2
|
import * as PostFiltering from "./lib/postFiltering.mjs";
|
|
3
3
|
import * as PostOrdering from "./lib/postOrdering.mjs";
|
|
4
|
-
import * as Cache from "./lib/
|
|
4
|
+
import * as Cache from "./lib/cache.mjs";
|
|
5
5
|
import * as Dates from "./lib/dates.mjs";
|
|
6
6
|
import * as Urls from "./lib/urls.mjs";
|
|
7
7
|
export { PostQueries, PostFiltering, PostOrdering, Cache, Dates, Urls };
|
package/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as PostQueries from "./lib/postQueries.mjs";
|
|
2
2
|
import * as PostFiltering from "./lib/postFiltering.mjs";
|
|
3
3
|
import * as PostOrdering from "./lib/postOrdering.mjs";
|
|
4
|
-
import * as Cache from "./lib/
|
|
4
|
+
import * as Cache from "./lib/cache.mjs";
|
|
5
5
|
import * as Dates from "./lib/dates.mjs";
|
|
6
6
|
import * as Urls from "./lib/urls.mjs";
|
|
7
7
|
|
package/lib/Cache.d.mts
CHANGED
|
@@ -18,7 +18,7 @@ export function getItem(key: string): any;
|
|
|
18
18
|
/**
|
|
19
19
|
* Adds an item to the cache
|
|
20
20
|
* @param {string} key
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {any} value
|
|
22
22
|
*/
|
|
23
|
-
export function setItem(key: string, value:
|
|
23
|
+
export function setItem(key: string, value: any): Promise<void>;
|
|
24
24
|
export const maxAge: 200;
|
|
@@ -21,7 +21,7 @@ export async function getCachePath () {
|
|
|
21
21
|
*/
|
|
22
22
|
export async function getItemPath (key) {
|
|
23
23
|
const cachePath = await getCachePath();
|
|
24
|
-
return path.join(cachePath, key + '.
|
|
24
|
+
return path.join(cachePath, key + '.json');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -51,7 +51,7 @@ export async function getItem (key) {
|
|
|
51
51
|
/**
|
|
52
52
|
* Adds an item to the cache
|
|
53
53
|
* @param {string} key
|
|
54
|
-
* @param {
|
|
54
|
+
* @param {any} value
|
|
55
55
|
*/
|
|
56
56
|
export async function setItem (key, value) {
|
|
57
57
|
const itemPath = await getItemPath(key);
|
package/lib/dates.d.mts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/Site") } Site
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Returns the formatted pubDate
|
|
3
6
|
* @param {any} frontmatter
|
|
4
7
|
* @param {string} lang
|
|
5
|
-
* @param {
|
|
8
|
+
* @param {Site} site
|
|
6
9
|
* @returns {string}
|
|
7
10
|
*/
|
|
8
|
-
export function formatDate(frontmatter: any, lang: string, site:
|
|
11
|
+
export function formatDate(frontmatter: any, lang: string, site: Site): string;
|
|
9
12
|
/**
|
|
10
13
|
* Returns the formatted modDate
|
|
11
14
|
* @param {any} frontmatter
|
|
12
15
|
* @param {string} lang
|
|
13
|
-
* @param {
|
|
16
|
+
* @param {Site} site
|
|
14
17
|
* @returns {string}
|
|
15
18
|
*/
|
|
16
|
-
export function formatModifiedDate(frontmatter: any, lang: string, site:
|
|
19
|
+
export function formatModifiedDate(frontmatter: any, lang: string, site: Site): string;
|
|
20
|
+
export type Site = typeof import("../types/Site");
|
package/lib/dates.mjs
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/Site") } Site
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Returns the formatted pubDate
|
|
3
7
|
* @param {any} frontmatter
|
|
4
8
|
* @param {string} lang
|
|
5
|
-
* @param {
|
|
9
|
+
* @param {Site} site
|
|
6
10
|
* @returns {string}
|
|
7
11
|
*/
|
|
8
12
|
export function formatDate (frontmatter, lang, site) {
|
|
@@ -19,7 +23,7 @@ export function formatDate (frontmatter, lang, site) {
|
|
|
19
23
|
* Returns the formatted modDate
|
|
20
24
|
* @param {any} frontmatter
|
|
21
25
|
* @param {string} lang
|
|
22
|
-
* @param {
|
|
26
|
+
* @param {Site} site
|
|
23
27
|
* @returns {string}
|
|
24
28
|
*/
|
|
25
29
|
export function formatModifiedDate (frontmatter, lang, site) {
|
package/lib/postFiltering.d.mts
CHANGED
|
@@ -1,36 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/PageFunction") } PageFunction
|
|
3
|
+
* @typedef { import("../types/PagePredicate") } PagePredicate
|
|
4
|
+
* @typedef { import("../types/Markdown") } Markdown
|
|
5
|
+
*/
|
|
1
6
|
/**
|
|
2
7
|
* Predicate for whether a page should appear in the sitemap
|
|
3
|
-
* @param {
|
|
8
|
+
* @param {Markdown} p
|
|
4
9
|
* @returns {boolean}
|
|
5
10
|
*/
|
|
6
|
-
export function showInSitemap(p:
|
|
11
|
+
export function showInSitemap(p: Markdown): boolean;
|
|
7
12
|
/**
|
|
8
13
|
* Predicate for whether a page should appear in the site search
|
|
9
|
-
* @param {
|
|
14
|
+
* @param {Markdown} p
|
|
10
15
|
* @returns {boolean}
|
|
11
16
|
*/
|
|
12
|
-
export function showInSearch(p:
|
|
17
|
+
export function showInSearch(p: Markdown): boolean;
|
|
13
18
|
/**
|
|
14
19
|
* Predicate for whether a page should appear in the navigation menu
|
|
15
|
-
* @param {
|
|
20
|
+
* @param {Markdown} p
|
|
16
21
|
* @returns {boolean}
|
|
17
22
|
*/
|
|
18
|
-
export function showInMenu(p:
|
|
23
|
+
export function showInMenu(p: Markdown): boolean;
|
|
19
24
|
/**
|
|
20
25
|
* Predicate for whether a page is an author page
|
|
21
|
-
* @param {
|
|
26
|
+
* @param {Markdown} p
|
|
22
27
|
* @returns {boolean}
|
|
23
28
|
*/
|
|
24
|
-
export function isAuthor(p:
|
|
29
|
+
export function isAuthor(p: Markdown): boolean;
|
|
25
30
|
/**
|
|
26
31
|
* Predicate for whether a page is a search page
|
|
27
|
-
* @param {
|
|
32
|
+
* @param {Markdown} p
|
|
28
33
|
* @returns {boolean}
|
|
29
34
|
*/
|
|
30
|
-
export function isSearch(p:
|
|
35
|
+
export function isSearch(p: Markdown): boolean;
|
|
31
36
|
/**
|
|
32
37
|
* Predicate for whether a page should be listed
|
|
33
|
-
* @param {
|
|
38
|
+
* @param {Markdown} p
|
|
34
39
|
* @returns {boolean}
|
|
35
40
|
*/
|
|
36
|
-
export function isListable(p:
|
|
41
|
+
export function isListable(p: Markdown): boolean;
|
|
42
|
+
export type PageFunction = typeof import("../types/PageFunction");
|
|
43
|
+
export type PagePredicate = typeof import("../types/PagePredicate");
|
|
44
|
+
export type Markdown = typeof import("../types/Markdown");
|
package/lib/postFiltering.mjs
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/PageFunction") } PageFunction
|
|
3
|
+
* @typedef { import("../types/PagePredicate") } PagePredicate
|
|
4
|
+
* @typedef { import("../types/Markdown") } Markdown
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Predicate for whether a page should appear in the sitemap
|
|
3
|
-
* @param {
|
|
9
|
+
* @param {Markdown} p
|
|
4
10
|
* @returns {boolean}
|
|
5
11
|
*/
|
|
6
12
|
export function showInSitemap (p) {
|
|
@@ -15,7 +21,7 @@ export function showInSitemap (p) {
|
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* Predicate for whether a page should appear in the site search
|
|
18
|
-
* @param {
|
|
24
|
+
* @param {Markdown} p
|
|
19
25
|
* @returns {boolean}
|
|
20
26
|
*/
|
|
21
27
|
export function showInSearch (p) {
|
|
@@ -30,7 +36,7 @@ export function showInSearch (p) {
|
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* Predicate for whether a page should appear in the navigation menu
|
|
33
|
-
* @param {
|
|
39
|
+
* @param {Markdown} p
|
|
34
40
|
* @returns {boolean}
|
|
35
41
|
*/
|
|
36
42
|
export function showInMenu (p) {
|
|
@@ -44,7 +50,7 @@ export function showInMenu (p) {
|
|
|
44
50
|
|
|
45
51
|
/**
|
|
46
52
|
* Predicate for whether a page is an author page
|
|
47
|
-
* @param {
|
|
53
|
+
* @param {Markdown} p
|
|
48
54
|
* @returns {boolean}
|
|
49
55
|
*/
|
|
50
56
|
export function isAuthor (p) {
|
|
@@ -57,7 +63,7 @@ export function isAuthor (p) {
|
|
|
57
63
|
|
|
58
64
|
/**
|
|
59
65
|
* Predicate for whether a page is a search page
|
|
60
|
-
* @param {
|
|
66
|
+
* @param {Markdown} p
|
|
61
67
|
* @returns {boolean}
|
|
62
68
|
*/
|
|
63
69
|
export function isSearch (p) {
|
|
@@ -70,7 +76,7 @@ export function isSearch (p) {
|
|
|
70
76
|
|
|
71
77
|
/**
|
|
72
78
|
* Predicate for whether a page should be listed
|
|
73
|
-
* @param {
|
|
79
|
+
* @param {Markdown} p
|
|
74
80
|
* @returns {boolean}
|
|
75
81
|
*/
|
|
76
82
|
export function isListable (p) {
|
package/lib/postOrdering.d.mts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/Markdown") } Markdown
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Sorts by the pubDate field
|
|
3
|
-
* @param {
|
|
4
|
-
* @param {
|
|
6
|
+
* @param {Markdown} a
|
|
7
|
+
* @param {Markdown} b
|
|
5
8
|
* @returns {any}
|
|
6
9
|
*/
|
|
7
|
-
export function sortByPubDate(a:
|
|
10
|
+
export function sortByPubDate(a: Markdown, b: Markdown): any;
|
|
8
11
|
/**
|
|
9
12
|
* Sorts by the pubDate field in descending order
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
13
|
+
* @param {Markdown} a
|
|
14
|
+
* @param {Markdown} b
|
|
12
15
|
* @returns {any}
|
|
13
16
|
*/
|
|
14
|
-
export function sortByPubDateDesc(a:
|
|
17
|
+
export function sortByPubDateDesc(a: Markdown, b: Markdown): any;
|
|
15
18
|
/**
|
|
16
19
|
* Sorts by the modDate field
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
20
|
+
* @param {Markdown} a
|
|
21
|
+
* @param {Markdown} b
|
|
19
22
|
* @returns {any}
|
|
20
23
|
*/
|
|
21
|
-
export function sortByModDate(a:
|
|
24
|
+
export function sortByModDate(a: Markdown, b: Markdown): any;
|
|
25
|
+
export type Markdown = typeof import("../types/Markdown");
|
package/lib/postOrdering.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/Markdown") } Markdown
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Sorts by the pubDate field
|
|
3
|
-
* @param {
|
|
4
|
-
* @param {
|
|
7
|
+
* @param {Markdown} a
|
|
8
|
+
* @param {Markdown} b
|
|
5
9
|
* @returns {any}
|
|
6
10
|
*/
|
|
7
11
|
export function sortByPubDate (a, b) {
|
|
@@ -10,8 +14,8 @@ export function sortByPubDate (a, b) {
|
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
16
|
* Sorts by the pubDate field in descending order
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
17
|
+
* @param {Markdown} a
|
|
18
|
+
* @param {Markdown} b
|
|
15
19
|
* @returns {any}
|
|
16
20
|
*/
|
|
17
21
|
export function sortByPubDateDesc (a, b) {
|
|
@@ -20,8 +24,8 @@ export function sortByPubDateDesc (a, b) {
|
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Sorts by the modDate field
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
27
|
+
* @param {Markdown} a
|
|
28
|
+
* @param {Markdown} b
|
|
25
29
|
* @returns {any}
|
|
26
30
|
*/
|
|
27
31
|
export function sortByModDate (a, b) {
|
package/lib/postQueries.d.mts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/PageFunction") } PageFunction
|
|
3
|
+
* @typedef { import("../types/PagePredicate") } PagePredicate
|
|
4
|
+
* @typedef { import("../types/Markdown") } Markdown
|
|
5
|
+
*/
|
|
1
6
|
/**
|
|
2
7
|
* Fetches pages
|
|
3
|
-
* @param {
|
|
4
|
-
* @param {
|
|
5
|
-
* @returns {
|
|
8
|
+
* @param {PageFunction} fetchPages
|
|
9
|
+
* @param {PagePredicate} [filter]
|
|
10
|
+
* @returns {Markdown[]}
|
|
6
11
|
*/
|
|
7
|
-
export function getPages(fetchPages:
|
|
12
|
+
export function getPages(fetchPages: PageFunction, filter?: PagePredicate): Markdown[];
|
|
13
|
+
export type PageFunction = typeof import("../types/PageFunction");
|
|
14
|
+
export type PagePredicate = typeof import("../types/PagePredicate");
|
|
15
|
+
export type Markdown = typeof import("../types/Markdown");
|
package/lib/postQueries.mjs
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { getItem, setItem } from "./Cache.mjs";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @typedef { import("../types/PageFunction") } PageFunction
|
|
5
|
+
* @typedef { import("../types/PagePredicate") } PagePredicate
|
|
6
|
+
* @typedef { import("../types/Markdown") } Markdown
|
|
7
|
+
*/
|
|
8
|
+
|
|
3
9
|
/**
|
|
4
10
|
* Fetches pages
|
|
5
|
-
* @param {
|
|
6
|
-
* @param {
|
|
7
|
-
* @returns {
|
|
11
|
+
* @param {PageFunction} fetchPages
|
|
12
|
+
* @param {PagePredicate} [filter]
|
|
13
|
+
* @returns {Markdown[]}
|
|
8
14
|
*/
|
|
9
15
|
export async function getPages (fetchPages, filter) {
|
|
10
16
|
const key = 'PageQueries__getPages';
|
package/lib/urls.d.mts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/Site") } Site
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Ensures trailing slash is used
|
|
3
6
|
* @param {URL} url
|
|
@@ -7,7 +10,8 @@ export function addSlashToUrl(url: URL): URL;
|
|
|
7
10
|
/**
|
|
8
11
|
* Ensures trailing slash is used
|
|
9
12
|
* @param {string} address
|
|
10
|
-
* @param {
|
|
13
|
+
* @param {Site} site
|
|
11
14
|
* @returns {string}
|
|
12
15
|
*/
|
|
13
|
-
export function addSlashToAddress(address: string, site:
|
|
16
|
+
export function addSlashToAddress(address: string, site: Site): string;
|
|
17
|
+
export type Site = typeof import("../types/Site");
|
package/lib/urls.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef { import("../types/Site") } Site
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Ensures trailing slash is used
|
|
3
7
|
* @param {URL} url
|
|
@@ -11,7 +15,7 @@ export function addSlashToUrl(url) {
|
|
|
11
15
|
/**
|
|
12
16
|
* Ensures trailing slash is used
|
|
13
17
|
* @param {string} address
|
|
14
|
-
* @param {
|
|
18
|
+
* @param {Site} site
|
|
15
19
|
* @returns {string}
|
|
16
20
|
*/
|
|
17
21
|
export function addSlashToAddress(address, site) {
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-accelerator-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"description": "Astro utilities for Astro Accelerator.",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"index.mjs",
|
|
8
8
|
"index.d.mts",
|
|
9
|
-
"lib/*"
|
|
9
|
+
"lib/*",
|
|
10
|
+
"types/*.d.ts"
|
|
10
11
|
],
|
|
11
12
|
"types": "index.d.mts",
|
|
12
13
|
"scripts": {
|
package/types/Site.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type Site = {
|
|
2
|
+
url: string;
|
|
3
|
+
dateOptions: Intl.DateTimeFormatOptions;
|
|
4
|
+
subfolder: string;
|
|
5
|
+
feedUrl: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
defaultLanguage: string;
|
|
9
|
+
themeColor: string;
|
|
10
|
+
owner: string;
|
|
11
|
+
default: {
|
|
12
|
+
lang: string;
|
|
13
|
+
locale: string;
|
|
14
|
+
dir: string;
|
|
15
|
+
};
|
|
16
|
+
search: {
|
|
17
|
+
fallbackUrl: 'https://www.google.com/search' | string;
|
|
18
|
+
fallbackSite: 'q' | string;
|
|
19
|
+
fallbackQuery: 'q' | string;
|
|
20
|
+
};
|
|
21
|
+
pageSize: number;
|
|
22
|
+
pageLinks: number;
|
|
23
|
+
rssLimit: number;
|
|
24
|
+
featureFlags: {
|
|
25
|
+
codeBlocks: 'copy'[];
|
|
26
|
+
figures: 'enlarge'[];
|
|
27
|
+
youTubeLinks: 'embed'[];
|
|
28
|
+
};
|
|
29
|
+
images: {
|
|
30
|
+
contentSize: string;
|
|
31
|
+
listerSize: string;
|
|
32
|
+
authorSize: string;
|
|
33
|
+
};
|
|
34
|
+
};
|