From 6ffb6ba756df2fafdd795dc76124efd243ee01c7 Mon Sep 17 00:00:00 2001 From: tuber Date: Thu, 25 Jul 2024 15:22:32 +0800 Subject: [PATCH] fix: Refactor MultiMeta component to handle string and URL contents --- packages/next/src/lib/metadata/generate/meta.tsx | 3 +++ .../next/src/lib/metadata/resolvers/resolve-opengraph.ts | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/packages/next/src/lib/metadata/generate/meta.tsx b/packages/next/src/lib/metadata/generate/meta.tsx index 96394bc7b008a..c291e85efbef3 100644 --- a/packages/next/src/lib/metadata/generate/meta.tsx +++ b/packages/next/src/lib/metadata/generate/meta.tsx @@ -100,6 +100,9 @@ export function MultiMeta({ if (typeof contents === 'undefined' || contents === null) { return null } + if (!Array.isArray(contents)) { + contents = [contents] + } return MetaFilter( contents.map((content) => { diff --git a/packages/next/src/lib/metadata/resolvers/resolve-opengraph.ts b/packages/next/src/lib/metadata/resolvers/resolve-opengraph.ts index 780f3c2e45ab0..ac54047993366 100644 --- a/packages/next/src/lib/metadata/resolvers/resolve-opengraph.ts +++ b/packages/next/src/lib/metadata/resolvers/resolve-opengraph.ts @@ -166,6 +166,11 @@ export const resolveOpenGraph: FieldResolverExtraArgs< ) } + /* + warning: force type assertion maybe merge authors of openGraph with string type from Metadata into ResolvedOpenGraph, + but it's not support a string type for authors of openGraph. + is there any other field that has the same issue? + */ const resolved = { ...openGraph, title: resolveTitle(openGraph.title, titleTemplate),