@xingwangzhe/stalux 1.2.0 → 1.3.1
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/README.md +51 -23
- package/package.json +24 -25
- package/scripts/cli.mjs +45 -43
- package/src/components/stalux/layout/listPage.astro +3 -2
- package/src/config.ts +30 -30
- package/src/index.ts +179 -155
- package/src/internal/components-plugin.ts +24 -24
- package/src/internal/dev-toolbar.ts +8 -8
- package/src/internal/font-subset.ts +372 -0
- package/src/internal/override.ts +57 -57
- package/src/internal/pagefind.ts +23 -22
- package/src/layouts/Stalux.astro +10 -0
- package/src/pages/404.astro +1 -0
- package/src/pages/about.astro +1 -0
- package/src/pages/archives.astro +1 -1
- package/src/pages/categories/[category].astro +1 -0
- package/src/pages/categories/index.astro +1 -0
- package/src/pages/index.astro +1 -1
- package/src/pages/links.astro +7 -6
- package/src/pages/posts/[post].astro +1 -0
- package/src/pages/tags/[tag].astro +1 -0
- package/src/pages/tags/index.astro +1 -0
- package/src/pages/words.astro +1 -1
- package/src/schemas/collections.ts +85 -84
- package/template/astro.config.mjs +3 -3
- package/template/package.json +5 -5
- package/template/stalux/posts/hello-stalux.md +1 -1
- package/template/stalux/words/_template.md +1 -0
|
@@ -60,6 +60,7 @@ export async function getStaticPaths() {
|
|
|
60
60
|
tags={props.post.data.tags}
|
|
61
61
|
categories={props.post.data.categories}
|
|
62
62
|
author={authorConfig.name}
|
|
63
|
+
fontSubsetId={`posts-${props.post.data.abbrlink}`}
|
|
63
64
|
>
|
|
64
65
|
<div style="height:3em"></div>
|
|
65
66
|
<Navs /><div style="height:3em"></div>
|
|
@@ -29,6 +29,7 @@ const props = Astro.props as Props;
|
|
|
29
29
|
title={t("taxonomy.tag") + ": " + props.tag + " | " + siteConfig.title}
|
|
30
30
|
description={t("taxonomy.browseTag", { title: siteConfig.title, tag: props.tag, count: props.count })}
|
|
31
31
|
noindex={props.count < 3}
|
|
32
|
+
fontSubsetId="tags"
|
|
32
33
|
>
|
|
33
34
|
<div style="height: 3em;"></div>
|
|
34
35
|
<Navs />
|
|
@@ -14,6 +14,7 @@ const { t } = createTranslator(siteConfig.lang || "zh-CN");
|
|
|
14
14
|
<Stalux
|
|
15
15
|
title={t("tags.title") + " | " + siteConfig.title}
|
|
16
16
|
description={t("tags.description", { title: siteConfig.title })}
|
|
17
|
+
fontSubsetId="tags"
|
|
17
18
|
>
|
|
18
19
|
<div style="height: 3em;"></div>
|
|
19
20
|
<Navs />
|
package/src/pages/words.astro
CHANGED
|
@@ -13,7 +13,7 @@ const { t } = createTranslator(siteConfig.lang || "zh-CN");
|
|
|
13
13
|
const entries = await getCollection("words", ({ data }) => !data.draft);
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
<Stalux title={t("words.title") + " | " + siteConfig.title} description={t("words.description")}>
|
|
16
|
+
<Stalux title={t("words.title") + " | " + siteConfig.title} description={t("words.description")} fontSubsetId="words">
|
|
17
17
|
<div style="height: 3em;"></div>
|
|
18
18
|
<Navs />
|
|
19
19
|
<h1 class={styles.title}>{t("words.heading")}</h1>
|
|
@@ -15,18 +15,19 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { configSchema } from "./config";
|
|
19
|
-
import { defineCollection } from "astro:content";
|
|
20
18
|
import { glob } from "astro/loaders";
|
|
21
19
|
import { z } from "astro/zod";
|
|
20
|
+
import { defineCollection } from "astro:content";
|
|
21
|
+
|
|
22
|
+
import { configSchema } from "./config";
|
|
22
23
|
|
|
23
24
|
// ---------------------------------------------------------------------------
|
|
24
25
|
// 集合配置选项
|
|
25
26
|
// ---------------------------------------------------------------------------
|
|
26
27
|
|
|
27
28
|
export interface CollectionPaths {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
/** 内容根目录(默认 "stalux") */
|
|
30
|
+
contentDir?: string;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
// ---------------------------------------------------------------------------
|
|
@@ -34,36 +35,36 @@ export interface CollectionPaths {
|
|
|
34
35
|
// ---------------------------------------------------------------------------
|
|
35
36
|
|
|
36
37
|
const postSchema = z.object({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
38
|
+
title: z.string().min(1, "title is required"),
|
|
39
|
+
abbrlink: z
|
|
40
|
+
.string({ invalid_type_error: "abbrlink must be a string or number" })
|
|
41
|
+
.or(z.number().transform((num) => num.toString())),
|
|
42
|
+
date: z
|
|
43
|
+
.string({
|
|
44
|
+
required_error: "date is required",
|
|
45
|
+
invalid_type_error: "date must be a string",
|
|
46
|
+
})
|
|
47
|
+
.min(1, "date is required, format: YYYY-MM-DD HH:mm:ss"),
|
|
48
|
+
updated: z.string().optional(),
|
|
49
|
+
draft: z.boolean().optional().default(false),
|
|
50
|
+
tags: z.preprocess(
|
|
51
|
+
(val) => (typeof val === "string" ? [val] : val),
|
|
52
|
+
z.array(z.string()).optional(),
|
|
53
|
+
),
|
|
54
|
+
categories: z.preprocess(
|
|
55
|
+
(val) => (typeof val === "string" ? [val] : val),
|
|
56
|
+
z.array(z.string()).optional(),
|
|
57
|
+
),
|
|
58
|
+
desc: z
|
|
59
|
+
.string({
|
|
60
|
+
required_error: "desc is required",
|
|
61
|
+
invalid_type_error: "desc must be a string",
|
|
62
|
+
})
|
|
63
|
+
.min(1, "desc is required"),
|
|
64
|
+
minutesRead: z.string().optional(),
|
|
65
|
+
wordCount: z.number().optional(),
|
|
66
|
+
cc: z.string().optional().default("CC-BY-NC-SA-4.0"),
|
|
67
|
+
cover: z.string().optional(),
|
|
67
68
|
});
|
|
68
69
|
|
|
69
70
|
// ---------------------------------------------------------------------------
|
|
@@ -77,61 +78,61 @@ const postSchema = z.object({
|
|
|
77
78
|
* @returns 四个内容集合,可直接在 `src/content.config.ts` 中导出
|
|
78
79
|
*/
|
|
79
80
|
export function defineCollections(paths: CollectionPaths = {}) {
|
|
80
|
-
|
|
81
|
+
const root = paths.contentDir ?? "stalux";
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
const posts = defineCollection({
|
|
84
|
+
loader: glob({
|
|
85
|
+
pattern: ["*.{md,mdx}"],
|
|
86
|
+
base: `${root}/posts/`,
|
|
87
|
+
generateId: ({ data }) => String((data as Record<string, unknown>).abbrlink ?? ""),
|
|
88
|
+
retainBody: true,
|
|
89
|
+
deferRender: true,
|
|
90
|
+
}),
|
|
91
|
+
schema: postSchema,
|
|
92
|
+
});
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
const config = defineCollection({
|
|
95
|
+
loader: glob({
|
|
96
|
+
pattern: ["*.yml"],
|
|
97
|
+
base: `${root}/config/`,
|
|
98
|
+
generateId: ({ data }) => String((data as Record<string, unknown>).id ?? ""),
|
|
99
|
+
}),
|
|
100
|
+
schema: configSchema,
|
|
101
|
+
});
|
|
101
102
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
const about = defineCollection({
|
|
104
|
+
loader: glob({
|
|
105
|
+
base: `${root}/about`,
|
|
106
|
+
pattern: "**/*.{md,mdx}",
|
|
107
|
+
retainBody: true,
|
|
108
|
+
}),
|
|
109
|
+
schema: z.object({
|
|
110
|
+
title: z.string().min(1, "about.title is required"),
|
|
111
|
+
description: z.string().min(1, "about.description is required"),
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
115
|
+
const words = defineCollection({
|
|
116
|
+
loader: glob({
|
|
117
|
+
pattern: ["*.md"],
|
|
118
|
+
base: `${root}/words/`,
|
|
119
|
+
retainBody: true,
|
|
120
|
+
deferRender: true,
|
|
121
|
+
}),
|
|
122
|
+
schema: z.object({
|
|
123
|
+
source: z.string().optional(),
|
|
124
|
+
link: z.string().url("words.link must be a valid URL").optional(),
|
|
125
|
+
sourceDate: z.string().optional(),
|
|
126
|
+
date: z.string().optional(),
|
|
127
|
+
updated: z.string().optional(),
|
|
128
|
+
draft: z.boolean().optional().default(false),
|
|
129
|
+
title: z.string().optional(),
|
|
130
|
+
abbrlink: z.string().optional(),
|
|
131
|
+
tags: z.array(z.string()).optional(),
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
return { posts, config, about, words };
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { defineConfig } from "astro/config";
|
|
2
1
|
import { satteri } from "@astrojs/markdown-satteri";
|
|
3
2
|
import sitemap from "@astrojs/sitemap";
|
|
4
|
-
import expressiveCode from "astro-expressive-code";
|
|
5
|
-
import stalux from "stalux";
|
|
6
3
|
import { mermaidMdast, mermaidHast } from "@xingwangzhe/satteri-mermaid";
|
|
7
4
|
import { photoswipe } from "@xingwangzhe/satteri-photoswipe";
|
|
5
|
+
import expressiveCode from "astro-expressive-code";
|
|
6
|
+
import { defineConfig } from "astro/config";
|
|
7
|
+
import stalux from "stalux";
|
|
8
8
|
|
|
9
9
|
// https://astro.build/config
|
|
10
10
|
export default defineConfig({
|
package/template/package.json
CHANGED
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"astro": "astro"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"astro": "^7.0.0",
|
|
13
|
-
"stalux": "^2.0.0",
|
|
14
12
|
"@astrojs/markdown-satteri": "^1.0.0",
|
|
15
|
-
"
|
|
13
|
+
"@astrojs/sitemap": "^4.0.0",
|
|
14
|
+
"@pagefind/component-ui": "^1.5.0",
|
|
16
15
|
"@xingwangzhe/satteri-mermaid": "^0.7.0",
|
|
17
16
|
"@xingwangzhe/satteri-photoswipe": "^0.2.0",
|
|
18
|
-
"
|
|
17
|
+
"astro": "^7.0.0",
|
|
18
|
+
"astro-expressive-code": "^0.44.0",
|
|
19
19
|
"pagefind": "^1.5.0",
|
|
20
|
-
"
|
|
20
|
+
"stalux": "^2.0.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@astrojs/rss": "^4.0.0",
|