个人博客网站,基于 Astro 和 astro-erudite 模板构建。
博客文章存储在 blog/ 目录下,按分类组织:
blog/
├── Study/ # 学习相关
├── Learning/ # 技能学习
├── Recommendations/ # 推荐内容
└── Life/ # 生活日记
创建新文章:
- 在对应分类文件夹下创建
.md或.mdx文件 - 添加 frontmatter(文章元数据):
---
title: '文章标题'
description: '文章描述'
date: 2025-12-14
tags:
- tag1
- tag2
authors:
- yifan
---
你的文章内容...支持 Obsidian 图片插入语法 ![[image.png]]。图片可以放在:
- 文章同级目录
assets/子文件夹
在分类文件夹下创建子文件夹,并添加 index.mdx 作为系列首页:
blog/Study/
├── index.mdx # Study 分类首页
├── series-name/ # 子系列
│ ├── index.mdx # 系列首页
│ ├── part-1.md
│ └── part-2.md
└── standalone.md # 独立文章
编辑 src/components/bento/MusicCard.tsx:
const song = "歌曲名"
const artist = "艺术家"
const album = "专辑名"
const url = "https://music.apple.com/..." // Apple Music 链接更新专辑封面:替换 public/static/bento/music-cover.jpg
在 src/content/projects/ 创建 .mdx 文件:
---
title: '项目标题'
description: '项目描述'
date: 2025-12-14
url: 'https://project-url.com'
---
项目详细介绍...主页面位于 src/pages/work.astro,可以自定义布局和内容。
编辑 src/consts.ts 中的 SOCIAL_LINKS:
export const SOCIAL_LINKS: SocialLink[] = [
{
label: 'GitHub',
href: 'https://github.com/your-username',
},
{
label: 'Email',
href: 'mailto:your@email.com',
},
// ...
]同样在 src/consts.ts 中的 NAV_LINKS:
export const NAV_LINKS: NavLink[] = [
{ label: 'Home', href: withBase('/') },
{ label: 'Blog', href: withBase('/blog') },
// 添加更多...
]编辑 src/pages/index.astro,找到 About 卡片的文本部分并修改个人介绍。
编辑 src/components/bento/DiscordPresence.tsx 中的配置。
在 src/pages/index.astro 中找到:
<GithubCalendar username="sudo-yf" client:load />替换为你的 GitHub 用户名。
重要:仓库必须命名为 username.github.io 才能部署到根域名。
- 推送代码到 GitHub
- GitHub Actions 会自动构建和部署
- 网站将部署到
https://username.github.io/
# 安装依赖
npm install
# 开发服务器
npm run dev
# 构建
npm run build
# 预览构建结果
npm run previewyfblog/
├── blog/ # 博客内容(Markdown)
├── public/
│ └── static/
│ └── bento/ # 主页卡片资源
├── src/
│ ├── components/ # UI 组件
│ │ └── bento/ # 主页 Bento 卡片
│ ├── content/ # 其他内容
│ │ ├── authors/ # 作者信息
│ │ └── projects/ # 项目/工作
│ ├── layouts/ # 页面布局
│ ├── pages/ # 路由页面
│ └── consts.ts # 全局配置
└── astro.config.ts # Astro 配置
代码基于 astro-erudite 模板(MIT License)。
- 框架: Astro
- 样式: Tailwind CSS
- 组件: shadcn/ui
- 内容: MDX + Markdown
- 部署: GitHub Pages