diff --git a/frontmatter.json b/frontmatter.json index cb9e910..a377ad9 100644 --- a/frontmatter.json +++ b/frontmatter.json @@ -55,6 +55,11 @@ "title": "draft", "name": "draft", "type": "boolean" + }, + { + "title": "language", + "name": "language", + "type": "string" } ] } diff --git a/scripts/new-post.js b/scripts/new-post.js index 05a944c..6f9f21e 100644 --- a/scripts/new-post.js +++ b/scripts/new-post.js @@ -44,6 +44,7 @@ image: '' tags: [] category: '' draft: false +language: '' --- ` diff --git a/src/content/config.ts b/src/content/config.ts index a200113..50e7d8b 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -9,6 +9,7 @@ const postsCollection = defineCollection({ image: z.string().optional().default(''), tags: z.array(z.string()).optional().default([]), category: z.string().optional().default(''), + language: z.string().optional().default(''), /* For internal use */ prevTitle: z.string().default(''), diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 073acaa..9ab96b2 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -21,9 +21,10 @@ interface Props { title?: string banner?: string description?: string + lang?: string } -let { title, banner, description } = Astro.props +let { title, banner, description, lang } = Astro.props // apply a class to the body element to decide the height of the banner, only used for initial page load // Swup can update the body for each page visit, but it's after the page transition, causing a delay for banner height change @@ -52,7 +53,11 @@ if (title) { const favicons: Favicon[] = siteConfig.favicon.length > 0 ? siteConfig.favicon : defaultFavicons -const siteLang = siteConfig.lang.replace('_', '-') +// const siteLang = siteConfig.lang.replace('_', '-') +if (!lang) { + lang = `${siteConfig.lang}` +} +const siteLang = lang.replace('_', '-') --- diff --git a/src/layouts/MainGridLayout.astro b/src/layouts/MainGridLayout.astro index d961310..3cd7141 100644 --- a/src/layouts/MainGridLayout.astro +++ b/src/layouts/MainGridLayout.astro @@ -11,15 +11,16 @@ interface Props { title?: string banner?: string description?: string + lang?: string } -const { title, banner, description } = Astro.props +const { title, banner, description, lang } = Astro.props const hasBannerCredit = siteConfig.banner.enable && siteConfig.banner.credit.enable const hasBannerLink = !!siteConfig.banner.credit.url --- - +
+