diff --git a/src/client/theme-default/components/VPSidebar.vue b/src/client/theme-default/components/VPSidebar.vue index 7602d68b..f39a7d99 100644 --- a/src/client/theme-default/components/VPSidebar.vue +++ b/src/client/theme-default/components/VPSidebar.vue @@ -94,7 +94,7 @@ watchPostEffect(async () => { @media (min-width: 1440px) { .VPSidebar { - padding-left: calc((100% - (var(--vp-layout-max-width) - 64px)) / 2); + padding-left: max(32px, calc((100% - (var(--vp-layout-max-width) - 64px)) / 2)); width: calc((100% - (var(--vp-layout-max-width) - 64px)) / 2 + var(--vp-sidebar-width) - 32px); } } diff --git a/src/client/theme-default/styles/components/vp-doc.css b/src/client/theme-default/styles/components/vp-doc.css index 29128d3a..c8c64a94 100644 --- a/src/client/theme-default/styles/components/vp-doc.css +++ b/src/client/theme-default/styles/components/vp-doc.css @@ -222,7 +222,7 @@ .vp-doc .custom-block div[class*='language-'] code { font-weight: 400; - background-color: var(--vp-code-block-bg); + background-color: transparent; } /** diff --git a/src/node/serve/serve.ts b/src/node/serve/serve.ts index 107b0ad6..ec27a2ef 100644 --- a/src/node/serve/serve.ts +++ b/src/node/serve/serve.ts @@ -1,3 +1,5 @@ +import fs from 'fs' +import path from 'path' import sirv from 'sirv' import compression from 'compression' import polka from 'polka' @@ -26,14 +28,21 @@ export async function serve(options: ServeOptions = {}) { const site = await resolveConfig(options.root, 'serve', 'production') const base = trimChar(options?.base ?? site?.site?.base ?? '', '/') + const notAnAsset = (pathname: string) => !pathname.includes('/assets/') + const notFound = fs.readFileSync(path.resolve(site.outDir, './404.html')) + const onNoMatch: polka.Options['onNoMatch'] = (req, res) => { + res.statusCode = 404 + if (notAnAsset(req.path)) res.write(notFound.toString()) + res.end() + } + const compress = compression() const serve = sirv(site.outDir, { etag: true, - single: true, maxAge: 31536000, immutable: true, setHeaders(res, pathname) { - if (!pathname.includes('/assets/')) { + if (notAnAsset(pathname)) { // force server validation for non-asset files since they // are not fingerprinted res.setHeader('cache-control', 'no-cache') @@ -42,14 +51,14 @@ export async function serve(options: ServeOptions = {}) { }) if (base) { - polka() + polka({ onNoMatch }) .use(base, compress, serve) .listen(port, (err: any) => { if (err) throw err console.log(`Built site served at http://localhost:${port}/${base}/\n`) }) } else { - polka() + polka({ onNoMatch }) .use(compress, serve) .listen(port, (err: any) => { if (err) throw err diff --git a/src/shared/shared.ts b/src/shared/shared.ts index 8e02e6dc..973a4a03 100644 --- a/src/shared/shared.ts +++ b/src/shared/shared.ts @@ -21,7 +21,7 @@ export const notFoundPageData: PageData = { title: '404', description: 'Not Found', headers: [], - frontmatter: {}, + frontmatter: { sidebar: false, layout: 'page' }, lastUpdated: 0 }