render: code cleanup (html composition)

pull/3386/head
Yuxuan Zhang 2 years ago
parent f9f968499a
commit 5c06a082f3
No known key found for this signature in database
GPG Key ID: 6910B04F3351EF7D

@ -148,37 +148,34 @@ export async function renderPage(
}
}
const html = `<!DOCTYPE html>
<html lang="${siteData.lang}" dir="${siteData.dir}">
<head>
<meta charset="utf-8">
${
isMetaViewportOverridden(head)
? ''
: '<meta name="viewport" content="width=device-width,initial-scale=1">'
}
<title>${title}</title>
${
isDescriptionOverridden(head)
? ''
: `<meta name="description" content="${description}">`
}
<meta name="generator" content="VitePress v${version}">
${stylesheetLink}
${metadataScript.inHead ? metadataScript.html : ''}
${
appChunk
? `<script type="module" src="${siteData.base}${appChunk.fileName}"></script>`
: ''
}
${await renderHead(head)}
</head>
<body>${teleports?.body || ''}
<div id="app">${content}</div>
${metadataScript.inHead ? '' : metadataScript.html}
${inlinedScript}
</body>
</html>`
const html = [
`<!DOCTYPE html>`,
`<html lang="${siteData.lang}" dir="${siteData.dir}">`,
`<head>`,
`<meta charset="utf-8">`,
isMetaViewportOverridden(head)
? ''
: '<meta name="viewport" content="width=device-width,initial-scale=1">',
`<title>${title}</title>`,
isDescriptionOverridden(head)
? ''
: `<meta name="description" content="${description}">`,
`<meta name="generator" content="VitePress v${version}">`,
stylesheetLink,
metadataScript.inHead ? metadataScript.html : '',
appChunk
? `<script type="module" src="${siteData.base}${appChunk.fileName}"></script>`
: '',
await renderHead(head),
`</head>`,
`<body>`,
teleports?.body || '',
`<div id="app">${content}</div>`,
metadataScript.inHead ? '' : metadataScript.html,
inlinedScript,
`</body>`,
`</html>`
].join('')
const htmlFileName = path.join(config.outDir, page.replace(/\.md$/, '.html'))
await fs.ensureDir(path.dirname(htmlFileName))

Loading…
Cancel
Save