From 570edec9ba95a356e97fbe0a145190a6c94edebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cchrisshank=E2=80=9D?= Date: Tue, 24 Dec 2024 09:41:20 -0800 Subject: [PATCH] fix paths and redirect --- vite.config.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index af12b2c..ded0ff5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -58,7 +58,7 @@ const linkGenerator = (): Plugin => { .sort((a, b) => a.name.localeCompare(b.name)) .map(({ path, name }) => { const title = name.replace('.html', '').replaceAll('-', ' '); - return `
  • ${title}
  • `; + return `
  • ${title}
  • `; }) .join('\n'); @@ -70,7 +70,7 @@ const linkGenerator = (): Plugin => { .sort((a, b) => a.name.localeCompare(b.name)) .map(({ path, name }) => { const title = name.split('/').pop()?.replace('.html', '').replaceAll('-', ' ') || ''; - return `
  • ${title}
  • `; + return `
  • ${title}
  • `; }) .join('\n'); @@ -88,8 +88,9 @@ const fallback = (rootDir: string): Plugin => ({ configureServer(server) { server.middlewares.use((req, res, next) => { const url = req.originalUrl; - if (url && !extname(url) && existsSync(join(rootDir, `${url}/index.html`))) { + if (url && url !== '/' && !extname(url) && existsSync(join(rootDir, `${url}/index.html`))) { req.url += '/index.html'; + console.log('redirect', req.url, req.originalUrl); } next(); });