Skip to content

Latest commit

 

History

History
114 lines (94 loc) · 3.33 KB

File metadata and controls

114 lines (94 loc) · 3.33 KB

配置规范 (config.yaml)

配置文件示例

site:
  # 支持多语言对象形式或纯字符串(纯字符串时所有语言共用)
  title:
    zh_CN: "我的博客"
    zh_TW: "我的部落格"
    en: "My Blog"
  subtitle:
    zh_CN: "记录技术与生活"
    zh_TW: "記錄技術與生活"
    en: "Notes on tech and life"
  description:
    zh_CN: "分享技术与生活"
    zh_TW: "分享技術與生活"
    en: "Sharing tech and life"
  author: "张三"
  url: "https://example.com"
  language: "zh_CN"  # 站点默认语言

build:
  output_dir: "dist"
  enable_search: true
  posts_per_page: 10

theme:
  primary_color: "#2563eb"
  bg_color: "#fafafa"
  text_color: "#1a1a1a"
  nav:
    - label:
        zh_CN: "首页"
        zh_TW: "首頁"
        en: "Home"
      url: "/"
    - label:
        zh_CN: "关于"
        zh_TW: "關於"
        en: "About"
      url: "/about/"
  footer:
    text:
      zh_CN: "由 nib 驱动"
      zh_TW: "由 nib 驅動"
      en: "Powered by nib"
    show_theme_badge: true

配置项说明

Site 配置(站点元信息)

配置项 类型 必需 默认值 说明
site.title string | object 站点标题,支持多语言对象或纯字符串
site.subtitle string | object "" 站点副标题,支持多语言对象或纯字符串
site.description string | object "" 站点描述,支持多语言对象或纯字符串
site.author string "" 默认作者名
site.language string 站点默认语言(如 "zh_CN", "en")
site.url string "" 站点完整 URL(用于 RSS、sitemap)

Build 配置(构建相关)

配置项 类型 必需 默认值 说明
build.output_dir string "dist" 站点输出目录
build.enable_search bool true 是否生成 Pagefind 搜索索引并显示搜索 UI
build.posts_per_page number 10 每页文章数

Theme 配置(主题相关)

配置项 类型 必需 默认值 说明
theme.primary_color string "#2563eb" 主题色
theme.bg_color string "#fafafa" 背景色
theme.text_color string "#1a1a1a" 文字颜色
theme.nav array 默认导航 导航链接列表,label 支持多语言对象或纯字符串
theme.footer.text string | object "Powered by nib" 页脚文字,支持多语言对象或纯字符串
theme.footer.show_theme_badge bool true 是否显示主题标识

导航链接格式

theme:
  nav:
    - label:
        zh_CN: "首页"
        zh_TW: "首頁"
        en: "Home"
      url: "/"

每个导航项包含:

  • label: 显示文字,支持纯字符串或多语言对象
  • url: 链接地址

配置文件位置

配置文件放置在 content/config.yaml

数据层处理

数据层脚本读取 config.yaml 后:

  1. 解析 YAML 格式
  2. 生成 data/config.json
  3. 主题层读取 JSON 进行渲染
  4. CLI 根据 build.output_dirbuild.enable_search 控制输出目录和搜索索引生成

配置验证

构建时会验证配置正确性,包括必需字段和数据类型。