@xingwangzhe/stalux 1.2.0 → 1.3.0

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.
@@ -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 />
@@ -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
- /** 内容根目录(默认 "stalux") */
29
- contentDir?: string;
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
- title: z.string().min(1, "title is required"),
38
- abbrlink: z
39
- .string({ invalid_type_error: "abbrlink must be a string or number" })
40
- .or(z.number().transform((num) => num.toString())),
41
- date: z
42
- .string({
43
- required_error: "date is required",
44
- invalid_type_error: "date must be a string",
45
- })
46
- .min(1, "date is required, format: YYYY-MM-DD HH:mm:ss"),
47
- updated: z.string().optional(),
48
- draft: z.boolean().optional().default(false),
49
- tags: z.preprocess(
50
- (val) => (typeof val === "string" ? [val] : val),
51
- z.array(z.string()).optional(),
52
- ),
53
- categories: z.preprocess(
54
- (val) => (typeof val === "string" ? [val] : val),
55
- z.array(z.string()).optional(),
56
- ),
57
- desc: z
58
- .string({
59
- required_error: "desc is required",
60
- invalid_type_error: "desc must be a string",
61
- })
62
- .min(1, "desc is required"),
63
- minutesRead: z.string().optional(),
64
- wordCount: z.number().optional(),
65
- cc: z.string().optional().default("CC-BY-NC-SA-4.0"),
66
- cover: z.string().optional(),
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
- const root = paths.contentDir ?? "stalux";
81
+ const root = paths.contentDir ?? "stalux";
81
82
 
82
- const posts = defineCollection({
83
- loader: glob({
84
- pattern: ["*.{md,mdx}"],
85
- base: `${root}/posts/`,
86
- generateId: ({ data }) => String((data as Record<string, unknown>).abbrlink ?? ""),
87
- retainBody: true,
88
- deferRender: true,
89
- }),
90
- schema: postSchema,
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
- const config = defineCollection({
94
- loader: glob({
95
- pattern: ["*.yml"],
96
- base: `${root}/config/`,
97
- generateId: ({ data }) => String((data as Record<string, unknown>).id ?? ""),
98
- }),
99
- schema: configSchema,
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
- const about = defineCollection({
103
- loader: glob({
104
- base: `${root}/about`,
105
- pattern: "**/*.{md,mdx}",
106
- retainBody: true,
107
- }),
108
- schema: z.object({
109
- title: z.string().min(1, "about.title is required"),
110
- description: z.string().min(1, "about.description is required"),
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
- const words = defineCollection({
115
- loader: glob({
116
- pattern: ["*.md"],
117
- base: `${root}/words/`,
118
- retainBody: true,
119
- deferRender: true,
120
- }),
121
- schema: z.object({
122
- source: z.string().optional(),
123
- link: z.string().url("words.link must be a valid URL").optional(),
124
- sourceDate: z.string().optional(),
125
- date: z.string().optional(),
126
- updated: z.string().optional(),
127
- draft: z.boolean().optional().default(false),
128
- title: z.string().optional(),
129
- abbrlink: z.string().optional(),
130
- tags: z.array(z.string()).optional(),
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
- return { posts, config, about, words };
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({
@@ -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
- "astro-expressive-code": "^0.44.0",
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
- "@astrojs/sitemap": "^4.0.0",
17
+ "astro": "^7.0.0",
18
+ "astro-expressive-code": "^0.44.0",
19
19
  "pagefind": "^1.5.0",
20
- "@pagefind/component-ui": "^1.5.0"
20
+ "stalux": "^2.0.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@astrojs/rss": "^4.0.0",
@@ -26,7 +26,7 @@ Stalux is a modern, high-performance Astro blog theme featuring:
26
26
 
27
27
  ## Markdown Examples
28
28
 
29
- **Bold**, *italic*, ~~strikethrough~~, `inline code`
29
+ **Bold**, _italic_, ~~strikethrough~~, `inline code`
30
30
 
31
31
  ```javascript
32
32
  // Code block
@@ -9,4 +9,5 @@
9
9
  # abbrlink: "custom-id" # Optional
10
10
  # tags: [tag1, tag2] # Optional
11
11
  ---
12
+
12
13
  Write the quote body here. Supports **Markdown**, `inline code`, and code blocks.