astro-accelerator-utils 0.0.43 → 0.0.45
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 -2
- package/index.mjs +0 -2
- package/lib/cache.d.mts +5 -0
- package/lib/cache.mjs +13 -0
- package/lib/postFiltering.mjs +17 -4
- package/lib/taxonomy.mjs +2 -1
- package/package.json +1 -1
- package/lib/config.d.mts +0 -9
- package/lib/config.mjs +0 -49
package/index.d.mts
CHANGED
|
@@ -3,11 +3,10 @@ import * as PostFiltering from "./lib/postFiltering.mjs";
|
|
|
3
3
|
import * as PostOrdering from "./lib/postOrdering.mjs";
|
|
4
4
|
import * as PostPaging from "./lib/postPaging.mjs";
|
|
5
5
|
import * as Cache from "./lib/cache.mjs";
|
|
6
|
-
import * as Config from "./lib/config.mjs";
|
|
7
6
|
import * as Dates from "./lib/dates.mjs";
|
|
8
7
|
import * as FooterMenu from "./lib/footerMenu.mjs";
|
|
9
8
|
import * as Markdown from "./lib/markdown.mjs";
|
|
10
9
|
import * as Navigation from "./lib/navigation.mjs";
|
|
11
10
|
import * as Taxonomy from "./lib/taxonomy.mjs";
|
|
12
11
|
import * as Urls from "./lib/urls.mjs";
|
|
13
|
-
export { PostQueries, PostFiltering, PostOrdering, PostPaging, Cache,
|
|
12
|
+
export { PostQueries, PostFiltering, PostOrdering, PostPaging, Cache, Dates, FooterMenu, Markdown, Navigation, Taxonomy, Urls };
|
package/index.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import * as PostFiltering from './lib/postFiltering.mjs';
|
|
|
3
3
|
import * as PostOrdering from './lib/postOrdering.mjs';
|
|
4
4
|
import * as PostPaging from './lib/postPaging.mjs';
|
|
5
5
|
import * as Cache from './lib/cache.mjs';
|
|
6
|
-
import * as Config from './lib/config.mjs';
|
|
7
6
|
import * as Dates from './lib/dates.mjs';
|
|
8
7
|
import * as FooterMenu from './lib/footerMenu.mjs';
|
|
9
8
|
import * as Markdown from './lib/markdown.mjs';
|
|
@@ -17,7 +16,6 @@ export {
|
|
|
17
16
|
PostOrdering,
|
|
18
17
|
PostPaging,
|
|
19
18
|
Cache,
|
|
20
|
-
Config,
|
|
21
19
|
Dates,
|
|
22
20
|
FooterMenu,
|
|
23
21
|
Markdown,
|
package/lib/cache.d.mts
CHANGED
|
@@ -22,4 +22,9 @@ export function getItem(key: string): Promise<any>;
|
|
|
22
22
|
* @returns {Promise<void>}
|
|
23
23
|
*/
|
|
24
24
|
export function setItem(key: string, value: any): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Clears the cache
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
export function clear(): Promise<void>;
|
|
25
30
|
export const maxAge: 200;
|
package/lib/cache.mjs
CHANGED
|
@@ -58,3 +58,16 @@ export async function setItem (key, value) {
|
|
|
58
58
|
const itemPath = await getItemPath(key);
|
|
59
59
|
await fs.promises.writeFile(itemPath, JSON.stringify(value));
|
|
60
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Clears the cache
|
|
64
|
+
* @returns {Promise<void>}
|
|
65
|
+
*/
|
|
66
|
+
export async function clear() {
|
|
67
|
+
const path = await getCachePath();
|
|
68
|
+
const files = await fs.promises.readdir(path);
|
|
69
|
+
|
|
70
|
+
for(const file of files) {
|
|
71
|
+
await fs.promises.unlink(path.join(path, file));
|
|
72
|
+
}
|
|
73
|
+
}
|
package/lib/postFiltering.mjs
CHANGED
|
@@ -79,8 +79,21 @@ export function isSearch (p) {
|
|
|
79
79
|
* @returns {boolean}
|
|
80
80
|
*/
|
|
81
81
|
export function isListable (p) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
if (p.url == null || p.url === '') {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (p.frontmatter.layout.includes('/Redirect.astro')) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (p.frontmatter.draft == true) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (Date.parse(p.frontmatter.pubDate) > Date.now()) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return true;
|
|
86
99
|
}
|
package/lib/taxonomy.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Urls from './urls.mjs';
|
|
2
2
|
import * as Cache from './cache.mjs';
|
|
3
3
|
import * as PostQueries from './postQueries.mjs';
|
|
4
|
+
import * as PostFiltering from './postFiltering.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @typedef { import("../types/Taxonomy").Taxonomy } Taxonomy
|
|
@@ -65,7 +66,7 @@ export async function getTaxonomy () {
|
|
|
65
66
|
|
|
66
67
|
if (taxonomy == null) {
|
|
67
68
|
/** @type {MarkdownInstance[]} */
|
|
68
|
-
const allPages = await PostQueries.getPages();
|
|
69
|
+
const allPages = await PostQueries.getPages(PostFiltering.isListable);
|
|
69
70
|
|
|
70
71
|
/** @type {{ [key: string]: number }} */
|
|
71
72
|
const tags = {};
|
package/package.json
CHANGED
package/lib/config.d.mts
DELETED
package/lib/config.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef { import("../types/Site").Site } Site
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Gets default configuration
|
|
7
|
-
* @returns {Site}
|
|
8
|
-
*/
|
|
9
|
-
export function getDefault() {
|
|
10
|
-
return {
|
|
11
|
-
owner: '',
|
|
12
|
-
url: '',
|
|
13
|
-
feedUrl: '',
|
|
14
|
-
title: '',
|
|
15
|
-
description: '',
|
|
16
|
-
themeColor: '#222255',
|
|
17
|
-
subfolder: '',
|
|
18
|
-
defaultLanguage: 'en',
|
|
19
|
-
default: {
|
|
20
|
-
lang: 'en',
|
|
21
|
-
locale: 'en-US',
|
|
22
|
-
dir: 'ltr'
|
|
23
|
-
},
|
|
24
|
-
search: {
|
|
25
|
-
fallbackUrl: 'https://www.google.com/search',
|
|
26
|
-
fallbackSite: 'q',
|
|
27
|
-
fallbackQuery: 'q',
|
|
28
|
-
},
|
|
29
|
-
pageSize: 12,
|
|
30
|
-
pageLinks: 3,
|
|
31
|
-
rssLimit: 20,
|
|
32
|
-
dateOptions: {
|
|
33
|
-
weekday: 'long',
|
|
34
|
-
year: 'numeric',
|
|
35
|
-
month: 'long',
|
|
36
|
-
day: 'numeric',
|
|
37
|
-
},
|
|
38
|
-
featureFlags: {
|
|
39
|
-
codeBlocks: ['copy'],
|
|
40
|
-
figures: ['enlarge'],
|
|
41
|
-
youTubeLinks: ['embed'],
|
|
42
|
-
},
|
|
43
|
-
images: {
|
|
44
|
-
contentSize: '(max-width: 860px) 100vw, 620px',
|
|
45
|
-
listerSize: '(max-width: 860px) 90vw, 350px',
|
|
46
|
-
authorSize: '50px',
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|