# Sveltia CMS 的配置（Decap 兼容格式）。随站点部署到 /admin/，本地在
# http://localhost:1313/admin/ 用「Work with Local Repository」打开，不用登录。
# 线上 backend.base_url 指向 OAuth 中转 Worker（sveltia-cms-auth，部署在编辑组的 Cloudflare 账号）。
# 取舍的理由与上线记录见 docs/维护手册.md#cms。
#
# 为什么是两个文章 collection：Sveltia 按路径正则判断文件属于哪个 collection，
# 扁平的 YYYY-MM-DD-slug.md（375 篇 WordPress 迁移）和 YYYY-MM-DD-slug/index.md
# （181 篇公众号 + 今后新文章）没法用同一条正则覆盖。新文章一律走 bundle。
# 两个 collection 的字段完全一样，只差正文的 modes：迁移存档锁成源码模式。
# 改字段时两处都要改。
#
# 本地模式每次打开都会重新扫描 entry 和媒体目录，所以别把大目录
# （static/wp-content 有 2391 个文件）配成 media_folder。

backend:
  name: github
  repo: tyingknots/tyingknots
  branch: main
  base_url: https://sveltia-cms-auth.tyingknots2020.workers.dev
  # 保存默认不触发部署：提交信息带 [skip ci]，Cloudflare Pages 会跳过构建。
  # 编辑写完要上线时，把「草稿」取消勾选，用保存按钮旁的「保存并发布」。
  # 删除操作永远不跳过。本地模式不涉及。
  # 写了这一项 Sveltia 就会在页眉显示「发布更改」按钮，没有配置能关掉它；我们没配 deploy hook，
  # layouts/page/admin.html 里按按钮文字把它藏了（详见维护手册 CMS 章节）。
  skip_ci: true

site_url: https://tyingknots.net
display_url: https://tyingknots.net

# 多语言：对应 Hugo 的 index.md（中文，默认语言不带后缀）+ index.en.md（英文）。
# 新文章默认只建中文（initial_locales: default），要出英文版时在编辑器顶部的
# 语言开关里把 en 打开。字段上的 i18n: true 表示两种语言各写各的（标题、摘要、正文），
# duplicate 表示英文那边只读、照抄中文（slug、日期、草稿、题图、四组标签 —— 词名保持中文，
# 站点自己查译名）。规则与 docs/维护手册.md#translate 一致。
i18n:
  structure: multiple_files
  locales: [zh, en]
  default_locale: zh
  omit_default_locale_from_file_path: true
  initial_locales: default

# 全局媒体库：只给「关于我们」等站外文件用。文章图片进各自的 bundle。
media_folder: static/uploads
public_folder: /uploads

