# Sveltia CMS configuration — GitHub backend with an EXTERNAL OAuth provider.
# This is NOT Netlify-hosted, so we do NOT use git-gateway.
#
# Sveltia CMS is a drop-in, config-compatible successor to Decap/Netlify CMS.
# This config is intentionally Decap-compatible: the same `backend` block and
# external OAuth provider (base_url + auth_endpoint) keep working unchanged.
#
# The site is built by Jekyll and deployed as prebuilt static files to Vercel.
# Sveltia loads this file from /admin/config.yml at runtime in the browser.

backend:
  name: github
  repo: RyanKim17920/RyanKim17920.github.io
  branch: main

  # --- EXTERNAL OAUTH PROVIDER -------------------------------------------------
  # base_url is the ORIGIN (scheme + host, no trailing path) of the small OAuth
  # service you deploy from the sibling `oauth/` folder as its OWN Vercel project.
  # Sveltia starts the login flow by opening:  <base_url>/<auth_endpoint>
  # i.e. with the values below:  https://YOUR-OAUTH-SERVICE.vercel.app/auth
  # (this is the same Decap/Netlify-style handshake, so the OAuth service the
  #  `oauth/` folder already deploys needs NO changes.)
  #
  # TODO(Ryan): replace the placeholder below with your deployed OAuth service
  # origin (e.g. https://ryankim-cms-oauth.vercel.app). NO trailing slash.
  base_url: https://ryankimmeoauth.vercel.app # TODO: set to your deployed oauth/ service origin
  # auth_endpoint defaults to "auth" for the github backend (same default in
  # Sveltia); stated explicitly here to match the path served by the oauth/
  # service (/api/auth -> /auth).
  auth_endpoint: auth

  # --- COMMIT MESSAGE TEMPLATES ------------------------------------------------
  # Custom commit messages so the repo history reads cleanly instead of using
  # Sveltia's defaults. Nested under `backend`; per Sveltia these sub-keys are
  # camelCased (unlike the rest of the config) and Sveltia supports the same six
  # keys Decap does: create/update/delete/uploadMedia/deleteMedia/openAuthoring.
  # Available template vars include {{collection}}, {{slug}}, {{path}}.
  # Docs: https://sveltiacms.app/en/docs/backends  (and Decap parity:
  #        https://decapcms.org/docs/backends-overview/)
  commit_messages:
    create: '{{collection}}: create {{slug}}'
    update: '{{collection}}: update {{slug}}'
    delete: '{{collection}}: delete {{slug}}'
    uploadMedia: 'media: upload {{path}}'
    deleteMedia: 'media: delete {{path}}'
    openAuthoring: '{{message}}'

# --- SITE BRANDING / LINKS -----------------------------------------------------
# site_url: base URL of the published site; used by the CMS for various
#   functionality (and to build live-content links). Sveltia supports it and
#   would otherwise default to location.origin.
# display_url: the URL the CMS links to from its top bar ("View live site");
#   defaults to site_url if omitted. Set both for clarity.
# Docs: https://sveltiacms.app/en/docs/customization  (Decap parity:
#        https://decapcms.org/docs/configuration-options/)
site_url: https://ryankim.me
display_url: https://ryankim.me

# logo: branding shown on the login/entrance page (a square image works best).
#   Sveltia's preferred form is the `logo` object with `src` (an absolute path
#   OR full URL is accepted); the older top-level `logo_url` is deprecated in
#   Sveltia in favor of this. We point at the existing square favicon asset.
#   Docs: https://sveltiacms.app/en/docs/customization#custom-logo
logo:
  src: /assets/img/ryk-favicon-v2.svg

# Uploaded media (drag-drop images) are written to this repo path on commit.
# This folder lives under assets/img/, which al-folio's jekyll-imagemagick
# plugin watches to auto-generate responsive WebP variants. See SETUP.md.
media_folder: "assets/img/blog"
# public_folder is the URL prefix the CMS writes into Markdown for those images.
public_folder: "/assets/img/blog"

# --- DRAFT vs PUBLISH ---------------------------------------------------------
# We do NOT use `publish_mode: editorial_workflow`. Sveltia CMS does not yet
# support it: the official docs state "This feature from Netlify/Decap CMS is
# not yet supported in Sveltia CMS. It will be added before the 1.0 release."
# (https://sveltiacms.app/en/docs/workflows/editorial). Sveltia also targets a
# single branch and cannot auto-create per-post PR branches, so there is no
# clean way to keep a "draft" off `main` via the CMS today.
#
# Because EVERY commit to `main` auto-deploys, draft-vs-publish is instead done
# the Jekyll-native way, via the `published` boolean front-matter field below.
# Jekyll excludes any document with `published: false` from the build output
# (https://jekyllrb.com/docs/front-matter/ — "published: false" / shown only
# with the `--unpublished` flag, which CI does NOT pass). So a "draft" is still
# committed to `main` (and is recoverable/editable in the CMS), but it does NOT
# render on the live site. New posts default to published: false (draft); the
# user flips the "Published (live)" toggle ON and saves to make it go live.

collections:
  - name: "blog"
    label: "Blog Posts"
    folder: "_posts"
    create: true
    # Filenames must follow Jekyll's YYYY-MM-DD-slug convention.
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    extension: "md"
    format: "yaml-frontmatter"
    # --- SORTING: newest first by default; date + title sortable --------------
    # `sortable_fields` is the Decap key (also used by Sveltia). Sveltia extends
    # it with an object form: a `fields` list plus a `default` ({field,
    # direction}) so we can pre-select the default sort. `direction` accepts
    # `ascending`/`descending`. Newest date first = date / descending.
    # Docs: https://sveltiacms.app/en/docs/collections/entries  (Decap base key:
    #        https://decapcms.org/docs/configuration-options/)
    sortable_fields:
      fields: [date, title]
      default:
        field: date
        direction: descending
    # --- DRAFT vs PUBLISHED FILTERS ------------------------------------------
    # `view_filters` (Decap key, supported by Sveltia) adds quick filters to the
    # entry list. Each entry is {label, field, pattern}; a YAML boolean pattern
    # is matched against the `published` boolean (Decap's own docs use an
    # unquoted boolean pattern for a draft flag). "Drafts" = published:false,
    # "Published" = published:true.
    # Docs: https://decapcms.org/docs/configuration-options/  (Sveltia parity +
    #        extensions: https://sveltiacms.app/en/docs/collections/entries)
    view_filters:
      - label: "Drafts"
        field: published
        pattern: false
      - label: "Published"
        field: published
        pattern: true
    # Fields below match the al-folio post front matter inferred from
    # _layouts/post.liquid and the existing _posts/ entry.
    fields:
      # layout is fixed to "post" so every entry renders with post.liquid.
      - {
          label: "Layout",
          name: "layout",
          widget: "hidden",
          default: "post",
        }
      # DRAFT vs PUBLISH toggle. `published: false` => Jekyll drops the post
      # from the build, so it is committed to `main` but does NOT go live.
      # Defaults to false so a brand-new post is a draft until you flip this on.
      # Flip to true and save to publish (the next auto-deploy makes it live).
      - {
          label: "Published (live)",
          name: "published",
          widget: "boolean",
          default: false,
          hint: "OFF = draft (saved to the repo but NOT shown on the live site). Turn ON and save to publish.",
        }
      - { label: "Title", name: "title", widget: "string" }
      # al-folio dates are written as "YYYY-MM-DD HH:MM:SS" with no timezone.
      - {
          label: "Date",
          name: "date",
          widget: "datetime",
          date_format: "YYYY-MM-DD",
          time_format: "HH:mm:ss",
          format: "YYYY-MM-DD HH:mm:ss",
        }
      - {
          label: "Description",
          name: "description",
          widget: "string",
          required: false,
        }
      - {
          label: "Tags",
          name: "tags",
          widget: "list",
          required: false,
          hint: "Optional. Each tag links to /blog/tag/<tag>.",
        }
      - {
          label: "Categories",
          name: "categories",
          widget: "list",
          required: false,
          hint: "Optional. Each category links to /blog/category/<category>.",
        }
      - {
          label: "Show related posts",
          name: "related_posts",
          widget: "boolean",
          required: false,
          default: false,
          hint: "Leave off to hide the related-posts section at the bottom.",
        }
      # MATH: this site has `enable_math: false` globally in _config.yml and
      # turns MathJax on per-post via `enable_math: true` in front matter. The
      # CMS preview pane CANNOT render LaTeX (see SETUP.md "Math in the CMS"),
      # but turning this ON guarantees $$...$$ renders on the LIVE site once
      # published. Leave OFF for posts with no equations.
      - {
          label: "Enable math (MathJax)",
          name: "enable_math",
          widget: "boolean",
          required: false,
          default: false,
          hint: "Turn ON if this post uses LaTeX ($$...$$). Renders on the live site; the CMS preview cannot show math.",
        }
      # Body uses Sveltia's enhanced editor. The `markdown` widget is a
      # backward-compatible ALIAS of Sveltia's Lexical-based `richtext` widget,
      # so keeping `markdown` here works while giving us the better editor.
      #
      # For the best code-block + image experience:
      #   - modes: [rich_text, raw] keeps BOTH a rich editor (toolbar with a
      #     code-block button + drag/drop/paste images) AND a raw Markdown mode
      #     so you can hand-write or paste fenced ``` code blocks. The first
      #     entry is the default mode shown when the editor opens. (This is the
      #     Sveltia default, set explicitly here for clarity.)
      #   - editor_components: [code-block, image] are Sveltia's built-in
      #     components and are enabled by default; listed explicitly so the
      #     code-block and image insert buttons are guaranteed in the toolbar.
      # Images dropped/pasted here upload to media_folder (assets/img/blog) and
      # are written into Markdown using public_folder (/assets/img/blog).
      - {
          label: "Body",
          name: "body",
          widget: "markdown",
          modes: ["raw", "rich_text"],
          editor_components: ["code-block", "image"],
        }

  # --- NEWS / ANNOUNCEMENTS -----------------------------------------------------
  # al-folio's `_news/` collection holds short announcements shown on the about
  # page (and the standalone /news page). Fields below match EXACTLY what
  # _includes/news.liquid reads and the _config.yml `news` collection config:
  #   - the collection has `output: true` and a `defaults: { layout: post }`, so
  #     every item is given `layout: post` automatically; we set it here as a
  #     hidden field anyway (harmless, and matches the theme's shipped samples).
  #   - news.liquid reads `inline`, `date`, the body `content`, and (only when
  #     NOT inline) `title` + the generated `url`. It reads NO other fields, so
  #     we deliberately add nothing al-folio won't use.
  # INLINE (inline: true)  => the Markdown body is rendered directly inline in
  #   the news list; `title` is ignored. Use for short blurbs.
  # NOT INLINE (inline: false) => `title` is rendered as a link to the item's own
  #   generated page (built from the body via layout: post). `title` is required.
  # NOTE: to actually DISPLAY news on the about page, _pages/about.md front
  #   matter `announcements: enabled:` must be `true` (handled outside admin/).
  - name: "news"
    label: "News / Announcements"
    folder: "_news"
    create: true
    # al-folio sorts news by date (newest first); keep filenames date-prefixed.
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    extension: "md"
    format: "yaml-frontmatter"
    # Newest first by default (mirrors how the about/news page reverses by date).
    sortable_fields:
      fields: [date, title]
      default:
        field: date
        direction: descending
    fields:
      # layout is fixed to "post" (also the _config.yml collection default).
      - {
          label: "Layout",
          name: "layout",
          widget: "hidden",
          default: "post",
        }
      # al-folio news dates carry a time + timezone offset in the shipped
      # samples (e.g. 2026-01-01 00:00:00-0500). Mirror that exact shape.
      - {
          label: "Date",
          name: "date",
          widget: "datetime",
          date_format: "YYYY-MM-DD",
          time_format: "HH:mm:ss",
          format: "YYYY-MM-DD HH:mm:ssZZ",
        }
      # INLINE toggle. ON = short blurb rendered inline (title ignored).
      # OFF = a titled item that gets its own linked page.
      - {
          label: "Inline (short blurb)",
          name: "inline",
          widget: "boolean",
          default: true,
          hint: "ON = short announcement shown inline (no separate page; Title is ignored). OFF = a Title that links to its own page.",
        }
      # Title is only used for NON-inline items (it's the link text + page <h1>).
      # Optional here because inline items don't use it.
      - {
          label: "Title",
          name: "title",
          widget: "string",
          required: false,
          hint: "Required only when Inline is OFF (used as the link text and page heading).",
        }
      # related_posts: optional; suppresses the related-posts block on the
      # (still-generated) item page. The theme's shipped samples set it false.
      - {
          label: "Show related posts",
          name: "related_posts",
          widget: "boolean",
          required: false,
          default: false,
          hint: "Leave off to hide the related-posts section on the generated item page.",
        }
      # Body: the announcement text. For inline items this IS the announcement;
      # for non-inline items this becomes the item's own page content.
      - {
          label: "Body",
          name: "body",
          widget: "markdown",
          modes: ["raw", "rich_text"],
          editor_components: ["code-block", "image"],
        }
