UNPKG

react-metatags-hook

Version:
15 lines (14 loc) 571 B
import { getTagsList } from '../state'; // Public export const generateMetasMarkup = (metas) => { const title = metas.title ? `<title>${metas.title}</title>` : ''; const tagsList = getTagsList(metas); const tags = tagsList.map(({ attributes, tag }) => { const attributeParts = Object.keys(attributes).map((key) => { const value = attributes[key] ? `="${attributes[key] || ''}"` : ''; return `${key}${value}`; }); return `<${tag} ${attributeParts.join(' ')} />`; }); return [title, ...tags].join(''); };