@xingwangzhe/stalux 1.6.1 → 1.6.2

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.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "A powerful, modern Astro blog theme — use as template or install as plugin",
5
5
  "keywords": [
6
6
  "astro",
@@ -90,24 +90,38 @@ function getRouteChars(projectRoot: string, subsetId: string): string | null {
90
90
  return getCategoryContent(contentRoot, catName);
91
91
  }
92
92
 
93
- // ── Other HTML routes (home, links, 404) ──
94
- // These pages use i18n text + config YAML text, which are already
95
- // covered by the common subset. Return config text for extra safety.
96
- if (["home", "links", "common"].includes(subsetId)) {
97
- const configDir = join(contentRoot, "config");
98
- if (!existsSync(configDir)) return null;
99
- const all: string[] = [];
100
- for (const f of readdirSync(configDir)) {
101
- if (f.endsWith(".yml") || f.endsWith(".yaml")) {
102
- all.push(readFileSync(join(configDir, f), "utf-8"));
103
- }
104
- }
105
- return all.join("\n") || null;
93
+ // ── Home page ───────────────────────────────────────────
94
+ if (subsetId === "home") {
95
+ return getAllConfigContent(contentRoot);
96
+ }
97
+
98
+ // ── Links page ──────────────────────────────────────────
99
+ if (subsetId === "links") {
100
+ return getAllConfigContent(contentRoot);
101
+ }
102
+
103
+ // ── Other HTML routes (common) ──
104
+ // The common subset includes UI text from source + config YAML
105
+ if (subsetId === "common") {
106
+ return getAllConfigContent(contentRoot);
106
107
  }
107
108
 
108
109
  return null;
109
110
  }
110
111
 
112
+ /** Get all config YAML content */
113
+ function getAllConfigContent(contentRoot: string): string | null {
114
+ const configDir = join(contentRoot, "config");
115
+ if (!existsSync(configDir)) return null;
116
+ const all: string[] = [];
117
+ for (const f of readdirSync(configDir)) {
118
+ if (f.endsWith(".yml") || f.endsWith(".yaml")) {
119
+ all.push(readFileSync(join(configDir, f), "utf-8"));
120
+ }
121
+ }
122
+ return all.join("\n") || null;
123
+ }
124
+
111
125
  /** Get all post content concatenated (including template/_ files) */
112
126
  function getAllPostContent(contentRoot: string): string | null {
113
127
  const postsDir = join(contentRoot, "posts");
@@ -181,6 +181,25 @@ function scanContent(projectRoot: string): ContentFile[] {
181
181
  }
182
182
  }
183
183
 
184
+ // Build virtual routes for config-driven pages (home, links)
185
+ // These pages render text from config YAML files (nav titles, site title, etc.)
186
+ const configDir = join(contentRoot, "config");
187
+ if (existsSync(configDir)) {
188
+ const allConfigContent: string[] = [];
189
+ for (const f of readdirSync(configDir)) {
190
+ if (f.endsWith(".yml") || f.endsWith(".yaml")) {
191
+ allConfigContent.push(readFileSync(join(configDir, f), "utf-8"));
192
+ }
193
+ }
194
+ if (allConfigContent.length > 0) {
195
+ const configText = allConfigContent.join("\n");
196
+ // Home page: site title, author, navs, typetexts, social media, footer
197
+ virtualRouteCache.set("home", extractChars(configText));
198
+ // Links page: links config + navs + footer
199
+ virtualRouteCache.set("links", extractChars(configText));
200
+ }
201
+ }
202
+
184
203
  // About
185
204
  const aboutDir = join(contentRoot, "about");
186
205
  if (existsSync(aboutDir)) {
@@ -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}>
18
+ <Stalux title={siteTitle} description={siteDescription} fontSubsetId="home">
19
19
  <div class={styles.homeBody}>
20
20
  <h1 class={styles.homeTitle}>{siteTitle}</h1>
21
21
  <div class={styles.homeNavs}>
@@ -13,12 +13,12 @@ const linksTitle = linksConfig.title;
13
13
  const linksDescription = linksConfig.description;
14
14
  ---
15
15
 
16
- <ListPage
17
- title={siteTitle}
18
- description={siteDescription}
19
- heading={linksTitle}
20
- subheading={linksDescription}
21
-
22
- >
16
+ <ListPage
17
+ title={siteTitle}
18
+ description={siteDescription}
19
+ heading={linksTitle}
20
+ subheading={linksDescription}
21
+ fontSubsetId="links"
22
+ >
23
23
  <LinkList />
24
24
  </ListPage>