2 分钟阅读
博客集合

blog 集合位于 src/content/blog

它的基本结构如下:

📁 /src/content/blog
└── 📁 post-1
      └── 📄 index.md
└── 📁 post-2
      └── 📄 index.mdx

在上面的例子里,会根据 .md.mdx 文件自动生成两篇静态文章。文件夹名称就是最终的 slug:

  • https://example.com/blog/post-1
  • https://example.com/blog/post-2

所有内容都需要先写 YAML frontmatter,也就是三条横线包裹的元信息:

---
title: "My cool new title"
description: "A description of my content."
date: "Mar 22 2024"
draft: false
---

元信息字段

字段必填类型说明
titlestring内容标题,也会用于 SEO 和 RSS。
descriptionstring内容简介,也会用于 SEO 和 RSS。
datestring必须是可解析的日期字符串。
draft否*booleandraft: true 时不会被公开发布。

剩下的事情就很简单了:在元信息下面写正文。

---
title: "My cool new title"
description: "A description of my content."
date: "Mar 22 2024"
draft: false
---

### 开始写吧

这里是一段正文内容。

🎉 恭喜,现在你已经拥有一个博客集合了。