collections:
  - name: posts
    label: 文章
    label_singular: 文章
    folder: content/posts
    i18n: true
    format: yaml-frontmatter
    extension: md
    create: true
    delete: false
    # 新文章：content/posts/YYYY-MM-DD-<slug>/index.md，图片放同一目录
    slug: '{{fields.slug}}'
    path: '{{year}}-{{month}}-{{day}}-{{fields.slug}}/index'
    media_folder: ''
    public_folder: ''
    summary: '{{title}}'
    sortable_fields: [date, title]
    view_filters:
      - label: 草稿
        field: draft
        pattern: true
    fields:
      - label: 标题
        name: title
        i18n: true
        widget: string
      - label: 英文标题
        name: title_en
        widget: string
        required: false
        hint: 只在英文站（/en/）上顶掉中文标题；留空就两边都用中文标题。整篇的英文版是另一回事，见维护手册「翻译一篇文章」。
      - label: 英文 slug
        name: slug
        i18n: duplicate
        widget: string
        hint: 决定网址 /年/月/slug/。只用小写字母、数字和连字符；发表之后不要再改，改了等于换地址。
      - label: 发表时间
        name: date
        i18n: duplicate
        widget: datetime
        default: '{{now}}'
        format: 'YYYY-MM-DDTHH:mm:ssZ'
        hint: 年月决定网址里的 /年/月/，发表之后不要再改。
      - label: 草稿（勾上则不发布）
        name: draft
        i18n: duplicate
        widget: boolean
        default: false
        required: false
        hint: 勾选则不会发布到主站点。保存后会上传GitHub，可供其他人查看。
      - label: 摘要
        name: summary
        i18n: true
        widget: text
        required: false
        hint: 几句话。文章列表页、文章卡片会显示。检索文章时也会用到。
      - label: 题图
        name: featured_image
        i18n: duplicate
        widget: image
        required: false
        hint: 空着的话，文章列表页、文章卡片会显示正文的第一张图片。正文无图片则显示默认题图（斜线填充方块）。
      - label: 专题
        name: projects
        i18n: duplicate
        widget: select
        multiple: true
        required: false
        hint: 与 content/projects/ 下的目录一一对应；新专题先由维护者建目录（中英各一份 _index）再加进这份清单。文章卡片上露出的是专题（没有专题就是第一个主题）+ 体裁。
        options:
          - Corona读书会
          - 书讯
          - 全球运动
          - 公共人类学
          - 写作
          - 原住民视角
          - 哲学人类学
          - 它们
          - 巴以专题
          - 教与学
          - 文学与人类学
          - 格雷伯
          - 残障人类学
          - 焦点人类学家
          - 田野编
          - 结绳记疫
          - 艺术与人类学
          - 俄乌
          - 在场的教育
          - 应时民族志
          - 打工人类学
          - 报道｜非虚构｜民族志
          - 省县乡人类学
      - label: 主题
        name: topics
        i18n: duplicate
        widget: select
        multiple: true
        required: false
        hint: 与 content/topics/ 下的目录一一对应；新词先建目录再加进这份清单。
        options:
          - 体育
          - 写作
          - 劳工
          - 医疗
          - 国际政治
          - 多物种
          - 学科史
          - 学者
          - 宗教
          - 性别
          - 政治经济
          - 教育
          - 方法
          - 族群
          - 暴力
          - 残障
          - 环境
          - 理论
          - 社会运动
          - 科技
          - 经济
          - 艺术
          - 青年
          - 实践
          - 考古文博
          - 讯息
          - 都市
          - 文学
      - label: 体裁
        name: formats
        i18n: duplicate
        widget: select
        multiple: true
        required: false
        hint: 与 content/formats/ 下的目录一一对应。一般只填一个。
        options:
          - 书单
          - 书评
          - 其他
          - 原创
          - 影像
          - 时评
          - 民族志
          - 站务
          - 综述
          - 编译
          - 讲稿
          - 访谈
          - 读书会纪要
          - 课纲
          - 随笔
      - label: 地区
        name: regions
        i18n: duplicate
        widget: select
        multiple: true
        required: false
        hint: 与 content/regions/ 下的目录一一对应。
        options:
          - 东亚
          - 东南亚
          - 中东
          - 中亚
          - 中国
          - 全球
          - 北美
          - 南亚
          - 大洋洲
          - 拉美
          - 欧洲
          - 非洲
      - label: 正文（Markdown）
        name: body
        i18n: true
        widget: markdown
        modes: [raw, rich_text]
        hint: 默认是源码模式，工具栏可切富文本。

  - name: posts_flat
    label: 文章（WordPress 迁移存档）
    label_singular: 文章
    folder: content/posts
    i18n: true
    format: yaml-frontmatter
    extension: md
    create: false
    delete: false
    summary: '{{title}}'
    sortable_fields: [date, title]
    fields:
      - label: 标题
        name: title
        i18n: true
        widget: string
      - label: 英文标题
        name: title_en
        widget: string
        required: false
        hint: 只在英文站（/en/）上顶掉中文标题；留空就两边都用中文标题。整篇的英文版是另一回事，见维护手册「翻译一篇文章」。
      - label: 英文 slug
        name: slug
        i18n: duplicate
        widget: string
        hint: 决定网址 /年/月/slug/。只用小写字母、数字和连字符；发表之后不要再改，改了等于换地址。
      - label: 发表时间
        name: date
        i18n: duplicate
        widget: datetime
        default: '{{now}}'
        format: 'YYYY-MM-DDTHH:mm:ssZ'
        hint: 年月决定网址里的 /年/月/，发表之后不要再改。
      - label: 草稿
        name: draft
        i18n: duplicate
        widget: boolean
        default: false
        required: false
        hint: 勾选则不会发布到主站点。保存后会上传GitHub，可供其他人查看。
      - label: 摘要
        name: summary
        i18n: true
        widget: text
        required: false
        hint: 几句话。文章列表页、文章卡片会显示。检索文章时也会用到。
      - label: 题图
        name: featured_image
        i18n: duplicate
        widget: image
        required: false
        hint: 空着的话，文章列表页、文章卡片会显示正文的第一张图片。正文无图片则显示默认题图（斜线填充方块）。
      - label: 专题
        name: projects
        i18n: duplicate
        widget: select
        multiple: true
        required: false
        hint: 与 content/projects/ 下的目录一一对应；新专题先由维护者建目录（中英各一份 _index）再加进这份清单。文章卡片上露出的是专题（没有专题就是第一个主题）+ 体裁。
        options:
          - Corona读书会
          - 书讯
          - 全球运动
          - 公共人类学
          - 写作
          - 原住民视角
          - 哲学人类学
          - 它们
          - 巴以专题
          - 教与学
          - 文学与人类学
          - 格雷伯
          - 残障人类学
          - 焦点人类学家
          - 田野编
          - 结绳记疫
          - 艺术与人类学
          - 俄乌
          - 在场的教育
          - 应时民族志
          - 打工人类学
          - 报道｜非虚构｜民族志
          - 省县乡人类学
      - label: 主题
        name: topics
        i18n: duplicate
        widget: select
        multiple: true
        required: false
        hint: 与 content/topics/ 下的目录一一对应；新词先建目录再加进这份清单。
        options:
          - 体育
          - 写作
          - 劳工
          - 医疗
          - 国际政治
          - 多物种
          - 学科史
          - 学者
          - 宗教
          - 性别
          - 政治经济
          - 教育
          - 方法
          - 族群
          - 暴力
          - 残障
          - 环境
          - 理论
          - 社会运动
          - 科技
          - 经济
          - 艺术
          - 青年
          - 实践
          - 考古文博
          - 讯息
          - 都市
          - 文学
      - label: 体裁
        name: formats
        i18n: duplicate
        widget: select
        multiple: true
        required: false
        hint: 与 content/formats/ 下的目录一一对应。一般只填一个。
        options:
          - 书单
          - 书评
          - 其他
          - 原创
          - 影像
          - 时评
          - 民族志
          - 站务
          - 综述
          - 编译
          - 讲稿
          - 访谈
          - 读书会纪要
          - 课纲
          - 随笔
      - label: 地区
        name: regions
        i18n: duplicate
        widget: select
        multiple: true
        required: false
        hint: 与 content/regions/ 下的目录一一对应。
        options:
          - 东亚
          - 东南亚
          - 中东
          - 中亚
          - 中国
          - 全球
          - 北美
          - 南亚
          - 大洋洲
          - 拉美
          - 欧洲
          - 非洲
      - label: 正文（Markdown）
        name: body
        i18n: true
        widget: markdown
        modes: [raw]
        hint: WordPress迁移文章只开源码模式，避免富文本模式自动修改原始文章格式。

  - name: about
    label: 关于我们
    files:
      - name: about_zh
        label: 关于我们（中文）
        file: content/about.zh.md
        fields: &about_fields
          - { label: 标题, name: heading, widget: string }
          - { label: 标题链接, name: heading_url, widget: string, required: false }
          - { label: 导语, name: lede, widget: text }
          - { label: 「联系我们」栏标题, name: contact_title, widget: string }
          - label: 联系方式
            name: contact
            widget: list
            fields:
              - { label: 名称, name: label, widget: string }
              - { label: 显示文字, name: value, widget: string }
              - { label: 链接（可空）, name: url, widget: string, required: false }
          - { label: 「编辑团队」栏标题, name: team_title, widget: string }
          - { label: 「研究兴趣」小标题, name: team_research_label, widget: string }
          - { label: 「关注议题」小标题, name: team_focus_label, widget: string }
          - label: 编辑团队
            name: team
            widget: list
            fields:
              - { label: 姓名, name: name, widget: string }
              - { label: 英文名, name: name_en, widget: string }
              - { label: 照片（站内路径，如 /wp-content/uploads/2022/05/x.jpg.webp）, name: photo, widget: string, required: false }
              - { label: 研究兴趣, name: research, widget: text }
              - { label: 关注议题, name: focus, widget: text }
              - { label: 邮箱, name: email, widget: string, required: false }
          - label: 其余段落
            name: sections
            widget: list
            fields:
              - { label: 标题, name: title, widget: string }
              - { label: 正文, name: text, widget: text }
              - { label: 链接文字, name: link_label, widget: string, required: false }
              - { label: 链接, name: link_url, widget: string, required: false }

      - name: about_en
        label: About (English)
        file: content/about.en.md
        fields: *about_fields
