Skip to content

s1313s/xiajing-blog

Repository files navigation

夏境·笔记

一个基于 Astro 6、Markdown Content Collections 和纯静态构建的个人命理博客系统。项目适合“每日发布命理笔记”的工作流,不依赖数据库,不使用 SSR,构建产物可直接部署到 Cloudflare Pages。

技术栈

  • Astro 6
  • Astro Content Collections
  • 纯静态站点
  • Cloudflare Pages

安装方法

npm install

本地运行

npm run dev

默认地址为 http://localhost:4321

如果你在 Windows PowerShell 下想直接启动,也可以运行:

.\start.ps1

新建文章方法

新建一篇默认放到 src/content/blog/notes/ 的命理笔记:

npm run new-note -- --title="文章标题"

在 Windows PowerShell 下也可以直接运行:

.\new-note.ps1 -Title "文章标题"

脚本会自动完成这些动作:

  • 以当天日期生成文件名,例如 2026-03-17-文章标题.md
  • 自动生成 slug
  • 写入完整 frontmatter 模板
  • 默认分类为 命理笔记
  • 默认 draft: true

内容目录

博客内容根目录固定为:

src/content/blog/
├─ notes/
├─ cases/
├─ classics/
└─ thoughts/

发布流程

  1. npm run new-note -- --title="..." 创建草稿。
  2. 编辑生成的 Markdown 文件,补全正文、标签、专题和摘要。
  3. draft 改为 false
  4. 本地执行 npm run build 确认静态构建通过。
  5. 推送到 Git 仓库,由 Cloudflare Pages 自动构建发布。

Cloudflare Pages 部署说明

方式一:连接 Git 仓库

  1. 将项目推送到 GitHub、GitLab 或 Bitbucket。
  2. 在 Cloudflare Pages 中点击 Create a project
  3. 选择你的 Git 仓库。
  4. 构建配置填写:
    • Framework preset: Astro
    • Build command: npm run build
    • Build output directory: dist
    • Node.js version: 22
  5. 完成首次部署。

方式二:手动上传构建产物

npm run build

然后将 dist/ 目录上传到 Cloudflare Pages。

自定义域名上线说明

  1. 在 Cloudflare Pages 项目中打开 Custom domains
  2. 添加你的正式域名。
  3. 等待 Cloudflare 完成 DNS 验证和证书签发。
  4. astro.config.mjs 里的 site 改为正式域名。
  5. 如需更新站点联系邮箱,可同步修改 src/utils/site.ts 中的 emailsiteUrl

SEO 与静态输出

项目已包含:

  • canonical
  • 基础 OG meta
  • RSS:/rss.xml
  • sitemap
  • robots.txt
  • 自定义 404 页面
  • public/_headers
  • public/_redirects

构建命令

npm run build

静态文件输出到 dist/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors