diff --git a/src/node/build/bundle.ts b/src/node/build/bundle.ts index bb736847..7f86e7d7 100644 --- a/src/node/build/bundle.ts +++ b/src/node/build/bundle.ts @@ -2,7 +2,7 @@ import ora from 'ora' import path from 'path' import fs from 'fs-extra' import { slash } from '../utils/slash' -import { APP_PATH } from '../alias' +import { APP_PATH, APP_HTML } from '../alias' import { SiteConfig } from '../config' import { RollupOutput } from 'rollup' import { build, BuildOptions, UserConfig as ViteUserConfig } from 'vite' diff --git a/src/node/plugin.ts b/src/node/plugin.ts index 6f1751e7..7215abc8 100644 --- a/src/node/plugin.ts +++ b/src/node/plugin.ts @@ -5,7 +5,8 @@ import { createMarkdownToVueRenderFn, MarkdownCompileResult } from './markdownToVue' -import { DIST_CLIENT_PATH, APP_PATH, SITE_DATA_REQUEST_PATH } from './alias' +import { DIST_CLIENT_PATH, SITE_DATA_REQUEST_PATH } from './alias' +import { APP_HTML } from './utils/html' import createVuePlugin from '@vitejs/plugin-vue' import { slash } from './utils/slash' import { OutputAsset, OutputChunk } from 'rollup' @@ -160,23 +161,15 @@ export function createVitePressPlugin( // serve our index.html after vite history fallback return () => { - server.middlewares.use((req, res, next) => { + server.middlewares.use(async (req, res, next) => { if (req.url!.endsWith('.html')) { res.statusCode = 200 - res.end(` - - - - - - - - - -
- - -`) + const html = await server.transformIndexHtml( + req.url!, + APP_HTML, + req.originalUrl + ) + res.end(html) return } next() diff --git a/src/node/utils/html.ts b/src/node/utils/html.ts new file mode 100644 index 00000000..4235f8f0 --- /dev/null +++ b/src/node/utils/html.ts @@ -0,0 +1,16 @@ +import { APP_PATH } from '../alias' + +export const APP_HTML = ` + + + + + + + + + +
+ + +`