# Decap CMS 配置（3.17.x）。文档：https://decapcms.org/docs/configuration-options/
# 内容仍以 Git 仓库里的 Markdown 为唯一来源；后台只是通过 GitHub API 读写这些文件。

backend:
  name: github
  repo: Zhong0118/moclab
  branch: main
  # 登录走本站的 Vercel Function（api/decap/*），GitHub OAuth 密钥只在服务端
  base_url: https://www.moclab.top
  auth_endpoint: api/decap/auth
  # 编辑流程分支对应的 Vercel Preview 部署（提交状态的 context 为 "Vercel"）
  preview_context: Vercel
  commit_messages:
    create: "内容：新建 {{collection}} “{{slug}}”"
    update: "内容：更新 {{collection}} “{{slug}}”"
    delete: "内容：删除 {{collection}} “{{slug}}”"
    uploadMedia: "内容：上传 “{{path}}”"
    deleteMedia: "内容：删除 “{{path}}”"

# 保存 = 写入独立分支 cms/posts/<slug> 并开 PR；发布 = 合并进 main，触发 Vercel 生产构建。
# 已发布文章再次编辑时，新版本先留在分支里，线上版本不变，直到再次发布。
publish_mode: editorial_workflow

# 本地调试：在仓库根目录运行 `npx decap-server@3.11.6` 后打开 http://localhost:4321/admin/
# 只在 localhost 生效，直接读写工作区文件，不经过 GitHub。
local_backend: true

locale: zh_Hans
site_url: https://www.moclab.top
display_url: https://www.moclab.top
logo_url: /favicon/favicon-light-128.png

# 全站媒体库（目前不用，文章附件跟文章放在同一目录，见下方集合配置）
media_folder: public/uploads
public_folder: /uploads

slug:
  encoding: unicode
  clean_accents: false
  sanitize_replacement: "-"

collections:
  - name: posts
    label: 文章
    label_singular: 文章
    description: >-
      对应 src/content/posts。保存进入“草稿”分支，在“工作流”里推进到“待发布”后发布。
      文章地址由文件路径决定，创建后修改标题或分类不会改变地址。
      首页精选由站点配置指定，按文章 ID 和配置顺序展示。
    folder: src/content/posts
    extension: md
    # 自定义格式：只改动编辑过的 frontmatter 键，正文逐字节写回（见 src/cms/frontmatter-format.mjs）
    format: moclab-frontmatter
    create: true
    delete: false
    # 列出子目录中的文章（如 tool/、algorithm/notes/）；新文章默认放在根目录
    # subfolders: false —— 目录按文件夹名显示；且任何路径变更只移动单个文件，不会连带移动整个目录
    nested:
      depth: 4
      summary: "{{title}}"
      subfolders: false
    slug: "{{slug}}"
    identifier_field: title
    summary: "{{published}}  {{title}}{{draft | ternary('（draft）', '')}}"
    sortable_fields: [published, title, category]
    view_filters:
      - label: 已合并但隐藏（draft）
        field: draft
        pattern: true
    view_groups:
      - label: 分类
        field: category
      - label: 年份
        field: published
        pattern: \d{4}
    # 附件与文章同目录、以相对路径引用，与现有文章一致
    media_folder: ""
    public_folder: ""
    editor:
      preview: true
    # 首页精选由 src/config/homeConfig.ts 指定，不在这里编辑；frontmatter 中已有的 pinned 不再生效，
    # 也没有对应控件，保存时原样保留（自定义格式只改动编辑过的键）。
    fields:
      - { label: 标题, name: title, widget: string }
      - label: 发布日期
        name: published
        widget: datetime
        format: YYYY-MM-DD
        date_format: YYYY-MM-DD
        time_format: false
        picker_utc: false
        default: "{{now}}"
      - label: 更新日期
        name: updated
        widget: datetime
        format: YYYY-MM-DD
        date_format: YYYY-MM-DD
        time_format: false
        picker_utc: false
        required: false
      - label: 摘要
        name: description
        widget: text
        required: false
        hint: 用于文章简介，建议写一两句话。留空时列表不显示简介；首页精选可使用站点配置中的单独简介。搜索摘要由实际命中的正文生成。
      - label: 标签
        name: tags
        widget: list
        required: false
        allow_add: true
        hint: 别名会自动归并，例如 git / Git、服务器 / server（见 src/config/taxonomy.ts）。
      - label: 分类
        name: category
        widget: string
        required: false
        hint: 可以选用已有分类，也可以直接写一个新分类，或留空（显示为“未分类”）。已有分类的别名会自动归并，例如 Server → 服务器、Blog → 建站。
      - label: 封面图
        name: image
        widget: image
        required: false
        choose_url: true
        hint: 可选。没有封面的文章同样完整显示。
      - label: 隐藏（draft）
        name: draft
        widget: boolean
        required: false
        default: false
        hint: >-
          与后台“草稿/待审/待发布”不同：后台状态只存在于分支里，从不上线；
          这个开关用于已经合并进 main 但暂不公开的文章，生产环境不会出现在页面、列表、搜索、RSS 和 sitemap 中。
      - label: 语言
        name: lang
        widget: string
        required: false
        hint: 留空表示与站点一致（zh_CN）。
      - label: 作者
        name: author
        widget: string
        required: false
      - label: 原文链接（转载时填写）
        name: sourceLink
        widget: string
        required: false
      - { label: 许可名称, name: licenseName, widget: string, required: false }
      - { label: 许可链接, name: licenseUrl, widget: string, required: false }
      - label: 开启评论
        name: comment
        widget: boolean
        required: false
        default: true
      - label: 访问密码
        name: password
        widget: string
        required: false
        hint: 文章加密是前端加密，密码会出现在仓库文件中，不能用于真正保密的内容。
      - { label: 密码提示, name: passwordHint, widget: string, required: false }
      - label: 正文
        name: body
        widget: markdown
        # 只用源码模式：富文本模式会重新序列化 Markdown，可能改写公式、指令和表格
        modes: [raw]
        sanitize_preview: true
