Last active
March 3, 2022 17:12
-
-
Save Explosion-Scratch/a54287dc65586d7c6fb0e2d716942b6c to your computer and use it in GitHub Desktop.
Generate meta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const generate = (meta) => { | |
return [ | |
{ charset: "utf-8" }, | |
{ lang: "en" }, | |
{ name: "viewport", content: "width=device-width, initial-scale=1" }, | |
{ name: "format-detection", content: "telephone=no" }, | |
{ name: "title", content: meta.title }, | |
{ name: "author", content: meta.author }, | |
{ | |
name: "keywords", | |
content: meta.keywords || "", | |
}, | |
{ name: "robots", content: "index,follow" }, | |
{ name: "language", content: "English" }, | |
{ name: "description", content: meta.description }, | |
{ name: "theme-color", content: meta.color }, | |
{ name: "og:type", content: "website" }, | |
{ name: "apple-mobile-web-app-title", content: meta.title }, | |
{ name: "og_site_name", content: meta.site || meta.title }, | |
{ name: "og:site_name", content: meta.site || meta.title }, | |
{ name: "og:locale", content: "en_US" }, | |
{ name: "og:url", content: meta.url }, | |
{ name: "og:title", content: meta.title }, | |
{ name: "og:description", content: meta.description }, | |
{ name: "og:image", content: meta.image }, | |
{ name: "twitter:card", content: "summary_large_image" }, | |
{ name: "twitter:url", content: meta.url }, | |
{ name: "twitter:title", content: meta.title }, | |
{ name: "twitter:description", content: meta.description }, | |
{ name: "twitter:image", content: meta.image }, | |
].map((i) => { | |
var out = { ...i }; | |
if (!out.hid) { | |
out.hid = out.name; | |
} | |
return out; | |
}).map(i => `<meta name=${JSON.stringify(i.name)} content=${JSON.stringify(i.content)}/>`).join('\n'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment