Просмотр исходного кода

ref: define docs static build path in constants.ts

Sv443 4 месяцев назад
Родитель
Сommit
6d331a0c33
2 измененных файлов с 7 добавлено и 3 удалено
  1. 3 0
      src/constants.ts
  2. 4 3
      src/routes/index.ts

+ 3 - 0
src/constants.ts

@@ -1,3 +1,4 @@
+import { resolve } from "node:path";
 import type { IRateLimiterOptions } from "rate-limiter-flexible";
 import packageJson from "../package.json" with { type: "json" };
 
@@ -28,3 +29,5 @@ export const charReplacements = new Map<string, string>([
 export const rlIgnorePaths = [
   "/docs",
 ];
+
+export const docsPath = resolve("./www/.vuepress/dist");

+ 4 - 3
src/routes/index.ts

@@ -1,6 +1,5 @@
-import { resolve } from "node:path";
 import express, { Application, Router } from "express";
-import { verMajor } from "@src/constants.js";
+import { docsPath, verMajor } from "@src/constants.js";
 import { redirectToDocs } from "@src/utils.js";
 
 import { initSearchRoutes } from "@routes/search.js";
@@ -29,7 +28,9 @@ export function initRouter(app: Application) {
 
   if(hostHomepage) {
     // host docs files
-    router.use("/docs", express.static(resolve("./www/.vuepress/dist")));
+    router.use("/docs", express.static(docsPath, {
+      index: "index.html",
+    }));
 
     // redirect to docs page
     router.get("/", (_req, res) => redirectToDocs(res));