@xingwangzhe/stalux 1.2.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.
Files changed (214) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +192 -0
  3. package/package.json +108 -0
  4. package/scripts/cli.mjs +103 -0
  5. package/src/assets/BiCcCircle.svg +1 -0
  6. package/src/assets/astro.svg +1 -0
  7. package/src/assets/background/README.md +3 -0
  8. package/src/assets/background/pattern-1.min.svg +1 -0
  9. package/src/assets/background/pattern-10.min.svg +1 -0
  10. package/src/assets/background/pattern-11.min.svg +1 -0
  11. package/src/assets/background/pattern-12.min.svg +1 -0
  12. package/src/assets/background/pattern-13.min.svg +1 -0
  13. package/src/assets/background/pattern-14.min.svg +1 -0
  14. package/src/assets/background/pattern-15.min.svg +1 -0
  15. package/src/assets/background/pattern-16.min.svg +1 -0
  16. package/src/assets/background/pattern-17.min.svg +1 -0
  17. package/src/assets/background/pattern-18.min.svg +1 -0
  18. package/src/assets/background/pattern-19.min.svg +1 -0
  19. package/src/assets/background/pattern-2.min.svg +1 -0
  20. package/src/assets/background/pattern-20.min.svg +1 -0
  21. package/src/assets/background/pattern-21.min.svg +1 -0
  22. package/src/assets/background/pattern-22.min.svg +1 -0
  23. package/src/assets/background/pattern-23.min.svg +1 -0
  24. package/src/assets/background/pattern-24.min.svg +1 -0
  25. package/src/assets/background/pattern-25.min.svg +1 -0
  26. package/src/assets/background/pattern-26.min.svg +1 -0
  27. package/src/assets/background/pattern-27.min.svg +1 -0
  28. package/src/assets/background/pattern-28.min.svg +1 -0
  29. package/src/assets/background/pattern-29.min.svg +1 -0
  30. package/src/assets/background/pattern-3.min.svg +1 -0
  31. package/src/assets/background/pattern-30.min.svg +1 -0
  32. package/src/assets/background/pattern-31.min.svg +1 -0
  33. package/src/assets/background/pattern-32.min.svg +1 -0
  34. package/src/assets/background/pattern-33.min.svg +1 -0
  35. package/src/assets/background/pattern-34.min.svg +1 -0
  36. package/src/assets/background/pattern-35.min.svg +1 -0
  37. package/src/assets/background/pattern-36.min.svg +1 -0
  38. package/src/assets/background/pattern-37.min.svg +1 -0
  39. package/src/assets/background/pattern-38.min.svg +1 -0
  40. package/src/assets/background/pattern-39.min.svg +1 -0
  41. package/src/assets/background/pattern-4.min.svg +1 -0
  42. package/src/assets/background/pattern-40.min.svg +1 -0
  43. package/src/assets/background/pattern-41.min.svg +1 -0
  44. package/src/assets/background/pattern-42.min.svg +1 -0
  45. package/src/assets/background/pattern-5.min.svg +1 -0
  46. package/src/assets/background/pattern-6.min.svg +1 -0
  47. package/src/assets/background/pattern-7.min.svg +1 -0
  48. package/src/assets/background/pattern-8.min.svg +1 -0
  49. package/src/assets/background/pattern-9.min.svg +1 -0
  50. package/src/assets/background.svg +1 -0
  51. package/src/assets/cc-icon.svg +4 -0
  52. package/src/assets/fonts/GoogleSansCode-Italic.woff2 +0 -0
  53. package/src/assets/fonts/GoogleSansCode.woff2 +0 -0
  54. package/src/assets/fonts/LXGWWenKai-Regular.ttf +0 -0
  55. package/src/assets/fonts/LXGWWenKai-Regular.woff2 +0 -0
  56. package/src/components/stalux/analytics/clarity.astro +25 -0
  57. package/src/components/stalux/analytics/google.astro +31 -0
  58. package/src/components/stalux/analytics/umami.astro +16 -0
  59. package/src/components/stalux/archives/archivesList.astro +116 -0
  60. package/src/components/stalux/archives/toArchive.astro +14 -0
  61. package/src/components/stalux/categories/categoriesCard.astro +49 -0
  62. package/src/components/stalux/categories/categoriesList.astro +17 -0
  63. package/src/components/stalux/common/author.astro +35 -0
  64. package/src/components/stalux/common/date.astro +59 -0
  65. package/src/components/stalux/common/search.astro +14 -0
  66. package/src/components/stalux/common/textType.astro +16 -0
  67. package/src/components/stalux/common/verCount.astro +10 -0
  68. package/src/components/stalux/footer/FooterBadges.astro +150 -0
  69. package/src/components/stalux/footer/FooterBeian.astro +91 -0
  70. package/src/components/stalux/footer/FooterCopyright.astro +40 -0
  71. package/src/components/stalux/footer/FooterStats.astro +108 -0
  72. package/src/components/stalux/footer/FooterThemeInfo.astro +67 -0
  73. package/src/components/stalux/layout/footer.astro +87 -0
  74. package/src/components/stalux/layout/head.astro +194 -0
  75. package/src/components/stalux/layout/listPage.astro +26 -0
  76. package/src/components/stalux/layout/navs.astro +174 -0
  77. package/src/components/stalux/links/linkCard.astro +50 -0
  78. package/src/components/stalux/links/linkList.astro +20 -0
  79. package/src/components/stalux/links/socialMedia.astro +102 -0
  80. package/src/components/stalux/posts/PhotoSwipeStyle.astro +3 -0
  81. package/src/components/stalux/posts/PostTaxonomy.astro +65 -0
  82. package/src/components/stalux/posts/WalineComment.astro +609 -0
  83. package/src/components/stalux/posts/postAuthor.astro +23 -0
  84. package/src/components/stalux/posts/postCC.astro +52 -0
  85. package/src/components/stalux/posts/postCard.astro +83 -0
  86. package/src/components/stalux/posts/postContent.astro +174 -0
  87. package/src/components/stalux/posts/postLeft.astro +41 -0
  88. package/src/components/stalux/posts/postList.astro +25 -0
  89. package/src/components/stalux/posts/postNavigation.astro +137 -0
  90. package/src/components/stalux/posts/postRight.astro +33 -0
  91. package/src/components/stalux/posts/postToc.astro +88 -0
  92. package/src/components/stalux/posts/randomPost.astro +134 -0
  93. package/src/components/stalux/tags/tagHeader.astro +50 -0
  94. package/src/components/stalux/tags/tagsCloud.astro +100 -0
  95. package/src/components/stalux/words/wordCard.astro +62 -0
  96. package/src/components/stalux/words/wordList.astro +70 -0
  97. package/src/config.ts +58 -0
  98. package/src/i18n/en.json +193 -0
  99. package/src/i18n/zh-CN.json +193 -0
  100. package/src/index.ts +215 -0
  101. package/src/internal/components-plugin.ts +54 -0
  102. package/src/internal/dev-toolbar.ts +33 -0
  103. package/src/internal/override.ts +99 -0
  104. package/src/internal/pagefind.ts +40 -0
  105. package/src/layouts/PostLayout.astro +90 -0
  106. package/src/layouts/Stalux.astro +91 -0
  107. package/src/pages/404.astro +103 -0
  108. package/src/pages/about.astro +59 -0
  109. package/src/pages/about.md.ts +15 -0
  110. package/src/pages/api/post.abbrlink.json.ts +20 -0
  111. package/src/pages/archives.astro +23 -0
  112. package/src/pages/archives.md.ts +24 -0
  113. package/src/pages/atom.xml.ts +29 -0
  114. package/src/pages/categories/[category].astro +35 -0
  115. package/src/pages/categories/[category].md.ts +34 -0
  116. package/src/pages/categories/index.astro +23 -0
  117. package/src/pages/categories/index.md.ts +27 -0
  118. package/src/pages/index.astro +30 -0
  119. package/src/pages/index.md.ts +18 -0
  120. package/src/pages/links.astro +23 -0
  121. package/src/pages/links.md.ts +18 -0
  122. package/src/pages/llms-full.txt.ts +25 -0
  123. package/src/pages/llms.txt.ts +26 -0
  124. package/src/pages/posts/[post].astro +69 -0
  125. package/src/pages/posts/[post].md.ts +109 -0
  126. package/src/pages/rss.xml.ts +29 -0
  127. package/src/pages/tags/[tag].astro +37 -0
  128. package/src/pages/tags/[tag].md.ts +34 -0
  129. package/src/pages/tags/index.astro +23 -0
  130. package/src/pages/tags/index.md.ts +27 -0
  131. package/src/pages/words.astro +24 -0
  132. package/src/pages/words.md.ts +14 -0
  133. package/src/plugins/feature-flags.ts +68 -0
  134. package/src/plugins/satteri-temml.ts +81 -0
  135. package/src/schemas/collections.ts +140 -0
  136. package/src/schemas/config.ts +226 -0
  137. package/src/scripts/background.ts +59 -0
  138. package/src/styles/base/init.css +286 -0
  139. package/src/styles/base/math.css +411 -0
  140. package/src/styles/components/archives/archivesList.module.css +378 -0
  141. package/src/styles/components/archives/toArchive.module.css +3 -0
  142. package/src/styles/components/categories/categoriesCard.module.css +87 -0
  143. package/src/styles/components/categories/categoriesList.module.css +27 -0
  144. package/src/styles/components/common/author.module.css +73 -0
  145. package/src/styles/components/common/date.module.css +15 -0
  146. package/src/styles/components/common/textType.module.css +10 -0
  147. package/src/styles/components/footer/footer.module.css +44 -0
  148. package/src/styles/components/layout/navs.module.css +250 -0
  149. package/src/styles/components/links/linkCard.module.css +99 -0
  150. package/src/styles/components/links/linkList.module.css +67 -0
  151. package/src/styles/components/links/socialLinks.module.css +22 -0
  152. package/src/styles/components/markdown.css +528 -0
  153. package/src/styles/components/posts/postAuthor.module.css +32 -0
  154. package/src/styles/components/posts/postCC.module.css +138 -0
  155. package/src/styles/components/posts/postCard.module.css +156 -0
  156. package/src/styles/components/posts/postCategories.module.css +50 -0
  157. package/src/styles/components/posts/postContent.module.css +230 -0
  158. package/src/styles/components/posts/postLayout.module.css +142 -0
  159. package/src/styles/components/posts/postLeft.module.css +38 -0
  160. package/src/styles/components/posts/postList.module.css +24 -0
  161. package/src/styles/components/posts/postNavigation.module.css +187 -0
  162. package/src/styles/components/posts/postRight.module.css +60 -0
  163. package/src/styles/components/posts/postSidebar.module.css +57 -0
  164. package/src/styles/components/posts/postTags.module.css +51 -0
  165. package/src/styles/components/posts/postTaxonomy.module.css +87 -0
  166. package/src/styles/components/posts/postToc.module.css +74 -0
  167. package/src/styles/components/posts/randomPost.module.css +131 -0
  168. package/src/styles/components/tags/tagHeader.module.css +44 -0
  169. package/src/styles/components/tags/tagsCloud.module.css +124 -0
  170. package/src/styles/components/words/wordCard.module.css +130 -0
  171. package/src/styles/components/words/wordList.module.css +39 -0
  172. package/src/styles/pages/archives.module.css +18 -0
  173. package/src/styles/pages/categories.module.css +13 -0
  174. package/src/styles/pages/home.module.css +51 -0
  175. package/src/styles/pages/listPage.module.css +13 -0
  176. package/src/styles/pages/tags.module.css +12 -0
  177. package/src/styles/pages/words.module.css +13 -0
  178. package/src/styles/shared/animations.css +87 -0
  179. package/src/styles/shared/stagger.css +20 -0
  180. package/src/utils/ai-discovery.ts +547 -0
  181. package/src/utils/badge-generator.ts +68 -0
  182. package/src/utils/cc.ts +46 -0
  183. package/src/utils/collections-stats.ts +48 -0
  184. package/src/utils/config-utils.ts +107 -0
  185. package/src/utils/count-words.ts +20 -0
  186. package/src/utils/dayjs.ts +106 -0
  187. package/src/utils/feed.ts +70 -0
  188. package/src/utils/i18n.ts +64 -0
  189. package/src/utils/lucide-icons.ts +52 -0
  190. package/src/utils/semantic-time.ts +11 -0
  191. package/src/utils/taxonomy.ts +44 -0
  192. package/src/utils/toc-scrollspy.ts +95 -0
  193. package/src/utils/waline.ts +27 -0
  194. package/src/utils/word-count-utils.ts +83 -0
  195. package/template/astro.config.mjs +51 -0
  196. package/template/package.json +27 -0
  197. package/template/public/robots.txt +3 -0
  198. package/template/src/content.config.ts +11 -0
  199. package/template/stalux/about/index.md +14 -0
  200. package/template/stalux/config/ai-discovery.yml +2 -0
  201. package/template/stalux/config/author.yml +4 -0
  202. package/template/stalux/config/comment.yml +5 -0
  203. package/template/stalux/config/footer.yml +13 -0
  204. package/template/stalux/config/head.yml +7 -0
  205. package/template/stalux/config/links.yml +4 -0
  206. package/template/stalux/config/media-links.yml +8 -0
  207. package/template/stalux/config/navs.yml +23 -0
  208. package/template/stalux/config/promote.yml +2 -0
  209. package/template/stalux/config/site.yml +7 -0
  210. package/template/stalux/config/typetexts.yml +5 -0
  211. package/template/stalux/posts/hello-stalux.md +47 -0
  212. package/template/stalux/words/_template.md +12 -0
  213. package/template/stalux/words/einstein-imagination.md +8 -0
  214. package/template/tsconfig.json +9 -0
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Stalux 内容集合定义辅助
3
+ *
4
+ * 用户在 `src/content.config.ts` 中使用此函数快速配置内容集合,
5
+ * 支持自定义内容目录路径。
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // src/content.config.ts
10
+ * import { defineCollections } from "stalux/schemas";
11
+ *
12
+ * export const collections = defineCollections({
13
+ * contentDir: "./stalux", // 默认为 "./stalux"
14
+ * });
15
+ * ```
16
+ */
17
+
18
+ import { configSchema } from "./config";
19
+ import { defineCollection } from "astro:content";
20
+ import { glob } from "astro/loaders";
21
+ import { z } from "astro/zod";
22
+
23
+ // ---------------------------------------------------------------------------
24
+ // 集合配置选项
25
+ // ---------------------------------------------------------------------------
26
+
27
+ export interface CollectionPaths {
28
+ /** 内容根目录(默认 "stalux") */
29
+ contentDir?: string;
30
+ }
31
+
32
+ // ---------------------------------------------------------------------------
33
+ // 文章 Schema
34
+ // ---------------------------------------------------------------------------
35
+
36
+ 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(),
67
+ });
68
+
69
+ // ---------------------------------------------------------------------------
70
+ // 定义集合
71
+ // ---------------------------------------------------------------------------
72
+
73
+ /**
74
+ * 快速配置 Stalux 所需的四个内容集合(posts / config / about / words)。
75
+ *
76
+ * @param paths - 内容目录路径配置
77
+ * @returns 四个内容集合,可直接在 `src/content.config.ts` 中导出
78
+ */
79
+ export function defineCollections(paths: CollectionPaths = {}) {
80
+ const root = paths.contentDir ?? "stalux";
81
+
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
+ });
92
+
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
+ });
101
+
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
+ });
113
+
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
+ });
133
+
134
+ return { posts, config, about, words };
135
+ }
136
+
137
+ /**
138
+ * 默认内容集合(使用 "stalux" 作为内容根目录)
139
+ */
140
+ export const collections = defineCollections({ contentDir: "stalux" });
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Config 集合的 Zod Schema 定义
3
+ *
4
+ * 每个 config/*.yml 文件对应一个独立的 schema,
5
+ * 通过 z.discriminatedUnion("id") 联合为 config 集合。
6
+ */
7
+ import { z } from "astro/zod";
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // 子 Schema(每个对应一个 config/*.yml 文件)
11
+ // ---------------------------------------------------------------------------
12
+
13
+ export const siteSchema = z.object({
14
+ id: z.literal("site"),
15
+ lang: z.string().optional().default("zh-CN"),
16
+ title: z.string().min(1, "site.title is required"),
17
+ url: z.string().url("site.url must be a valid URL"),
18
+ description: z.string().min(1, "site.description is required"),
19
+ timezone: z.string().optional().default("Asia/Shanghai"),
20
+ canonical: z.string().url("site.canonical must be a valid URL").optional(),
21
+ twitterSite: z.string().optional(),
22
+ noindex: z.boolean().optional().default(false),
23
+ nofollow: z.boolean().optional().default(false),
24
+ favicon: z.string().optional().default("/favicon.ico"),
25
+ });
26
+
27
+ export const authorSchema = z.object({
28
+ id: z.literal("author"),
29
+ name: z.string().min(1, "author.name is required"),
30
+ avatar: z.string().min(1, "author.avatar is required"),
31
+ bio: z.string().min(1, "author.bio is required"),
32
+ });
33
+
34
+ export const headSchema = z.object({
35
+ id: z.literal("head"),
36
+ googleAnalyticsId: z.string().optional(),
37
+ bingClarityId: z.string().optional(),
38
+ umami: z
39
+ .object({
40
+ id: z.string().optional(),
41
+ url: z.string().optional(),
42
+ })
43
+ .optional(),
44
+ anyhead: z.string().optional(),
45
+ });
46
+
47
+ export const typetextsSchema = z.object({
48
+ id: z.literal("typetexts"),
49
+ items: z.array(z.string()),
50
+ });
51
+
52
+ export const navsSchema = z.object({
53
+ id: z.literal("navs"),
54
+ items: z.array(
55
+ z.object({
56
+ title: z.string().min(1, "navs[].title is required"),
57
+ icon: z.string().min(1, "navs[].icon is required"),
58
+ link: z.string().min(1, "navs[].link is required"),
59
+ }),
60
+ ),
61
+ });
62
+
63
+ export const mediaLinksSchema = z.object({
64
+ id: z.literal("media-links"),
65
+ items: z.array(
66
+ z.object({
67
+ icon: z.string().min(1, "mediaLinks[].icon is required"),
68
+ link: z.string().min(1, "mediaLinks[].link is required"),
69
+ }),
70
+ ),
71
+ });
72
+
73
+ export const linksSchema = z.object({
74
+ id: z.literal("links"),
75
+ title: z.string().min(1, "links.title is required"),
76
+ description: z.string(),
77
+ sites: z.array(
78
+ z.object({
79
+ name: z.string().min(1, "links.sites[].name is required"),
80
+ description: z.string(),
81
+ icon: z.string().min(1, "links.sites[].icon is required"),
82
+ link: z.string().min(1, "links.sites[].link is required"),
83
+ }),
84
+ ),
85
+ });
86
+
87
+ const badgeFlatSchema = z.object({
88
+ label: z.string().min(1, "badges[].label is required"),
89
+ message: z.string().min(1, "badges[].message is required"),
90
+ color: z.string().optional(),
91
+ style: z.string().optional(),
92
+ alt: z.string().optional(),
93
+ href: z.string().optional(),
94
+ });
95
+
96
+ const badgeGroupSchema = z.object({
97
+ title: z.string().min(1, "badge group title is required"),
98
+ collapsed: z.boolean().optional().default(true),
99
+ items: z.array(badgeFlatSchema),
100
+ });
101
+
102
+ export const footerSchema = z.object({
103
+ id: z.literal("footer"),
104
+ buildtime: z.string().optional(),
105
+ copyright: z
106
+ .object({
107
+ enabled: z.boolean().optional().default(true),
108
+ startYear: z.number().optional(),
109
+ customText: z.string().optional(),
110
+ })
111
+ .optional(),
112
+ theme: z
113
+ .object({
114
+ showPoweredBy: z.boolean().optional().default(true),
115
+ showThemeInfo: z.boolean().optional().default(true),
116
+ })
117
+ .optional(),
118
+ beian: z
119
+ .object({
120
+ icp: z
121
+ .object({
122
+ enabled: z.boolean().optional().default(false),
123
+ number: z.string().optional(),
124
+ })
125
+ .optional(),
126
+ security: z
127
+ .object({
128
+ enabled: z.boolean().optional().default(false),
129
+ text: z.string().optional(),
130
+ number: z.string().optional(),
131
+ })
132
+ .optional(),
133
+ })
134
+ .optional(),
135
+ badges: z.array(z.union([badgeFlatSchema, badgeGroupSchema])).optional(),
136
+ custom: z.string().optional(),
137
+ });
138
+
139
+ export const aiDiscoverySchema = z.object({
140
+ id: z.literal("ai-discovery"),
141
+ conformance: z
142
+ .enum(["disabled", "essential", "recommended", "complete"])
143
+ .optional()
144
+ .default("complete"),
145
+ permissions_text: z.array(z.string()).optional(),
146
+ restrictions_text: z.array(z.string()).optional(),
147
+ attribution_text: z.string().optional(),
148
+ contact_text: z.string().optional(),
149
+ });
150
+
151
+ export const commentSchema = z.object({
152
+ id: z.literal("comment"),
153
+ enabled: z.boolean().optional().default(false),
154
+ waline: z
155
+ .object({
156
+ serverURL: z.string().url("comment.waline.serverURL must be a valid URL").optional(),
157
+ lang: z.string().optional().default("zh-CN"),
158
+ locale: z.any().optional(),
159
+ emoji: z
160
+ .array(z.string())
161
+ .optional()
162
+ .default([
163
+ "https://unpkg.com/@waline/emojis@1.1.0/bilibili",
164
+ "https://unpkg.com/@waline/emojis@1.1.0/bmoji",
165
+ ]),
166
+ reaction: z.boolean().optional().default(false),
167
+ meta: z.array(z.string()).optional().default(["nick", "mail", "link"]),
168
+ requiredMeta: z.array(z.string()).optional().default([]),
169
+ login: z.string().optional().default("enable"),
170
+ recaptchaV3Key: z.string().optional(),
171
+ turnstileKey: z.string().optional(),
172
+ dark: z.union([z.string(), z.boolean()]).optional().default(true),
173
+ noCopyright: z.boolean().optional().default(false),
174
+ commentSorting: z.string().optional().default("latest"),
175
+ imageUploader: z.any().optional(),
176
+ highlighter: z.any().optional(),
177
+ texRenderer: z.any().optional(),
178
+ search: z.any().optional(),
179
+ wordLimit: z.number().optional().default(200),
180
+ pageSize: z.number().optional().default(10),
181
+ })
182
+ .optional(),
183
+ });
184
+
185
+ export const promoteSchema = z.object({
186
+ id: z.literal("promote"),
187
+ llm_promote: z.string().optional(),
188
+ export_md: z.boolean().optional().default(false),
189
+ });
190
+
191
+ // ---------------------------------------------------------------------------
192
+ // 联合 Schema(内容集合使用)
193
+ // ---------------------------------------------------------------------------
194
+
195
+ export const configSchema = z.discriminatedUnion("id", [
196
+ siteSchema,
197
+ authorSchema,
198
+ headSchema,
199
+ navsSchema,
200
+ typetextsSchema,
201
+ mediaLinksSchema,
202
+ linksSchema,
203
+ footerSchema,
204
+ aiDiscoverySchema,
205
+ commentSchema,
206
+ promoteSchema,
207
+ ]);
208
+
209
+ // ---------------------------------------------------------------------------
210
+ // 推导的 TypeScript 类型
211
+ // ---------------------------------------------------------------------------
212
+
213
+ type ConfigData = z.infer<typeof configSchema>;
214
+
215
+ // 按 id 提取的具体类型
216
+ export type SiteData = Extract<ConfigData, { id: "site" }>;
217
+ export type AuthorData = Extract<ConfigData, { id: "author" }>;
218
+ export type HeadData = Extract<ConfigData, { id: "head" }>;
219
+ export type NavsData = Extract<ConfigData, { id: "navs" }>;
220
+ export type TypetextsData = Extract<ConfigData, { id: "typetexts" }>;
221
+ export type MediaLinksData = Extract<ConfigData, { id: "media-links" }>;
222
+ export type LinksData = Extract<ConfigData, { id: "links" }>;
223
+ export type FooterData = Extract<ConfigData, { id: "footer" }>;
224
+ export type AiDiscoveryData = Extract<ConfigData, { id: "ai-discovery" }>;
225
+ export type CommentData = Extract<ConfigData, { id: "comment" }>;
226
+ export type PromoteData = Extract<ConfigData, { id: "promote" }>;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * 双层随机背景 — 每页服务端随机选图直接渲染,不做 VT crossfade
3
+ * (去掉 view-transition-name 避免 SVG 全屏瓦片在过渡期间双倍 CPU 光栅化)
4
+ */
5
+ declare global {
6
+ interface Window {
7
+ __STALUX_BG_URLS__?: string[];
8
+ __STALUX_BG_INDEX__?: number;
9
+ }
10
+ }
11
+
12
+ const backgroundImages: string[] = window.__STALUX_BG_URLS__ || [];
13
+ const initialIndexFromSSR =
14
+ typeof window.__STALUX_BG_INDEX__ === "number" ? window.__STALUX_BG_INDEX__ : -1;
15
+
16
+ function getLayerEl(layer: "a" | "b"): HTMLElement | null {
17
+ return document.querySelector(`.bg-layer.bg-${layer}`);
18
+ }
19
+
20
+ function setLayerOpacity(layer: "a" | "b", opacity: number): void {
21
+ const el = getLayerEl(layer);
22
+ if (el) el.style.opacity = String(opacity);
23
+ }
24
+
25
+ function initBackground(): void {
26
+ if (initialIndexFromSSR >= 0 && backgroundImages.length > 0) {
27
+ // 服务端已预填充 bg-a,只需确保状态一致
28
+ document.body.dataset.staluxBgIndex = String(initialIndexFromSSR);
29
+ document.body.dataset.staluxBgLayer = "a";
30
+ setLayerOpacity("a", 1);
31
+ setLayerOpacity("b", 0);
32
+ } else {
33
+ // Fallback:客户端自行初始化
34
+ const index = Math.floor(Math.random() * backgroundImages.length);
35
+ const layer: "a" | "b" = "a";
36
+ if (backgroundImages.length > 0) {
37
+ const el = getLayerEl(layer);
38
+ if (el) el.style.backgroundImage = `url('${backgroundImages[index]}')`;
39
+ }
40
+ setLayerOpacity(layer, 1);
41
+ setLayerOpacity("b", 0);
42
+ document.body.dataset.staluxBgIndex = String(index);
43
+ document.body.dataset.staluxBgLayer = layer;
44
+ }
45
+ }
46
+
47
+ // 初始化(首次加载 + VT 软导航都走这里)
48
+ document.addEventListener("astro:page-load", () => {
49
+ const layer = document.body.dataset.staluxBgLayer as "a" | "b" | undefined;
50
+ const indexStr = document.body.dataset.staluxBgIndex;
51
+
52
+ if (layer && indexStr !== undefined) {
53
+ // View Transition 后:新页面服务端已渲染正确的背景,直接同步状态
54
+ setLayerOpacity(layer, 1);
55
+ setLayerOpacity(layer === "a" ? "b" : "a", 0);
56
+ } else {
57
+ initBackground();
58
+ }
59
+ });
@@ -0,0 +1,286 @@
1
+ /* 全局设置 */
2
+ html,
3
+ body {
4
+ margin: 0;
5
+ width: 100%;
6
+ height: 100%;
7
+ color: white;
8
+ main {
9
+ flex: 1;
10
+ }
11
+ scrollbar-color: #4a4a4a #2a2a2a;
12
+ display: block;
13
+ font-family:
14
+ var(--font-body),
15
+ "Noto Sans SC",
16
+ "Noto Sans CJK SC",
17
+ system-ui,
18
+ -apple-system,
19
+ sans-serif;
20
+ -webkit-font-smoothing: antialiased;
21
+ -moz-osx-font-smoothing: grayscale;
22
+ text-rendering: optimizeLegibility;
23
+ }
24
+
25
+ html[data-clarity-id] {
26
+ opacity: 1 !important;
27
+ }
28
+ /* 将所有链接初始化为无视觉状态,但保留键盘可见焦点 */
29
+ a {
30
+ color: inherit;
31
+ text-decoration: none;
32
+ background-color: transparent;
33
+ cursor: pointer;
34
+ text-decoration-skip-ink: auto;
35
+ }
36
+
37
+ .a-none {
38
+ color: inherit !important;
39
+ text-decoration: none !important;
40
+ background-color: transparent;
41
+ cursor: pointer;
42
+ text-decoration-skip-ink: auto;
43
+ }
44
+
45
+ .a-none::after {
46
+ display: none !important;
47
+ }
48
+
49
+ a {
50
+ position: relative;
51
+ transition:
52
+ color 0.2s ease,
53
+ text-shadow 0.2s ease;
54
+ }
55
+
56
+ /* 下划线动画 */
57
+ a::after {
58
+ content: "";
59
+ position: absolute;
60
+ left: 0;
61
+ bottom: -2px;
62
+ height: 1px;
63
+ width: 100%;
64
+ background: linear-gradient(90deg, var(--stalux-accent-color), rgba(100, 255, 218, 0.5));
65
+ transform: scaleX(0);
66
+ transform-origin: left;
67
+ transition: transform 0.25s cubic-bezier(0.25, 0.9, 0.2, 1);
68
+ pointer-events: none;
69
+ }
70
+
71
+ a:hover::after,
72
+ a:focus-visible::after,
73
+ a:active::after {
74
+ transform: scaleX(1);
75
+ }
76
+
77
+ a:hover,
78
+ a:active,
79
+ a:focus-visible {
80
+ text-decoration: none;
81
+ /* 保持颜色不变,避免 hover 时颜色跳变 */
82
+ }
83
+
84
+ a:focus {
85
+ outline: none;
86
+ }
87
+
88
+ a:focus-visible {
89
+ outline: 2px solid var(--stalux-accent-color);
90
+ outline-offset: 2px;
91
+ }
92
+ ul {
93
+ list-style: none;
94
+ padding: 0;
95
+ margin: 0;
96
+ }
97
+ .none {
98
+ display: none;
99
+ }
100
+ /* 布局:使 body 成为列 flex 容器,并让 main 填充可用高度 */
101
+ .stalux-root {
102
+ display: flex;
103
+ flex-direction: column;
104
+ min-height: 100vh;
105
+ color: white; /* 默认文本颜色,适用于深色背景 */
106
+ }
107
+
108
+ /* 默认 stalux 背景的 CSS 变量(非动态默认值) */
109
+ :root {
110
+ --stalux-bg-color: #202020;
111
+ --stalux-bg-filter: none;
112
+ --stalux-text-shadow: #64ffda 0.1rem 0.1rem 0.2rem;
113
+ --stalux-accent-color: #64ffda;
114
+ --stalux-search-backdrop: rgba(0, 0, 0, 0.1);
115
+ --stalux-search-box-bg: rgba(0, 0, 0, 0.1);
116
+ --stalux-search-border: rgba(0, 0, 0, 0.2);
117
+
118
+ /* 卡片和标签颜色 Token(可在这里统一调整主题色/透明度) */
119
+ --card-bg: rgba(0, 0, 0, 0.2);
120
+ --card-border: rgba(255, 255, 255, 0.1);
121
+ --card-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
122
+ --card-box-shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.5);
123
+
124
+ --tag-bg: rgba(255, 255, 255, 0.12);
125
+ --tag-bg-hover: rgba(255, 255, 255, 0.18);
126
+ --category-bg: rgba(255, 255, 255, 0.08);
127
+ --category-bg-hover: rgba(255, 255, 255, 0.14);
128
+
129
+ --date-bg: rgba(66, 160, 255, 0.18);
130
+ --date-border: rgba(66, 160, 255, 0.25);
131
+ --updated-bg: rgba(255, 201, 71, 0.2);
132
+ --updated-border: rgba(255, 201, 71, 0.3);
133
+
134
+ /* 常用颜色值 */
135
+ --white-full: #ffffff;
136
+ --white-95p: rgba(255, 255, 255, 0.95);
137
+ --white-90p: rgba(255, 255, 255, 0.9);
138
+ --white-85p: rgba(255, 255, 255, 0.85);
139
+ --white-80p: rgba(255, 255, 255, 0.8);
140
+ --white-78p: rgba(255, 255, 255, 0.78);
141
+ --white-75p: rgba(255, 255, 255, 0.75);
142
+ --white-70p: rgba(255, 255, 255, 0.7);
143
+ --white-60p: rgba(255, 255, 255, 0.6);
144
+ --white-50p: rgba(255, 255, 255, 0.5);
145
+ --white-30p: rgba(255, 255, 255, 0.3);
146
+ --white-20p: rgba(255, 255, 255, 0.2);
147
+ --white-15p: rgba(255, 255, 255, 0.15);
148
+ --white-12p: rgba(255, 255, 255, 0.12);
149
+ --white-10p: rgba(255, 255, 255, 0.1);
150
+ --white-8p: rgba(255, 255, 255, 0.08);
151
+ --white-05p: rgba(255, 255, 255, 0.05);
152
+
153
+ --black-full: #000000;
154
+ --black-30p: rgba(0, 0, 0, 0.3);
155
+ --black-28p: rgba(0, 0, 0, 0.28);
156
+ --black-20p: rgba(0, 0, 0, 0.2);
157
+ --black-15p: rgba(0, 0, 0, 0.15);
158
+ --black-10p: rgba(0, 0, 0, 0.1);
159
+ --black-05p: rgba(0, 0, 0, 0.05);
160
+ --black-03p: rgba(0, 0, 0, 0.03);
161
+
162
+ /* 强调色变体 */
163
+ --accent-90p: rgba(100, 255, 218, 0.9);
164
+ --accent-85p: rgba(100, 255, 218, 0.85);
165
+ --accent-80p: rgba(100, 255, 218, 0.8);
166
+ --accent-70p: rgba(100, 255, 218, 0.7);
167
+ --accent-60p: rgba(100, 255, 218, 0.6);
168
+ --accent-50p: rgba(100, 255, 218, 0.5);
169
+ --accent-40p: rgba(100, 255, 218, 0.4);
170
+ --accent-30p: rgba(100, 255, 218, 0.3);
171
+ --accent-20p: rgba(100, 255, 218, 0.2);
172
+ --accent-10p: rgba(100, 255, 218, 0.1);
173
+
174
+ /* 常用过渡和动画 */
175
+ --transition-fast: 0.18s ease;
176
+ --transition-medium: 0.2s ease;
177
+ --transition-normal: 0.25s ease;
178
+ --transition-slow: 0.3s ease;
179
+ --transition-slower: 0.5s ease;
180
+ --transition-slowest: 0.6s ease;
181
+
182
+ --easing-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
183
+ --easing-smooth: cubic-bezier(0.25, 0.9, 0.2, 1);
184
+
185
+ /* 常用间距值 */
186
+ --space-2xs: 0.25rem;
187
+ --space-xs: 0.75rem;
188
+ --space-sm: 0.5rem;
189
+ --space-md: 1rem;
190
+ --space-lg: 1.5rem;
191
+ --space-xl: 2rem;
192
+ --space-2xl: 3rem;
193
+ --space-3xl: 4rem;
194
+
195
+ /* 常用圆角半径值 */
196
+ --radius-sm: 4px;
197
+ --radius-md: 6px;
198
+ --radius-lg: 8px;
199
+ --radius-xl: 10px;
200
+ --radius-full: 9999px;
201
+ --radius-circle: 50%;
202
+
203
+ /* 常用阴影 */
204
+ --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.1);
205
+ --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.2);
206
+ --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.3);
207
+ --shadow-xl: 0 12px 26px rgba(0, 0, 0, 0.28);
208
+ --shadow-sidebar: 0 4px 6px rgba(0, 0, 0, 0.753);
209
+ --shadow-dark: rgba(0, 0, 0, 0.753);
210
+
211
+ /* 语义化颜色 */
212
+ --date-text-color: #e8f2ff;
213
+ --updated-text-color: #fff7de;
214
+ --muted-text: #bbb;
215
+ --border-color-light: #e5e5e5;
216
+
217
+ /* 字体族栈 */
218
+ /* --font-body 由 Astro Fonts API 生成(见 astro.config.mjs fonts 配置) */
219
+ --font-body-serif: "Noto Serif CJK SC", "Source Han Serif SC", "STSong", Georgia, serif;
220
+
221
+ /* 字体大小系统 */
222
+ --font-size-title: 2.8rem;
223
+ --font-size-h2: 2rem;
224
+ --font-size-subtitle: 1.35rem;
225
+ --font-size-base: 1.1rem;
226
+ --font-size-small: 0.95rem;
227
+ --font-size-smaller: 0.9rem;
228
+ --font-size-tiny: 0.85rem;
229
+
230
+ /* 边框宽度 */
231
+ --border-thin: 1px;
232
+ --border-medium: 2px;
233
+ --border-thick: 3px;
234
+ --border-thicker: 4px;
235
+ }
236
+ ::-webkit-scrollbar {
237
+ width: 8px;
238
+ height: 8px;
239
+ }
240
+
241
+ ::-webkit-scrollbar-track {
242
+ background: #2a2a2a;
243
+ border-radius: 4px;
244
+ }
245
+
246
+ ::-webkit-scrollbar-thumb {
247
+ background: #4a4a4a;
248
+ border-radius: 4px;
249
+ transition: background 0.3s ease-out;
250
+ }
251
+
252
+ ::-webkit-scrollbar-thumb:hover {
253
+ background: #5a5a5a;
254
+ }
255
+
256
+ ::-webkit-scrollbar-corner {
257
+ background: #2a2a2a;
258
+ }
259
+
260
+ /* 背景层 - 双层随机背景(不在 View Transition 中 crossfade,避免 SVG 双倍光栅化卡顿) */
261
+ .bg-layer {
262
+ position: fixed;
263
+ inset: 0;
264
+ z-index: -10;
265
+ background-repeat: repeat;
266
+ background-size: auto;
267
+ background-position: center;
268
+ background-color: var(--stalux-bg-color, transparent);
269
+ filter: var(--stalux-bg-filter, none);
270
+ pointer-events: none;
271
+ opacity: 0;
272
+ /* 禁止浏览器强制色彩模式(高对比度/暗黑模式)调整背景图颜色 */
273
+ forced-color-adjust: none;
274
+ /* 关键:防止 Safari/WebKit 在暗色模式下自动调整 SVG 背景图颜色 */
275
+ color-scheme: only light;
276
+ }
277
+
278
+ /* footer 基础样式,保证页脚始终可见且不覆盖内容 */
279
+ footer {
280
+ padding: var(--space-lg) var(--space-md);
281
+ text-align: center;
282
+ color: var(--muted-text);
283
+ background: transparent;
284
+ position: relative;
285
+ z-index: 1;
286
+ }