Jacky Zhao
2024-02-08 a87704cd05e379c670abce823385fb937a65920d
fix: set default locale for lang attribute
2 files modified
6 ■■■■ changed files
quartz/components/renderPage.tsx 3 ●●●● patch | view | raw | blame | history
quartz/i18n/index.ts 3 ●●●● patch | view | raw | blame | history
quartz/components/renderPage.tsx
@@ -209,8 +209,7 @@
    </div>
  )
  const lang = componentData.frontmatter?.lang ?? cfg.locale.split("-")[0]
  const lang = componentData.frontmatter?.lang ?? cfg.locale?.split("-")[0] ?? "en"
  const doc = (
    <html lang={lang}>
      <Head {...componentData} />
quartz/i18n/index.ts
@@ -20,5 +20,6 @@
  "uk-UA": uk,
} as const
export const i18n = (locale: ValidLocale): Translation => TRANSLATIONS[locale ?? "en-US"]
export const defaultTranslation = "en-US"
export const i18n = (locale: ValidLocale): Translation => TRANSLATIONS[locale ?? defaultTranslation]
export type ValidLocale = keyof typeof TRANSLATIONS