fix: missing open tags in production

This commit is contained in:
2022-11-24 00:32:45 +01:00
parent 1deea11126
commit 2dfce9d7d7
2 changed files with 19 additions and 1 deletions
+17 -1
View File
@@ -97,7 +97,23 @@ async function createProductionRouter() {
const { html, metadata } = render(req.originalUrl)
res.send(transformedTemplate.replace('<!-- SSR OUTLET -->', html))
process.stdout.write('[Metadata] ')
console.dir(metadata)
const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`
const metaTagsHtml =
'' +
(metadata.title ? `<meta property="og:title" content="${metadata.title}" />\n` : '') +
(metadata.description
? `<meta property="og:description" content="${metadata.description}" />\n`
: '') +
`<meta property="og:url" content="${fullUrl}" />\n`
res.send(
transformedTemplate
.replace('<!-- INJECT META TAGS -->', metaTagsHtml)
.replace('<!-- SSR OUTLET -->', html)
)
})
return r