diff --git a/README.md b/README.md index 592933a..9451ee8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ A minimalism, personal blog theme for Astro [![Built with Astro](https://astro.badg.es/v1/built-with-astro/tiny.svg)](https://astro.build) [![Netlify Status](https://api.netlify.com/api/v1/badges/a4eb6e88-606d-4ea6-9a53-179e03a7e2ef/deploy-status)](https://app.netlify.com/sites/astro-air/deploys) +Astro Air + > > If you find this project helpful, please consider giving it a star ⭐️ diff --git a/astro.config.mjs b/astro.config.mjs index 3769166..0010a92 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,10 +1,9 @@ import mdx from "@astrojs/mdx" import react from "@astrojs/react" +import sitemap from "@astrojs/sitemap" import tailwind from "@astrojs/tailwind" import { defineConfig } from "astro/config" -import sitemap from "@astrojs/sitemap"; - // https://astro.build/config export default defineConfig({ output: "static", @@ -15,4 +14,4 @@ export default defineConfig({ }, }, integrations: [react(), tailwind(), mdx(), sitemap()], -}) \ No newline at end of file +}) diff --git a/public/images/page-meta/en/about.png b/public/images/page-meta/en/about.png new file mode 100644 index 0000000..57f9a79 Binary files /dev/null and b/public/images/page-meta/en/about.png differ diff --git a/public/images/page-meta/en/archive.png b/public/images/page-meta/en/archive.png new file mode 100644 index 0000000..630d4c5 Binary files /dev/null and b/public/images/page-meta/en/archive.png differ diff --git a/public/images/page-meta/en/links.png b/public/images/page-meta/en/links.png new file mode 100644 index 0000000..b33252f Binary files /dev/null and b/public/images/page-meta/en/links.png differ diff --git a/public/images/page-meta/zh/about.png b/public/images/page-meta/zh/about.png new file mode 100644 index 0000000..13d38d8 Binary files /dev/null and b/public/images/page-meta/zh/about.png differ diff --git a/public/images/page-meta/zh/archive.png b/public/images/page-meta/zh/archive.png new file mode 100644 index 0000000..a900026 Binary files /dev/null and b/public/images/page-meta/zh/archive.png differ diff --git a/public/images/page-meta/zh/links.png b/public/images/page-meta/zh/links.png new file mode 100644 index 0000000..3f433db Binary files /dev/null and b/public/images/page-meta/zh/links.png differ diff --git a/public/links/astro.svg b/public/links/astro.svg new file mode 100644 index 0000000..76b5a35 --- /dev/null +++ b/public/links/astro.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/preview.png b/public/preview.png new file mode 100644 index 0000000..3c7da82 Binary files /dev/null and b/public/preview.png differ diff --git a/src/components/astro/link-card.astro b/src/components/astro/link-card.astro new file mode 100644 index 0000000..de61dc2 --- /dev/null +++ b/src/components/astro/link-card.astro @@ -0,0 +1,32 @@ +--- +interface Props { + name: string + link: string + description: string + avatar: string +} + +const { name, link, description, avatar } = Astro.props +--- + + + {name} +
+ + {name} + + + {description} + +
+
diff --git a/src/components/astro/nav.astro b/src/components/astro/nav.astro index a54076b..d4fc7ad 100644 --- a/src/components/astro/nav.astro +++ b/src/components/astro/nav.astro @@ -5,11 +5,13 @@ import { getLangFromUrl, useTranslations } from "~/i18n/utils" const lang = getLangFromUrl(Astro.url) const t = useTranslations(lang) -const { home, archive, custom, about } = +const { home, archive, custom, links, about } = lang === "zh" ? zh.navigation : en.navigation --- -
+
{ home && ( )) } + { + links && ( + +

{t("nav.links")}

+
+ ) + } { about && ( {title} {title} + +```json +name: "Guoqi Sun" +description: "Try, fail, retry. That's the rhythm of growth." +link: "https://blog.sunguoqi.com" +avatar: "https://assets.guoqi.dev/images/avatar.png" +``` + +

+ Want to add a friend link? Please leave a comment in the comment area below, + and I will add it as soon as possible. +

+ +```json +name: "your site name" +description: "your site description" +link: "your site link" +avatar: "your site avatar" +``` diff --git a/src/config/index.ts b/src/config/index.ts index 06c3049..a45ab6f 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -3,6 +3,7 @@ import { Github, Twitter } from "lucide-react" export const defaultLanguage: string = "en" export const common = { + domain: "https://astro-air.guoqi.dev", meta: { favicon: "/avatar.png", url: "https://blog.sunguoqi.com", @@ -30,6 +31,7 @@ export const common = { link: "https://camlife.cn", }, ], + links: true, about: true, }, latestPosts: 8, @@ -60,6 +62,28 @@ export const zh = { }, ], }, + pageMeta: { + home: { + title: "小孙同学", + description: "读书、摄影、编程、旅行,热爱可抵岁月漫长~", + ogImage: "/preview.png", + }, + archive: { + title: "归档", + description: "小孙同学的所有文章", + ogImage: "/images/page-meta/zh/archive.png", + }, + links: { + title: "朋友们", + description: "小孙同学的和他朋友们", + ogImage: "/images/page-meta/zh/links.png", + }, + about: { + title: "关于我", + description: "小孙同学的自我介绍", + ogImage: "/images/page-meta/zh/about.png", + }, + }, } export const en = { @@ -80,4 +104,26 @@ export const en = { }, ], }, + pageMeta: { + home: { + title: "Guoqi Sun", + description: "Reading, Photography, Programming, Traveling", + ogImage: "/preview.png", + }, + archive: { + title: "All Posts", + description: "Here are Guoqi Sun's all posts", + ogImage: "/images/page-meta/en/archive.png", + }, + links: { + title: "My Friends", + description: "Here are Guoqi Sun's friends", + ogImage: "/images/page-meta/en/links.png", + }, + about: { + title: "About Me", + description: "Here is Guoqi Sun's self-introduction", + ogImage: "/images/page-meta/en/about.png", + }, + }, } diff --git a/src/config/links.ts b/src/config/links.ts new file mode 100644 index 0000000..7f1ca3b --- /dev/null +++ b/src/config/links.ts @@ -0,0 +1,14 @@ +export const links = [ + { + name: "Astro", + link: "https://astro.build", + description: "The web framework for content-driven websites", + avatar: "/links/astro.svg", + }, + { + name: "Guoqi Sun", + link: "https://blog.sunguoqi.com", + description: "Try, fail, retry. That's the rhythm of growth.", + avatar: "https://assets.guoqi.dev/images/avatar.png", + }, +] diff --git a/src/config/zh/about.mdx b/src/config/zh/about.mdx index 0b1dbed..ec08bf6 100644 --- a/src/config/zh/about.mdx +++ b/src/config/zh/about.mdx @@ -1,6 +1,6 @@ -export const title = "关于我" +export const title = "你好,我是小孙同学~" -{title} +

