don't remove quotes in <head>

This commit is contained in:
Andrea Vos 2021-10-21 20:44:23 +02:00
parent a0afec37f6
commit 41c242dc86

View File

@ -23,7 +23,7 @@ export const head = ({title, description, banner}) => {
const meta = { meta: [] }; const meta = { meta: [] };
if (title) { if (title) {
title = clearLinkedText(title); title = clearLinkedText(title, false);
title += ' • ' + process.env.TITLE; title += ' • ' + process.env.TITLE;
meta.title = title; meta.title = title;
meta.meta.push({ hid: 'og:title', property: 'og:title', content: title }); meta.meta.push({ hid: 'og:title', property: 'og:title', content: title });
@ -198,12 +198,16 @@ export const handleErrorAsync = func => (req, res, next) => {
func(req, res, next).catch((error) => next(error)); func(req, res, next).catch((error) => next(error));
}; };
export const clearLinkedText = (text) => { export const clearLinkedText = (text, quotes = true) => {
return text text = text
.replace(/{[^}=]+=([^}=]+)}/g, '$1') .replace(/{[^}=]+=([^}=]+)}/g, '$1')
.replace(/{([^}=]+)}/g, '$1') .replace(/{([^}=]+)}/g, '$1');
.replace(/[„”"']/g, '')
; if (quotes) {
text = text.replace(/[„”"']/g, '');
}
return text;
} }
export const sortClearedLinkedText = (items, key) => { export const sortClearedLinkedText = (items, key) => {