Skip to content

Commit

Permalink
fix: Filter undefined and support title prop
Browse files Browse the repository at this point in the history
  • Loading branch information
kiliman committed Apr 6, 2022
1 parent 09668e1 commit c14eade
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -678,15 +678,17 @@ export function Meta() {

return (
<>
{[...meta.entries()].map(([key, value]) => {
if (key === "title" && typeof value.content === "string") {
return <title key={key}>{value.content}</title>;
}
if (key === "charset" && typeof value.content === "string") {
return <meta key={key} charSet={value.content} />;
}
return <meta key={key} {...value} />;
})}
{[...meta.entries()]
.filter(([_, value]) => typeof value.content !== "undefined")
.map(([key, value]) => {
if (key === "title" && typeof value.content === "string") {
return <title key={key}>{value.content}</title>;
}
if (key === "charset" && typeof value.content === "string") {
return <meta key={key} charSet={value.content} />;
}
return <meta key={key} {...value} />;
})}
</>
);
}
Expand All @@ -700,7 +702,9 @@ export function processMeta(
routeMeta: HtmlMetaDescriptor | HtmlMetaDescriptor[]
) {
let items: HtmlMetaDescriptor[] = Array.isArray(routeMeta)
? routeMeta
? routeMeta.map((item) =>
item.title ? { key: "title", content: item.title } : item
)
: Object.entries(routeMeta)
.map(([key, value]) => {
if (!value) return [];
Expand Down

0 comments on commit c14eade

Please sign in to comment.