UNPKG

@forge42/seo-tools

Version:

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

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