mirror of
https://github.com/docmost/docmost.git
synced 2025-11-18 20:51:11 +10:00
add meta og:title
This commit is contained in:
@ -73,15 +73,17 @@ export class ShareSeoController {
|
|||||||
rawTitle.length > 80 ? `${rawTitle.slice(0, 77)}…` : rawTitle;
|
rawTitle.length > 80 ? `${rawTitle.slice(0, 77)}…` : rawTitle;
|
||||||
|
|
||||||
const metaTagVar = '<!--meta-tags-->';
|
const metaTagVar = '<!--meta-tags-->';
|
||||||
let metaTag = '';
|
let metaTags = '';
|
||||||
|
|
||||||
|
metaTags = `<meta property="og:title" content="${metaTitle}" />\n`;
|
||||||
if (!share.searchIndexing) {
|
if (!share.searchIndexing) {
|
||||||
metaTag = '<meta name="robots" content="noindex" />';
|
metaTags += '<meta name="robots" content="noindex" />\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
const html = fs.readFileSync(indexFilePath, 'utf8');
|
const html = fs.readFileSync(indexFilePath, 'utf8');
|
||||||
const transformedHtml = html
|
const transformedHtml = html
|
||||||
.replace(/<title>[\s\S]*?<\/title>/i, `<title>${metaTitle}</title>`)
|
.replace(/<title>[\s\S]*?<\/title>/i, `<title>${metaTitle}</title>`)
|
||||||
.replace(metaTagVar, metaTag);
|
.replace(metaTagVar, metaTags);
|
||||||
|
|
||||||
res.type('text/html').send(transformedHtml);
|
res.type('text/html').send(transformedHtml);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user