{title}

{title} + +```json +name: "Guoqi Sun" +description: "Try, fail, retry. That's the rhythm of growth." +link: "https://blog.sunguoqi.com" +avatar: "https://assets.guoqi.dev/images/avatar.png" +``` + +

+ 想要添加友情链接?请按照如下格式在评论区留言,我会及时添加。 +

+ +```json +name: "your site name" +description: "your site description" +link: "your site link" +avatar: "your site avatar" +``` diff --git a/src/i18n/ui.ts b/src/i18n/ui.ts index 2a6cdaf..0a1510a 100644 --- a/src/i18n/ui.ts +++ b/src/i18n/ui.ts @@ -12,17 +12,19 @@ export const ui = { "nav.home": "Home", "nav.archive": "Archive", "nav.about": "About", - "nav.twitter": "Twitter", + "nav.links": "Links", "blog.latest": "Latest Posts", "archive.title": "All Posts", + "links.title": "My Friends", "tag.title": "Tag:", "tag.no_posts": "No posts found for tag", }, zh: { "nav.home": "首页", "nav.about": "关于", - "nav.blog": "推特", "nav.archive": "归档", + "nav.links": "友链", + "links.title": "朋友们", "blog.latest": "近期文章", "archive.title": "所有文章", "tag.title": "标签:", diff --git a/src/layouts/main.astro b/src/layouts/main.astro index 3904911..d73e1d6 100644 --- a/src/layouts/main.astro +++ b/src/layouts/main.astro @@ -19,7 +19,7 @@ const openGraphImage = !ogImage ? `/og/${filename}.png` : ogImage
-
+
{needComment && }
diff --git a/src/pages/[lang]/about/index.astro b/src/pages/[lang]/about/index.astro index 70a6d14..5d99ea7 100644 --- a/src/pages/[lang]/about/index.astro +++ b/src/pages/[lang]/about/index.astro @@ -1,4 +1,5 @@ --- +import { en, zh } from "~/config" import AboutContentEn from "~/config/en/about.mdx" import AboutContentZh from "~/config/zh/about.mdx" import { getLangFromUrl } from "~/i18n/utils" @@ -10,18 +11,17 @@ export function getStaticPaths() { } const lang = getLangFromUrl(Astro.url) +const pageMeta = lang === "zh" ? zh.pageMeta : en.pageMeta const AboutContent = lang === "zh" ? AboutContentZh : AboutContentEn - -const ogImage = "https://sunguoqi.com/me.png" --- -
+
diff --git a/src/pages/[lang]/archive/index.astro b/src/pages/[lang]/archive/index.astro index bd82f7b..572e055 100644 --- a/src/pages/[lang]/archive/index.astro +++ b/src/pages/[lang]/archive/index.astro @@ -1,11 +1,13 @@ --- import PostList from "~/components/astro/post-list.astro" +import { en, zh } from "~/config" import { getLangFromUrl } from "~/i18n/utils" import MainLayout from "~/layouts/main.astro" import { getPostsByLocale } from "~/utils" import { getLanguagePaths } from "~/utils/langs" const lang = getLangFromUrl(Astro.url) +const pageMeta = lang === "zh" ? zh.pageMeta : en.pageMeta export function getStaticPaths() { return getLanguagePaths() @@ -28,7 +30,11 @@ const postsByYear = posts.reduce( const years = Object.keys(postsByYear).sort((a, b) => Number(b) - Number(a)) --- - + { years.map((year) => (
diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index 97ac78f..89133d7 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -2,15 +2,24 @@ import Footer from "~/components/astro/footer.astro" import Intro from "~/components/astro/intro.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 { getLanguagePaths } from "~/utils/langs" export function getStaticPaths() { return getLanguagePaths() } + +const lang = getLangFromUrl(Astro.url) +const pageMeta = lang === "zh" ? zh.pageMeta : en.pageMeta --- - +