mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-03-22 06:48:11 +00:00
bring back og meta tags
This commit is contained in:
@@ -576,6 +576,15 @@ export default async function createApp(vite) {
|
||||
userThemes : req.userThemes
|
||||
};
|
||||
|
||||
const ogTags = [];
|
||||
const ogMeta = req.ogMeta ?? {};
|
||||
Object.entries(ogMeta).forEach(([key, value])=>{
|
||||
if(!value) return;
|
||||
const tag = `<meta property="og:${key}" content="${value}">`;
|
||||
ogTags.push(tag);
|
||||
});
|
||||
const ogMetaTags = ogTags.join('\n');
|
||||
|
||||
const htmlPath = isProd ? path.resolve('build', 'index.html') : path.resolve('index.html');
|
||||
let html = fs.readFileSync(htmlPath, 'utf-8');
|
||||
|
||||
@@ -585,7 +594,7 @@ export default async function createApp(vite) {
|
||||
|
||||
html = html.replace(
|
||||
'<head>',
|
||||
`<head>\n<script id="props" >window.__INITIAL_PROPS__ = ${JSON.stringify(props)}</script>`
|
||||
`<head>\n<script id="props" >window.__INITIAL_PROPS__ = ${JSON.stringify(props)}</script>\n${ogMetaTags}`
|
||||
);
|
||||
|
||||
return html;
|
||||
|
||||
Reference in New Issue
Block a user