UNPKG

@forge42/seo-tools

Version:

Framework agnostic set of helpers designed to help you create, maintain and develop your SEO

1 lines 3.58 kB
{"version":3,"sources":["../../src/remix/metadata.ts"],"sourcesContent":["type MetaDescriptor =\n\t| {\n\t\t\tcharSet: \"utf-8\"\n\t }\n\t| {\n\t\t\ttitle: string\n\t }\n\t| {\n\t\t\tname: string\n\t\t\tcontent: string\n\t }\n\t| {\n\t\t\tproperty: string\n\t\t\tcontent: string\n\t }\n\t| {\n\t\t\thttpEquiv: string\n\t\t\tcontent: string\n\t }\n\t| {\n\t\t\t\"script:ld+json\": LdJsonObject\n\t }\n\t| {\n\t\t\ttagName: \"meta\" | \"link\"\n\t\t\t[name: string]: string\n\t }\n\t| {\n\t\t\t[name: string]: unknown\n\t }\ntype LdJsonObject = {\n\t[Key in string]: LdJsonValue\n} & {\n\t[Key in string]?: LdJsonValue | undefined\n}\ntype LdJsonArray = LdJsonValue[] | readonly LdJsonValue[]\ntype LdJsonPrimitive = string | number | boolean | null\ntype LdJsonValue = LdJsonPrimitive | LdJsonObject | LdJsonArray\n\nexport interface MetaData {\n\t/**\n\t * The title of the page.\n\t * this will be used as the title of the page and in the meta tags.\n\t * this also generates the twitter:title and og:title meta tags.\n\t */\n\ttitle: string\n\t/**\n\t * The description of the page.\n\t * this will be used as the description of the page and in the meta tags.\n\t * this also generates the twitter:description and og:description meta tags.\n\t */\n\tdescription: string\n\t/**\n\t * The keywords of the page.\n\t */\n\tkeywords?: string[]\n\t/**\n\t * The url of the page.\n\t * this generates the og:url meta tag.\n\t */\n\turl: string\n\t/**\n\t * The image of the page.\n\t * this generates the og:image meta tag.\n\t */\n\timage?: string\n\t/**\n\t * The site name of the page.\n\t * this generates the og:site_name meta tag.\n\t */\n\tsiteName?: string\n}\n/**\n * Generate meta tags for Remix to be consumed by the meta function.\n *\n * The first argument takes common meta tags like title, description, url, siteName, image, and keywords.\n * Then it generates meta tags for Twitter and Open Graph using the same data.\n *\n * @param metaData - MetaData object\n * @param additionalData - Additional meta tags\n * @returns MetaDescriptor[] - Remix compatible meta tags\n */\nexport const generateMeta = (metaData: MetaData, additionalData?: MetaDescriptor[]) => {\n\tconst { title, description, url, siteName, image, keywords } = metaData\n\treturn [\n\t\t{ title },\n\t\t{ name: \"twitter:title\", content: title },\n\t\t{ name: \"og:title\", content: title },\n\t\t{ name: \"description\", content: description },\n\t\t{ name: \"twitter:description\", content: description },\n\t\t{ name: \"og:description\", content: description },\n\t\t{ name: \"og:url\", content: url },\n\t\t...(keywords ? [{ name: \"keywords\", content: keywords.join(\", \") }] : []),\n\t\t...(siteName ? [{ name: \"og:site_name\", content: siteName }] : []),\n\t\t...(image ? [{ name: \"og:image\", content: image }] : []),\n\t\t...(additionalData ?? []),\n\t]\n}\n"],"mappings":"AAiFO,IAAMA,EAAe,CAACC,EAAoBC,IAAsC,CACtF,GAAM,CAAE,MAAAC,EAAO,YAAAC,EAAa,IAAAC,EAAK,SAAAC,EAAU,MAAAC,EAAO,SAAAC,CAAS,EAAIP,EAC/D,MAAO,CACN,CAAE,MAAAE,CAAM,EACR,CAAE,KAAM,gBAAiB,QAASA,CAAM,EACxC,CAAE,KAAM,WAAY,QAASA,CAAM,EACnC,CAAE,KAAM,cAAe,QAASC,CAAY,EAC5C,CAAE,KAAM,sBAAuB,QAASA,CAAY,EACpD,CAAE,KAAM,iBAAkB,QAASA,CAAY,EAC/C,CAAE,KAAM,SAAU,QAASC,CAAI,EAC/B,GAAIG,EAAW,CAAC,CAAE,KAAM,WAAY,QAASA,EAAS,KAAK,IAAI,CAAE,CAAC,EAAI,CAAC,EACvE,GAAIF,EAAW,CAAC,CAAE,KAAM,eAAgB,QAASA,CAAS,CAAC,EAAI,CAAC,EAChE,GAAIC,EAAQ,CAAC,CAAE,KAAM,WAAY,QAASA,CAAM,CAAC,EAAI,CAAC,EACtD,GAAIL,GAAkB,CAAC,CACxB,CACD","names":["generateMeta","metaData","additionalData","title","description","url","siteName","image","keywords"]}