@xingwangzhe/stalux 1.5.1 → 1.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingwangzhe/stalux",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "A powerful, modern Astro blog theme \u2014 use as template or install as plugin",
5
5
  "keywords": [
6
6
  "astro",
package/src/index.ts CHANGED
@@ -226,6 +226,7 @@ export function stalux(options: StaluxOptions = {}): AstroIntegration {
226
226
  await runFontSubsetting(projectRoot, logger, true);
227
227
  // 再添加按需路由切片中间件(放在最前面,优先拦截字体请求)
228
228
  const { createDevFontMiddleware } = await import(
229
+ /* @vite-ignore */
229
230
  new URL("./internal/font-subset-dev.ts", import.meta.url).href
230
231
  );
231
232
  const fontMiddleware = createDevFontMiddleware(projectRoot, logger);
@@ -12,7 +12,6 @@ import { resolve, join, dirname } from "node:path";
12
12
  import { fileURLToPath } from "node:url";
13
13
 
14
14
  import type { AstroIntegrationLogger } from "astro";
15
- import * as taetype from "taetype";
16
15
  import { register_font_raw, get_glyph_ids, subset_font_full } from "taetype";
17
16
 
18
17
  const FONT_INPUT = "src/assets/fonts/LXGWWenKai-Regular.ttf";
@@ -99,10 +98,8 @@ async function generateSubsetOnDemand(
99
98
  for (const ch of chars) charSet.add(ch);
100
99
  if (charSet.size === 0) return null;
101
100
 
102
- // Deduplicate against common subset: read common.css to find its referenced WOFF2
101
+ // Deduplicate against common subset
103
102
  const outDir = resolve(projectRoot, FONT_OUT_DIR);
104
- const commonCssPath = join(outDir, "common.css");
105
- const commonCharSet = new Set<string>();
106
103
 
107
104
  // We can't precisely know which chars common covers without re-extracting.
108
105
  // But we can read the i18n + config source for a rough estimate.
@@ -21,8 +21,6 @@ import { resolve, basename, extname, join, dirname } from "node:path";
21
21
  import { fileURLToPath } from "node:url";
22
22
 
23
23
  import type { AstroIntegrationLogger } from "astro";
24
- // taetype 是 Rust 原生字体引擎,比 subset-font (WASM) 快 2-3 倍
25
- import * as taetype from "taetype";
26
24
  import { register_font_raw, get_glyph_ids, subset_font_full } from "taetype";
27
25
 
28
26
  // ---------------------------------------------------------------------------
@@ -206,6 +204,21 @@ function collectCommonChars(projectRoot: string): string {
206
204
  }
207
205
  }
208
206
 
207
+ // Also scan post frontmatter for tags, categories so those pages' chars are covered
208
+ const postsDir = resolve(projectRoot, CONTENT_ROOT, "posts");
209
+ if (existsSync(postsDir)) {
210
+ for (const f of readdirSync(postsDir)) {
211
+ if (!f.endsWith(".md") && !f.endsWith(".mdx")) continue;
212
+ if (f.startsWith("_")) continue;
213
+ try {
214
+ const content = readFileSync(join(postsDir, f), "utf-8");
215
+ for (const ch of content) chars.add(ch);
216
+ } catch {
217
+ /* skip */
218
+ }
219
+ }
220
+ }
221
+
209
222
  return [...chars].sort().join("");
210
223
  }
211
224
 
@@ -13,7 +13,7 @@ const { t } = createTranslator(siteConfig.lang || "zh-CN");
13
13
  <Stalux
14
14
  title={t("page404.title") + " | " + siteConfig.title}
15
15
  description={t("page404.description")}
16
- fontSubsetId="common"
16
+
17
17
  >
18
18
  <div style="height: 3em;"></div>
19
19
  <Navs />
@@ -12,7 +12,7 @@ const { t } = createTranslator(siteConfig.lang || "zh-CN");
12
12
  const posts = await getCollection("posts", ({ data }) => !data.draft);
13
13
  ---
14
14
 
15
- <Stalux title={t("archives.title") + " | " + siteConfig.title} description={t("archives.description", { title: siteConfig.title })} fontSubsetId="archives">
15
+ <Stalux title={t("archives.title") + " | " + siteConfig.title} description={t("archives.description", { title: siteConfig.title })}>
16
16
  <div style="height: 3em;"></div>
17
17
  <Navs />
18
18
  <h1 class={styles.h1}>{t("archives.heading")}</h1>
@@ -27,7 +27,7 @@ const props = Astro.props as Props;
27
27
  <Stalux
28
28
  title={t("taxonomy.category") + ": " + props.category + " | " + siteConfig.title}
29
29
  description={t("taxonomy.browseCategory", { title: siteConfig.title, category: props.category, count: props.count })}
30
- fontSubsetId="categories"
30
+
31
31
  >
32
32
  <div style="height: 3em;"></div>
33
33
  <Navs />
@@ -14,7 +14,7 @@ const { t } = createTranslator(siteConfig.lang || "zh-CN");
14
14
  <Stalux
15
15
  title={t("categories.title") + " | " + siteConfig.title}
16
16
  description={t("categories.description", { title: siteConfig.title })}
17
- fontSubsetId="categories"
17
+
18
18
  >
19
19
  <div style="height: 3em;"></div>
20
20
  <Navs />
@@ -15,7 +15,7 @@ import ToArchive from "@components/stalux/archives/toArchive.astro";
15
15
  import { getSiteData, getAuthorData, getHeadData, getNavsData, getLinksData, getCommentData, getFooterData, getPromoteData, getTypetextsData, getMediaLinksData } from "@utils/config-utils";
16
16
  ---
17
17
 
18
- <Stalux title={siteTitle} description={siteDescription} fontSubsetId="home">
18
+ <Stalux title={siteTitle} description={siteDescription}>
19
19
  <div class={styles.homeBody}>
20
20
  <h1 class={styles.homeTitle}>{siteTitle}</h1>
21
21
  <div class={styles.homeNavs}>
@@ -18,7 +18,7 @@ const linksDescription = linksConfig.description;
18
18
  description={siteDescription}
19
19
  heading={linksTitle}
20
20
  subheading={linksDescription}
21
- fontSubsetId="links"
21
+
22
22
  >
23
23
  <LinkList />
24
24
  </ListPage>
@@ -29,7 +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
34
  <div style="height: 3em;"></div>
35
35
  <Navs />
@@ -14,7 +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
19
  <div style="height: 3em;"></div>
20
20
  <Navs />