Skip to content

Commit

Permalink
Better type
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Mar 15, 2024
1 parent 71e2fbd commit 9076c2d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-datocms",
"version": "5.0.0",
"version": "5.0.1",
"engines": {
"node": ">=8.0.0"
},
Expand Down
32 changes: 32 additions & 0 deletions src/Seo/__tests__/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -323,147 +323,179 @@ exports[`toRemixMeta generates a meta descriptor 1`] = `
{
"content": "Remix CMS - The easiest way to manage content with Remix",
"property": "og:title",
"tagName": "meta",
},
{
"content": "Remix CMS - The easiest way to manage content with Remix",
"name": "twitter:title",
"tagName": "meta",
},
{
"content": "Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now.",
"name": "description",
"tagName": "meta",
},
{
"content": "Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now.",
"property": "og:description",
"tagName": "meta",
},
{
"content": "Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now.",
"name": "twitter:description",
"tagName": "meta",
},
{
"content": "https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000",
"property": "og:image",
"tagName": "meta",
},
{
"content": "746",
"property": "og:image:width",
"tagName": "meta",
},
{
"content": "186",
"property": "og:image:height",
"tagName": "meta",
},
{
"content": "https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000",
"name": "twitter:image",
"tagName": "meta",
},
{
"content": "en",
"property": "og:locale",
"tagName": "meta",
},
{
"content": "article",
"property": "og:type",
"tagName": "meta",
},
{
"content": "DatoCMS",
"property": "og:site_name",
"tagName": "meta",
},
{
"content": "2022-01-18T14:02:47Z",
"property": "article:modified_time",
"tagName": "meta",
},
{
"content": "summary_large_image",
"name": "twitter:card",
"tagName": "meta",
},
{
"content": "@datocms",
"name": "twitter:site",
"tagName": "meta",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=16&w=16",
"rel": "icon",
"sizes": "16x16",
"tagName": "link",
"type": "image/png",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=32&w=32",
"rel": "icon",
"sizes": "32x32",
"tagName": "link",
"type": "image/png",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=96&w=96",
"rel": "icon",
"sizes": "96x96",
"tagName": "link",
"type": "image/png",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=192&w=192",
"rel": "icon",
"sizes": "192x192",
"tagName": "link",
"type": "image/png",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=57&w=57",
"rel": "apple-touch-icon",
"sizes": "57x57",
"tagName": "link",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=60&w=60",
"rel": "apple-touch-icon",
"sizes": "60x60",
"tagName": "link",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=72&w=72",
"rel": "apple-touch-icon",
"sizes": "72x72",
"tagName": "link",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=76&w=76",
"rel": "apple-touch-icon",
"sizes": "76x76",
"tagName": "link",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=114&w=114",
"rel": "apple-touch-icon",
"sizes": "114x114",
"tagName": "link",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=120&w=120",
"rel": "apple-touch-icon",
"sizes": "120x120",
"tagName": "link",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=144&w=144",
"rel": "apple-touch-icon",
"sizes": "144x144",
"tagName": "link",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=152&w=152",
"rel": "apple-touch-icon",
"sizes": "152x152",
"tagName": "link",
},
{
"href": "https://www.datocms-assets.com/205/1525789775-dato.png?h=180&w=180",
"rel": "apple-touch-icon",
"sizes": "180x180",
"tagName": "link",
},
{
"content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=70&w=70",
"name": "msapplication-square70x70logo",
"tagName": "meta",
},
{
"content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=150",
"name": "msapplication-square150x150logo",
"tagName": "meta",
},
{
"content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=310&w=310",
"name": "msapplication-square310x310logo",
"tagName": "meta",
},
{
"content": "https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=310",
"name": "msapplication-square310x150logo",
"tagName": "meta",
},
]
`;
Expand Down
9 changes: 7 additions & 2 deletions src/Seo/remixUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ export function toRemixMeta(
return tags
.map((x) => {
if (x.tag === 'title' && x.content) return { title: x.content };
return x.attributes;
if (x.attributes) {
return {
tagName: x.tag,
...x.attributes,
} as Record<string, string>;
}
})
.filter((x): x is NonNullable<typeof x> => Boolean(x));
.filter(Boolean);
}

0 comments on commit 9076c2d

Please sign in to comment.