diff --git a/src/pages/index.astro b/src/pages/index.astro index f8241d2..e7b7488 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,15 +1,40 @@ --- import BaseLayout from '../layouts/BaseLayout.astro'; import { listRecentPosts } from '../lib/posts'; -const posts = await listRecentPosts(5); +import { siteConfig } from '../site.config'; +const posts = await listRecentPosts(siteConfig.home.recentLimit); --- -

最近文章

- + {siteConfig.hero.enabled && ( +
+

{siteConfig.hero.title}

+

{siteConfig.hero.subtitle}

+ + {siteConfig.hero.ctaText} + +
+ )} + +
+

最近文章

+
+ {posts.map((p) => ( + +

{p.data.title}

+ {siteConfig.home.showDates && ( +
+ {p.data.pubDate?.toLocaleDateString?.('zh-CN')} +
+ )} + {siteConfig.home.showTags && p.data.tags?.length ? ( +
+ {p.data.tags.slice(0,3).map((t) => ( + {t} + ))} +
+ ) : null} +
+ ))} +
+
diff --git a/src/site.config.ts b/src/site.config.ts new file mode 100644 index 0000000..b25f46d --- /dev/null +++ b/src/site.config.ts @@ -0,0 +1,19 @@ +export const siteConfig = { + siteName: '学习博客', + tagline: '持续沉淀,面向未来的知识库', + hero: { + enabled: true, + title: '欢迎来到学习博客', + subtitle: '记录、分享、迭代你的知识资产', + ctaText: '查看全部文章', + ctaHref: '/posts' + }, + home: { + recentLimit: 8, + showTags: true, + showDates: true + } +} as const; + +export type SiteConfig = typeof siteConfig; +