import { escape } from "lodash"; export default function grabWebMetaHTML({ meta }) { let html = ``; if (meta.title) { html += ` ${escape(meta.title)}\n`; } if (meta.description) { html += ` \n`; } if (meta.keywords) { const keywords = Array.isArray(meta.keywords) ? meta.keywords.join(", ") : meta.keywords; html += ` \n`; } if (meta.author) { html += ` \n`; } if (meta.robots) { html += ` \n`; } if (meta.canonical) { html += ` \n`; } if (meta.themeColor) { html += ` \n`; } if (meta.og) { const { og } = meta; if (og.title) html += ` \n`; if (og.description) html += ` \n`; if (og.image) html += ` \n`; if (og.url) html += ` \n`; if (og.type) html += ` \n`; if (og.siteName) html += ` \n`; if (og.locale) html += ` \n`; } if (meta.twitter) { const { twitter } = meta; if (twitter.card) html += ` \n`; if (twitter.title) html += ` \n`; if (twitter.description) html += ` \n`; if (twitter.image) html += ` \n`; if (twitter.site) html += ` \n`; if (twitter.creator) html += ` \n`; } return html; }