0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-03-22 08:58:11 +00:00

bring back og meta tags

This commit is contained in:
Víctor Losada Hernández
2026-02-02 16:55:39 +01:00
parent b936546392
commit 74733a4cca
2 changed files with 10 additions and 2 deletions

View File

@@ -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;