# Decap CMS — https://decapcms.org/docs/configuration-options/
# Editors log in with GitHub (they need write access to the repo). The OAuth handshake runs
# in Cloudflare Pages Functions at /api/auth and /api/callback (see functions/api/).
# Locally: run `npm run cms` alongside `npm run dev`, then open http://localhost:4321/admin/
backend:
  name: github
  repo: telescopeinvesting/magicalmystery
  branch: main
  base_url: https://magicalmysterypokertour.com
  auth_endpoint: api/auth
local_backend: true

# Saving here writes straight to the site. A post with "Draft" ticked stays off the site: the same
# draft the main editor (/admin/) uses, so drafts show up in both.

site_url: https://magicalmysterypokertour.com
logo_url: /favicon.svg
media_folder: public/images/uploads
public_folder: /images/uploads

collections:
  - name: posts
    label: Posts
    label_singular: Post
    description: New posts appear at the top of the site. Imported Blogger posts are marked legacy.
    folder: src/content/posts
    create: true
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    summary: "{{date | date('YYYY-MM-DD')}} — {{title}}"
    sortable_fields: [date, title]
    view_filters:
      - { label: New posts, field: legacy, pattern: false }
      - { label: Blogger archive, field: legacy, pattern: true }
      - { label: Drafts, field: draft, pattern: true }
    fields:
      - { label: Title, name: title, widget: string }
      - label: AI assistant
        name: ai
        widget: ai-assist
        required: false
        hint: "Optional. Runs when you click Save; review what it added before publishing."
      - { label: Published, name: date, widget: datetime, format: "YYYY-MM-DDTHH:mmZ", date_format: DD MMM YYYY, time_format: "HH:mm", hint: "Posts on the same day are ordered by this time" }
      - { label: Draft, name: draft, widget: boolean, default: false, required: false, hint: "Ticked: kept off the site. Unticked: saving puts it live (and emails subscribers)." }
      - label: Where it happened
        name: places
        widget: relation
        collection: settings
        file: places
        search_fields: ["places.*.name"]
        display_fields: ["places.*.name"]
        value_field: "places.*.id"
        multiple: true
        required: false
        hint: "Leave empty to detect it from the text (venue keywords live in Site → Venues). New venue? Add it there first."
      - label: People in this post
        name: people
        widget: relation
        collection: cast
        search_fields: [name, nickname]
        display_fields: ["{{nickname}}"]
        value_field: "{{slug}}"
        multiple: true
        required: false
        hint: "Leave empty to find cast members by name in the text"
      - { label: Musing (no venue), name: musing, widget: boolean, default: false, required: false, hint: "Tick for posts not about a session, so no venue is detected" }
      - label: Extra tags
        name: tags
        widget: list
        required: false
        hint: "Optional. Tags for the venue and keywords (vegas, wsop, malta, home-game, omaha…) are added automatically."
      - { label: Header image, name: image, widget: image, required: false }
      - { label: Series id, name: series, widget: string, required: false, hint: "Optional. Trips to the same away venue are grouped automatically; set this to override, e.g. vegas-2026-06" }
      - { label: Series title, name: seriesTitle, widget: string, required: false, hint: "e.g. Vegas, June 2026" }
      - label: P&L tables (archive only)
        name: pnl
        widget: list
        required: false
        default: []
        hint: "Kept from the imported Blogger posts; not shown on the site. For new results use Money results below, which feed the Bankroll page."
        fields:
          - { label: Title, name: title, widget: string }
          - label: Rows
            name: rows
            widget: list
            fields:
              - { label: Label, name: label, widget: string }
              - { label: Amount, name: amount, widget: number, value_type: int, hint: Negative for losses }
          - { label: Total, name: total, widget: number, value_type: int, required: false }
      - label: Money results
        name: results
        widget: list
        required: false
        default: []
        hint: "Real money only (not chips) — these feed the Bankroll page"
        summary: "{{fields.kind}} · {{fields.event}}"
        fields:
          - { label: Type, name: kind, widget: select, options: [{ label: Cash game, value: cash }, { label: Tournament cash, value: tournament }, { label: Buy-in (didn't cash), value: buyin }, { label: Other, value: other }] }
          - { label: Event, name: event, widget: string, hint: "e.g. Pub game £1/£1, WSOP $1,500 NLHE" }
          - { label: Online, name: online, widget: boolean, default: false }
          - { label: Cash result / buy-in, name: amount, widget: number, value_type: float, required: false, hint: "Cash: net win (negative for a loss). Buy-in: the cost." }
          - { label: Prize won, name: prize, widget: number, value_type: float, required: false }
          - { label: Buy-in, name: buyin, widget: number, value_type: float, required: false }
          - { label: Currency, name: currency, widget: select, options: [GBP, USD, EUR], default: GBP }
      - { label: URL slug, name: slug, widget: string, required: false, hint: Leave blank to use the title }
      - { label: Imported from Blogger, name: legacy, widget: hidden, default: false, required: false }
      - { label: Body, name: body, widget: markdown, hint: "Use the Hand button (+ menu) to add a replayable hand after the paragraph that tells it. Guide: /admin/hands/" }

  - name: cast
    label: The Cast
    label_singular: Person
    description: Everyone named in the blog. Aliases decide which posts count as theirs.
    folder: src/content/cast
    create: true
    slug: "{{slug}}"
    identifier_field: nickname
    summary: "{{nickname}} ({{name}}) · {{role}}"
    fields:
      - { label: Nickname / display name, name: nickname, widget: string }
      - { label: Real name, name: name, widget: string }
      - { label: Names used in the posts, name: aliases, widget: list, hint: "Whole words, case-sensitive. e.g. The Baron, Baron, Tom" }
      - { label: Ignore these patterns, name: exclude, widget: list, required: false, hint: "Regex for other people sharing a name, e.g. Mark (?:Ramprakash|King)" }
      - { label: Gender, name: gender, widget: select, options: [{ label: Male, value: m }, { label: Female, value: f }, { label: Unknown, value: unknown }], default: unknown }
      - { label: Role, name: role, widget: select, options: [crew, regular, home-game, staff, pro, partner, other], default: regular }
      - label: Wireframe face
        name: face
        widget: object
        required: false
        collapsed: true
        fields:
          - { label: Hair, name: hair, widget: select, required: false, options: [short, spiky, bald, receding, side, curly, long, bob, bun, ponytail] }
          - { label: Beard, name: beard, widget: select, required: false, options: [none, stubble, full, goatee, moustache] }
          - { label: Glasses, name: glasses, widget: boolean, required: false }
      - label: Quotes from the blog
        name: quotes
        widget: list
        required: false
        summary: "{{fields.text}}"
        fields:
          - { label: Post, name: post, widget: relation, collection: posts, search_fields: [title], value_field: "{{slug}}", display_fields: ["{{date}} {{title}}"] }
          - { label: Quote, name: text, widget: text }
      - { label: Photo, name: photo, widget: image, required: false }
      - { label: Hide from the cast page, name: hidden, widget: boolean, default: false }
      - { label: Bio, name: body, widget: markdown, required: false }

  - name: settings
    label: Site
    files:
      - name: site
        label: Site settings
        file: src/data/site.json
        fields:
          - { label: Site title, name: title, widget: string }
          - { label: Description, name: description, widget: text }
          - { label: Author, name: author, widget: string }
          - { label: Since, name: since, widget: string }
          - { label: Homepage headline, name: heroTitle, widget: string }
          - { label: Homepage intro, name: heroText, widget: text }
      - name: places
        label: Venues
        file: src/data/places.json
        description: "Venues for the globe. Keywords are how a post's venue is detected (case-sensitive proper nouns; a lower-case keyword also matches capitalised). Away venues with a Trip name group into a series automatically."
        fields:
          - label: Venues
            name: places
            widget: list
            summary: "{{fields.name}} ({{fields.city}})"
            fields:
              - { label: Id, name: id, widget: string, hint: "lower-case-with-dashes, never change it once used" }
              - { label: Name, name: name, widget: string }
              - { label: City id, name: city, widget: string, required: false, hint: "One of the cities below, e.g. london, las-vegas, malta" }
              - { label: Kind, name: kind, widget: select, options: [club, casino, pub, home, festival, online] }
              - { label: Latitude, name: lat, widget: number, value_type: float, required: false, hint: "Right-click the spot in Google Maps to copy it" }
              - { label: Longitude, name: lon, widget: number, value_type: float, required: false }
              - { label: Keywords, name: keywords, widget: list, required: false, hint: "Words in a post that mean this venue, e.g. Loose Cannon, City 100" }
              - { label: Tags, name: tags, widget: list, required: false, hint: "Tags every post here gets, e.g. vegas, wsop" }
              - { label: Trip name, name: trip, widget: string, required: false, hint: "Away venues only, e.g. WSOP Malta: posts here within a few months form a series" }
              - { label: Generic, name: fallback, widget: boolean, required: false, default: false, hint: "Broad keyword like Vegas or online: only used if no specific venue matches" }
          - label: Cities
            name: cities
            widget: list
            summary: "{{fields.name}}, {{fields.country}}"
            fields:
              - { label: Id, name: id, widget: string }
              - { label: Name, name: name, widget: string }
              - { label: Country, name: country, widget: string }
              - { label: Latitude, name: lat, widget: number, value_type: float }
              - { label: Longitude, name: lon, widget: number, value_type: float }
      - name: rules
        label: Tag rules
        file: src/data/rules.json
        description: "Keyword rules that tag new posts automatically: a tag is added when its pattern appears in the title, or twice in the body."
        fields:
          - label: Tags
            name: tags
            widget: list
            summary: "{{fields.tag}}"
            fields:
              - { label: Tag, name: tag, widget: string }
              - { label: Pattern, name: pattern, widget: string, hint: "Regular expression, case-insensitive. Use | for alternatives, e.g. omaha|plo" }
      - name: ledger
        label: Money ledger (archive)
        file: src/data/ledger.json
        description: "Real-money results extracted from the old posts. Untick 'Count it' to drop a wrong entry; tick 'Checked' so re-imports leave it alone."
        fields:
          - label: Entries
            name: entries
            widget: list
            summary: "{{fields.date}} · {{fields.event}} · {{fields.net}} {{fields.currency}}"
            fields:
              - { label: Date, name: date, widget: string }
              - { label: Post, name: post, widget: relation, collection: posts, search_fields: [title], value_field: "{{slug}}", display_fields: ["{{date}} {{title}}"] }
              - { label: Type, name: kind, widget: select, options: [cash, tournament, buyin, other] }
              - { label: Event, name: event, widget: string }
              - { label: Online, name: online, widget: boolean, default: false }
              - { label: Net result, name: net, widget: number, value_type: float, hint: "Signed: tournament = prize minus buy-in" }
              - { label: Prize, name: prize, widget: number, value_type: float, required: false }
              - { label: Buy-in, name: buyin, widget: number, value_type: float, required: false }
              - { label: Currency, name: currency, widget: select, options: [GBP, USD, EUR] }
              - { label: Approximate, name: approx, widget: boolean, default: false }
              - { label: Quote from the post, name: quote, widget: text, required: false }
              - { label: Count it, name: include, widget: boolean, default: true }
              - { label: Checked by a human, name: checked, widget: boolean, default: false }
              - { label: confidence, name: confidence, widget: hidden, required: false }
      - name: photos
        label: Photo album
        file: src/data/photos.json
        description: "Photos come from the Google Photos album via `npm run import:photos`. Edit captions, the poker flag and post links here."
        fields:
          - label: Photos
            name: photos
            widget: list
            allow_add: false
            summary: "{{fields.takenAt}} · {{fields.event}} {{fields.caption}}"
            fields:
              - { label: Taken, name: takenAt, widget: string }
              - { label: Poker photo, name: poker, widget: boolean }
              - { label: Hide from site, name: hidden, widget: boolean, default: false }
              - { label: Event name, name: event, widget: string, required: false }
              - { label: Caption, name: caption, widget: string, required: false }
              - label: Linked posts
                name: posts
                widget: relation
                collection: posts
                search_fields: [title]
                value_field: "{{slug}}"
                display_fields: ["{{date}} {{title}}"]
                multiple: true
                required: false
              - { label: Keep these links (don't re-match), name: postsLocked, widget: boolean, default: false }
              - { label: id, name: id, widget: hidden }
              - { label: src, name: src, widget: hidden }
              - { label: width, name: width, widget: hidden }
              - { label: height, name: height, widget: hidden }
              - { label: video, name: video, widget: hidden }
              - { label: albumUrl, name: albumUrl, widget: hidden }
              - { label: file, name: file, widget: hidden, required: false }
