Skip to content

feat: configurable filename template for materialized occurrences (#2126)#2134

Open
raphaelfaouakhiri wants to merge 3 commits into
callumalpass:mainfrom
raphaelfaouakhiri:patch/occurrence-filename-template
Open

feat: configurable filename template for materialized occurrences (#2126)#2134
raphaelfaouakhiri wants to merge 3 commits into
callumalpass:mainfrom
raphaelfaouakhiri:patch/occurrence-filename-template

Conversation

@raphaelfaouakhiri

Copy link
Copy Markdown

Implements #2126.

Materialized occurrences are currently named by dedup suffix (Pay rent-2, Pay rent-3), which carries no meaning. This PR adds a filename template for them:

  • New template variables (occurrence-only): {{occurrenceDate}} (2026-08-01), {{occurrenceWeek}} (2026-W31, ISO), {{occurrenceMonth}} (2026-08), {{occurrenceYear}}, {{occurrenceMonthName}}, and {{occurrencePeriod}} — which auto-selects the granularity from the parent's FREQ (daily→date, weekly→week, monthly→month, yearly→year; complex rules fall back to full date). All regular filename variables also work. Injected via the existing additionalVariables mechanism (same as ICS notes).
  • Global setting occurrenceFilenameTemplate (Task properties → Title card). Empty = current behavior (parent title + -N).
  • Per-parent override: a frontmatter property on the parent task (name configurable via occurrenceFilenameTemplateProperty, default occurrenceFilenameTemplate) overrides the global template for that task's occurrences. Implemented plugin-side because the core FieldMapping lives in @tasknotes/model.
  • The -N dedup suffix is kept as a collision safety net; no template error can abort materialization (falls back to sanitized title); i18n strings added for en + pt.

⚠️ Behavior change — default is ON: the setting ships as {{title}} — {{occurrencePeriod}}, so after updating, newly materialized occurrences get meaningful names by default (existing files are never renamed). I believe this is the better default for users, but if you prefer opt-in, flipping the default to "" in defaults.ts is a one-line change — happy to do it.

Known limitation (pre-existing behavior, unchanged): with storeTitleInFilename enabled, later editing an occurrence's title renames the file to the plain title (the old -N suffix was equally lost).

Tests: new unit suite for the variables/generator + 3 wiring tests in the materialization suite (20 passing); tsc clean; validated in my own vault (daily/weekly/monthly recurrences, global + per-parent override).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant