# Decap CMS: the form-based editor at /admin.
# Edits are saved as drafts (a branch + pull request); nothing reaches the
# live site until someone with merge rights presses Publish, which merges
# into `main` and triggers a rebuild and redeploy.
# Field names mirror the schema in src/content.config.ts; keep the two in sync.

backend:
  name: github
  repo: WENSHAO521/Panorama-Directory
  branch: main
  # GitHub sign-in is handled by worker/oauth.ts on the site itself.
  base_url: https://profiles.panorama-sg.com
  auth_endpoint: oauth/auth
  # The repo is public, so ask GitHub for the narrower public_repo scope.
  auth_scope: public_repo
  commit_messages:
    create: "Add scholar: {{slug}}"
    update: "Update scholar: {{slug}}"
    delete: "Remove scholar: {{slug}}"
    uploadMedia: "Upload photo: {{path}}"
    deleteMedia: "Delete photo: {{path}}"

publish_mode: editorial_workflow

# `npx decap-server` + `npm run dev` lets you try the editor on localhost
# against your local files, without signing in.
local_backend: true

locale: zh_Hans
site_url: https://profiles.panorama-sg.com
display_url: https://profiles.panorama-sg.com
logo_url: /assets/logos/favicon.png

# Photos live in src/assets/scholars and are written into each entry as
# ../../assets/scholars/<file>, the relative path Astro's image() expects.
# Keep these global: a collection-level relative media_folder resolves
# against the entry's own path, which a new entry doesn't have yet, so the
# photo library came up empty when adding a scholar.
media_folder: src/assets/scholars
public_folder: ../../assets/scholars

slug:
  encoding: ascii
  clean_accents: true

collections:
  - name: scholars
    label: 学者
    label_singular: 学者
    description: 每位学者一页，发布在 /board/<文件名>。保存后约 1–2 分钟网站自动更新。
    folder: src/content/scholars
    extension: md
    format: frontmatter
    create: true
    delete: true
    slug: "{{fields.name}}"
    identifier_field: name
    # Two lines on the photo cards: name, then role.
    summary: "{{name}}\n{{role}}"
    sortable_fields:
      - { field: order, label: 首页排序, default_sort: asc }
      - { field: name, label: 姓名 }
      - { field: role, label: 职位 }
    # The same tiers as the Editorial Board page (TIERS in src/lib/scholars.ts).
    view_filters:
      - { label: 主编, field: role, pattern: "Editor-in-Chief" }
      - { label: 执行编委, field: role, pattern: "^Executive Editorial Board" }
      - { label: 编委, field: role, pattern: "Editorial Board Member" }
    view_groups:
      - { label: 层级, field: role, pattern: "Editor-in-Chief|Executive Editorial Board|Editorial Board Member" }
      - { label: 职位, field: role }
    preview_path: "board/{{slug}}"
    # The right-hand pane renders the profile page (public/admin/preview.js).
    editor:
      preview: true
    fields:
      - { name: name, label: 姓名（英文）, widget: string, hint: "例如 Qin Shi。新建时网址由它生成（qin-shi）。" }
      - { name: nativeName, label: 中文名 / 母语姓名, widget: string, required: false }
      - name: order
        label: 首页排序
        widget: number
        value_type: int
        default: 99
        hint: 数字越小越靠前；最小的三位显示在首页“Featured Scholars”。
      - name: role
        label: 职位
        widget: string
        hint: >-
          决定在编委会页面的分组：含 “Editor-in-Chief” → 主编组；以 “Executive Editorial Board” 开头 → 执行编委；
          含 “Editorial Board Member” → 编委；其他 → 编辑部与研究。
      - { name: affiliation, label: 单位, widget: string }
      - { name: headline, label: 个人页副标题, widget: string, required: false, hint: 与单位不同时显示在个人页姓名下方，可留空。 }
      - { name: photo, label: 照片, widget: image, choose_url: false, hint: 建议竖版人像，网站统一按 4:5 居中裁切。 }
      - { name: summary, label: 简介（一两句）, widget: text, hint: 显示在名录卡片和搜索结果里。 }
      - { name: keywords, label: 研究方向关键词, widget: list, hint: 用英文逗号分隔，例如 Dance Education, Choreography }
      - name: email
        label: 邮箱
        widget: string
        required: false
        pattern: ['^$|^[^@\s]+@[^@\s]+\.[^@\s]+$', "请输入有效邮箱，或留空"]
      - name: loginEmails
        label: 自助编辑登录邮箱
        label_singular: 登录邮箱
        widget: list
        required: false
        field: { name: address, label: 邮箱, widget: string, pattern: ['^[^@\s]+@[^@\s]+\.[^@\s]+$', "请输入有效邮箱"] }
        hint: >-
          学者可在 /edit 用这些邮箱（以及上面的公开邮箱）登录，只能编辑自己的页面，提交后出现在“工作流”里等你发布。
          不在网站上显示，但仓库是公开的。学者不能修改职位、排序、邮箱和这一栏。
      - name: identifiers
        label: 学术 ID（ORCID 等）
        label_singular: 学术 ID
        widget: list
        required: false
        summary: "{{fields.label}}: {{fields.value}}"
        fields:
          - { name: label, label: 名称, widget: string, hint: "例如 ORCID、Web of Science ResearcherID、Scopus Author ID" }
          - { name: value, label: 编号, widget: string }
          - { name: href, label: 链接, widget: string, pattern: ['^https?://', "需以 http:// 或 https:// 开头"] }
      - name: sections
        label: 个人页板块（论文、任职、荣誉等）
        label_singular: 板块
        widget: list
        required: false
        summary: "{{fields.title}}"
        fields:
          - { name: eyebrow, label: 小标题, widget: string, required: false, hint: "例如 Research Output" }
          - { name: title, label: 标题, widget: string, required: false, hint: "例如 Selected Publications" }
          - name: layout
            label: 排版
            widget: select
            default: list
            options:
              - { label: 列表（用于论文）, value: list }
              - { label: 卡片网格（用于任职、荣誉、专长）, value: grid }
          - { name: columns, label: 卡片列数, widget: number, value_type: int, min: 2, max: 3, required: false, hint: 仅卡片网格用，2 或 3，可留空。 }
          - { name: compact, label: 紧凑小卡片, widget: boolean, required: false, default: false }
          - name: items
            label: 条目
            label_singular: 条目
            widget: list
            typeKey: type
            types:
              - name: publication
                label: 论文 / 著作
                summary: "{{fields.label}} | {{fields.title}} | {{fields.authors}} | {{fields.venue}}"
                fields:
                  # Helper only (public/admin/doi.js): fills the fields below and is dropped on save.
                  - { name: doi, label: DOI 自动填写, widget: doi, required: false, hint: "粘贴 DOI 后点“自动填写”，题目、作者、期刊、年份和链接会自动识别（Crossref / DataCite）" }
                  - { name: label, label: 标签, widget: string, hint: "通常是年份，也可以是 SSCI、AHCI、KCI、Book" }
                  - { name: title, label: 题目, widget: string }
                  - { name: authors, label: 作者, widget: string, required: false, hint: "例如 Shi, Q. (First Author)" }
                  - { name: venue, label: 期刊 / 出版信息, widget: string, required: false, hint: "可用 *斜体* 标记期刊名" }
                  - name: link
                    label: 链接
                    widget: object
                    required: false
                    collapsed: true
                    fields:
                      - { name: href, label: 网址, widget: string, required: false }
                      - { name: text, label: 显示文字, widget: string, required: false, hint: "例如 DOI 或 View article" }
              - name: card
                label: 卡片
                summary: "{{fields.title}}"
                fields:
                  - { name: title, label: 标题, widget: string }
                  - { name: meta, label: 副信息, label_singular: 副信息, widget: list, required: false, hint: 每条单独一行显示, field: { name: line, label: 副信息, widget: string } }
                  - { name: text, label: 段落, label_singular: 段落, widget: list, required: false, field: { name: line, label: 段落, widget: text } }
                  - { name: list, label: 要点列表, label_singular: 要点, widget: list, required: false, field: { name: line, label: 要点, widget: string } }
                  - name: entries
                    label: 条目（标题 + 说明）
                    label_singular: 条目
                    widget: list
                    required: false
                    fields:
                      - { name: title, label: 标题, widget: string }
                      - { name: meta, label: 说明, widget: string }
                  - { name: icon, label: 图标名, widget: string, required: false, hint: 当前设计不显示图标，可留空。 }
                  - { name: centered, label: 居中, widget: boolean, required: false, default: false }
      - { name: body, label: 个人简介（正文）, widget: markdown, buttons: [bold, italic, link, bulleted-list, numbered-list], editor_components: [] }
