Skip to content

Commit

Permalink
Allow general language codes in the Metadata API (#52920)
Browse files Browse the repository at this point in the history
Closes #52898

LangCode Missing zh-Hans and zh-Hant

| 'yo-NG'
  | 'zh-CN'
  | 'zh-Hans'   //added
  | 'zh-Hant'        //added
  | 'zh-HK'
  | 'zh-MO'
  | 'zh-SG'
  | 'zh-TW'
  | 'zu-ZA'


https://github.com/vercel/next.js/blob/f5272acbe5628164257ef8e584c8a469a4af5cb8/packages/next/src/lib/metadata/types/alternative-urls-types.ts#L419


Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
  • Loading branch information
darshanjain-entrepreneur and shuding committed Jul 20, 2023
1 parent df0330f commit 8e3cd83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 8e3cd83

Please sign in to comment.