feat(website): SEO 升级 — BrowserRouter + 每页独立 meta
- HashRouter → BrowserRouter(basename /KimiSwitch),GitHub Pages 用 404.html SPA 回退,/features /download /changelog 变为可收录的独立 URL - 每页独立 title / description / OG / canonical(RouteMeta 随语言切换) - og:image 改为绝对地址;sitemap 更新为干净路径
This commit is contained in:
1 parent
5788624d12
commit
1b5cd0f416
8 files changed
+139
-21
No files matched your search
+22
-3
@@ -1,11 +1,30 @@
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, type Plugin } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { copyFileSync } from "node:fs";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
/**
|
||||
* GitHub Pages SPA fallback: any deep path (e.g. /KimiSwitch/features) is
|
||||
* served by 404.html; duplicating the built index.html there lets the
|
||||
* BrowserRouter boot and render the right route. This keeps every page
|
||||
* indexable as a real URL instead of a `#/` fragment.
|
||||
*/
|
||||
function generate404(): Plugin {
|
||||
return {
|
||||
name: "generate-404",
|
||||
apply: "build",
|
||||
closeBundle() {
|
||||
const dist = fileURLToPath(new URL("./dist", import.meta.url));
|
||||
copyFileSync(`${dist}/index.html`, `${dist}/404.html`);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// GitHub Pages subpath: billowliu2.github.io/KimiSwitch/
|
||||
export default defineConfig({
|
||||
base: "/KimiSwitch/",
|
||||
plugins: [react()],
|
||||
plugins: [react(), generate404()],
|
||||
resolve: {
|
||||
alias: { "@": "/src" },
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user