Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow general language codes in the Metadata API #52920

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/next/src/lib/metadata/resolvers/resolve-basics.ts
Original file line number Diff line number Diff line change
@@ -66,7 +66,10 @@ export const resolveViewport: FieldResolver<'viewport'> = (viewport) => {

function resolveUrlValuesOfObject(
obj:
| Record<string, string | URL | AlternateLinkDescriptor[] | null>
| Record<
string,
string | URL | AlternateLinkDescriptor[] | null | undefined
>
| null
| undefined,
metadataBase: ResolvedMetadata['metadataBase'],
Original file line number Diff line number Diff line change
@@ -412,7 +412,15 @@ type LangCode =
| 'zh-MO'
| 'zh-SG'
| 'zh-TW'
| 'zh-Hans'
| 'zh-Hant'
| 'zu-ZA'
// We can't have all valid combinations of language-region-script listed here
// as the list is too long and breaks the TypeScript compiler. So instead we
// only add the most common ones with a general string pattern for the rest.
// This way autocompletion still works and it is still possible to add custom
// lang codes.
| `${Lowercase<string>}-${string}`

type UnmatchedLang = 'x-default'