fix: missing open tags in production
This commit is contained in:
@@ -26,6 +26,8 @@ export const App = ({ url }: { url?: string }) => {
|
|||||||
// during server side rendering don't prepend the BASE_URL
|
// during server side rendering don't prepend the BASE_URL
|
||||||
const pbu = useContext(ServerContext) ? (s: string) => s : prependBaseUrl
|
const pbu = useContext(ServerContext) ? (s: string) => s : prependBaseUrl
|
||||||
|
|
||||||
|
console.log(url)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Router url={url}>
|
<Router url={url}>
|
||||||
<HomePage
|
<HomePage
|
||||||
|
|||||||
@@ -97,7 +97,23 @@ async function createProductionRouter() {
|
|||||||
|
|
||||||
const { html, metadata } = render(req.originalUrl)
|
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
|
return r
|
||||||
|
|||||||
Reference in New Issue
Block a user