@xingwangzhe/stalux 1.29.4 → 1.29.6
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 +1 -1
- package/package.json +4 -3
- package/src/index.ts +52 -2
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ bunx stalux init # Generate stalux/ content directory
|
|
|
26
26
|
Requires Node.js 26 or later. Then configure `astro.config.ts`. All plugins are bundled into the Stalux integration by default — **no manual configuration is needed**:
|
|
27
27
|
|
|
28
28
|
- **Markdown**: Mermaid (MDAST detection + HAST/SVG rendering), math formulas (Temml → MathML), word count / feature flags, and PhotoSwipe image lightbox are injected into the default `satteri()` processor automatically (math / frontmatter / gfm / smart punctuation are enabled by default).
|
|
29
|
-
- **Sitemap**: `@astrojs/sitemap` is bundled (
|
|
29
|
+
- **Sitemap**: `@astrojs/sitemap` is bundled (published post `/posts/*.md` endpoints are included when `promote.export_md` is enabled; other Markdown mirrors stay filtered by default).
|
|
30
30
|
- **Expressive Code**: bundled with line numbers enabled by default.
|
|
31
31
|
|
|
32
32
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xingwangzhe/stalux",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.6",
|
|
4
4
|
"description": "A powerful, modern Astro blog theme — use as template or install as plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"@lucide/astro": "^1.47.0",
|
|
101
101
|
"@mcp-b/webmcp-polyfill": "^5.1.0",
|
|
102
102
|
"@pagefind/component-ui": "^1.5.2",
|
|
103
|
-
"@waline/client": "
|
|
103
|
+
"@waline/client": "3.16.0",
|
|
104
104
|
"@xingwangzhe/cjk-font-split-native": "0.2.0",
|
|
105
105
|
"@xingwangzhe/satteri-mermaid": "0.7.8",
|
|
106
106
|
"@xingwangzhe/satteri-photoswipe": "^0.2.5",
|
|
@@ -114,7 +114,8 @@
|
|
|
114
114
|
"photoswipe": "^5.4.4",
|
|
115
115
|
"satteri": "^0.10.5",
|
|
116
116
|
"simple-icons": "^16.32.0",
|
|
117
|
-
"temml": "^0.13.5"
|
|
117
|
+
"temml": "^0.13.5",
|
|
118
|
+
"yaml": "^2.9.1"
|
|
118
119
|
},
|
|
119
120
|
"devDependencies": {
|
|
120
121
|
"@astrojs/check": "0.9.10",
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { fontProviders } from "astro/config";
|
|
|
27
27
|
// pagefind 是 ESM-only 包,需要在模块顶层导入
|
|
28
28
|
// 因为 astro:build:done 钩子中 Vite module runner 已关闭,无法动态 import
|
|
29
29
|
import { createIndex as pagefindCreateIndex } from "pagefind";
|
|
30
|
+
import { parse as parseYaml } from "yaml";
|
|
30
31
|
import type { StaluxOptions } from "./config";
|
|
31
32
|
import { expressiveCode } from "./expressive-code";
|
|
32
33
|
import { staluxComponentsAlias } from "./internal/components-plugin";
|
|
@@ -462,15 +463,64 @@ export function stalux(options: StaluxOptions = {}): AstroIntegration[] {
|
|
|
462
463
|
|
|
463
464
|
if (opt.sitemap !== false) {
|
|
464
465
|
const userSitemap = opt.sitemap === true ? undefined : opt.sitemap;
|
|
465
|
-
|
|
466
|
-
const
|
|
466
|
+
const contentDir = opt.contentDir ?? "stalux";
|
|
467
|
+
const promotePath = path.join(process.cwd(), contentDir, "config", "promote.yml");
|
|
468
|
+
const promoteConfig = existsSync(promotePath)
|
|
469
|
+
? (parseYaml(readFileSync(promotePath, "utf8")) as { export_md?: boolean } | undefined)
|
|
470
|
+
: undefined;
|
|
471
|
+
const exportMarkdown = promoteConfig?.export_md === true;
|
|
472
|
+
const sitePath = path.join(process.cwd(), contentDir, "config", "site.yml");
|
|
473
|
+
const siteConfig = existsSync(sitePath)
|
|
474
|
+
? (parseYaml(readFileSync(sitePath, "utf8")) as { url?: string } | undefined)
|
|
475
|
+
: undefined;
|
|
476
|
+
const sitemapSite = opt.site ?? siteConfig?.url;
|
|
477
|
+
const defaultFilter = (page: string) =>
|
|
478
|
+
exportMarkdown || !new URL(page).pathname.endsWith(".md");
|
|
467
479
|
const userFilter = userSitemap?.filter;
|
|
468
480
|
const filter = userFilter
|
|
469
481
|
? (page: string) => defaultFilter(page) && userFilter(page)
|
|
470
482
|
: defaultFilter;
|
|
483
|
+
const customPages = [...(userSitemap?.customPages ?? [])];
|
|
484
|
+
if (exportMarkdown) {
|
|
485
|
+
const postsDir = path.resolve(process.cwd(), contentDir, "posts");
|
|
486
|
+
if (existsSync(postsDir)) {
|
|
487
|
+
for (const filename of readdirSync(postsDir)) {
|
|
488
|
+
if (!filename.endsWith(".md") && !filename.endsWith(".mdx")) {
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
const source = readFileSync(path.join(postsDir, filename), "utf8");
|
|
492
|
+
const opening = source.startsWith("---\r\n")
|
|
493
|
+
? 5
|
|
494
|
+
: source.startsWith("---\n")
|
|
495
|
+
? 4
|
|
496
|
+
: 0;
|
|
497
|
+
if (!opening) continue;
|
|
498
|
+
const closing = source.indexOf("\n---", opening);
|
|
499
|
+
if (closing < 0) continue;
|
|
500
|
+
const frontmatterText = source.slice(opening, closing);
|
|
501
|
+
const frontmatter = frontmatterText.endsWith("\r")
|
|
502
|
+
? frontmatterText.slice(0, -1)
|
|
503
|
+
: frontmatterText;
|
|
504
|
+
const postData = parseYaml(frontmatter) as
|
|
505
|
+
| { abbrlink?: string | number; draft?: boolean }
|
|
506
|
+
| undefined;
|
|
507
|
+
if (postData?.draft || postData?.abbrlink == null) continue;
|
|
508
|
+
if (!sitemapSite) continue;
|
|
509
|
+
const normalizedSite = sitemapSite.endsWith("/")
|
|
510
|
+
? sitemapSite.slice(0, -1)
|
|
511
|
+
: sitemapSite;
|
|
512
|
+
const url = new URL(
|
|
513
|
+
`posts/${encodeURIComponent(String(postData.abbrlink))}.md`,
|
|
514
|
+
`${normalizedSite}/`,
|
|
515
|
+
);
|
|
516
|
+
customPages.push(url.href);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
471
520
|
bundled.push(
|
|
472
521
|
sitemap({
|
|
473
522
|
...userSitemap,
|
|
523
|
+
customPages,
|
|
474
524
|
filter,
|
|
475
525
|
}),
|
|
476
526
|
);
|