fix: fix homepage meta settings

This commit is contained in:
Guoqi Sun 2024-12-23 02:27:45 +08:00
parent 3bd4752bfd
commit 9d3d1537e8
3 changed files with 5 additions and 24 deletions

View file

@ -63,11 +63,6 @@ export const zh = {
], ],
}, },
pageMeta: { pageMeta: {
home: {
title: "小孙同学",
description: "读书、摄影、编程、旅行,热爱可抵岁月漫长~",
ogImage: "/preview.png",
},
archive: { archive: {
title: "归档", title: "归档",
description: "小孙同学的所有文章", description: "小孙同学的所有文章",
@ -105,11 +100,6 @@ export const en = {
], ],
}, },
pageMeta: { pageMeta: {
home: {
title: "Guoqi Sun",
description: "Reading, Photography, Programming, Traveling",
ogImage: "/preview.png",
},
archive: { archive: {
title: "All Posts", title: "All Posts",
description: "Here are Guoqi Sun's all posts", description: "Here are Guoqi Sun's all posts",

View file

@ -23,15 +23,15 @@ const config = lang === "zh" ? zh : en
<link rel="icon" type="image/svg+xml" href={config.meta.favicon} /> <link rel="icon" type="image/svg+xml" href={config.meta.favicon} />
<title> <title>
{ {
!title title
? `${config.meta.title} - ${config.meta.slogan}` ? `${config.meta.title} - ${title}`
: `${config.meta.title} - ${title}` : `${config.meta.title} - ${config.meta.slogan}`
} }
</title> </title>
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<meta <meta
name="description" name="description"
content={!description ? config.meta.description : description} content={description ? description : config.meta.description}
/> />
<!-- Open Graph / Facebook --> <!-- Open Graph / Facebook -->

View file

@ -2,24 +2,15 @@
import Footer from "~/components/astro/footer.astro" import Footer from "~/components/astro/footer.astro"
import Intro from "~/components/astro/intro.astro" import Intro from "~/components/astro/intro.astro"
import RecentBlogs from "~/components/astro/recent-blogs.astro" import RecentBlogs from "~/components/astro/recent-blogs.astro"
import { en, zh } from "~/config"
import { getLangFromUrl } from "~/i18n/utils"
import MainLayout from "~/layouts/main.astro" import MainLayout from "~/layouts/main.astro"
import { getLanguagePaths } from "~/utils/langs" import { getLanguagePaths } from "~/utils/langs"
export function getStaticPaths() { export function getStaticPaths() {
return getLanguagePaths() return getLanguagePaths()
} }
const lang = getLangFromUrl(Astro.url)
const pageMeta = lang === "zh" ? zh.pageMeta : en.pageMeta
--- ---
<MainLayout <MainLayout ogImage="/preview.png">
title={pageMeta.home.title}
description={pageMeta.home.description}
ogImage={pageMeta.home.ogImage}
>
<Intro /> <Intro />
<RecentBlogs /> <RecentBlogs />
<Footer /> <Footer />