docs: 部署脚本与项目文档
- scripts/ 部署与构建脚本 - README/.gitignore 等
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* After vite build, copy index.html into docs/ and docs/<slug>/ so that
|
||||
* static hosts (e.g. GitHub Pages) serve the SPA for each route without
|
||||
* needing a Node server. Must match DOC_SLUGS in src/pages/Docs.tsx.
|
||||
*/
|
||||
import { mkdir, readFile, writeFile } from "fs/promises";
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
||||
const distDir = join(__dirname, "..", "dist");
|
||||
|
||||
const DOC_SLUGS = [
|
||||
"intro",
|
||||
"quickstart",
|
||||
"console",
|
||||
"channels",
|
||||
"skills",
|
||||
"memory",
|
||||
"compact",
|
||||
"commands",
|
||||
"heartbeat",
|
||||
"config",
|
||||
"backup",
|
||||
"cli",
|
||||
"creator",
|
||||
"community",
|
||||
"contributing",
|
||||
];
|
||||
|
||||
async function main() {
|
||||
const indexHtml = await readFile(join(distDir, "index.html"), "utf-8");
|
||||
const BLOG_SLUGS = [
|
||||
"introducing-qwenpaw-driver",
|
||||
"qwenpaw-developer-day-collection",
|
||||
"play-with-qwenpaw-pet",
|
||||
];
|
||||
const paths = [
|
||||
"docs",
|
||||
"docs/search",
|
||||
...DOC_SLUGS.map((s) => `docs/${s}`),
|
||||
"blog",
|
||||
...BLOG_SLUGS.map((s) => `blog/${s}`),
|
||||
];
|
||||
for (const p of paths) {
|
||||
const out = join(distDir, p, "index.html");
|
||||
await mkdir(dirname(out), { recursive: true });
|
||||
await writeFile(out, indexHtml);
|
||||
}
|
||||
console.log("[spa-fallback-pages] Wrote index.html for /, /docs, /docs/*");
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user