跳到主要内容

如何新增一篇文章

#站点#写作

这是功能底座的第二篇示例文章,同时充当「操作说明」。

第一步:新建文件

src/content/blog/ 下新建一个 .md 文件,文件名就是文章 URL

src/content/blog/my-first-post.md  →  /blog/my-first-post

第二步:填写 frontmatter

frontmatter 的字段由 src/content.config.ts 中的 schema 校验,写错会直接构建失败:

---
title: 文章标题
description: 列表页与 SEO 用的摘要
pubDate: 2026-09-13
tags: ['标签一', '标签二']
---

可选字段:

  • updatedDate:更新时间,会显示在文章页
  • draft: true:草稿,不进入构建产物

第三步:构建与部署

npm run build     # 产出 dist/
git add dist && git commit -m "post: xxx"

服务器侧只需 git pull,Nginx 指向仓库里的 dist/ 目录,无需安装 Node。

← 返回文章列表