Skip to content

Conversation

@hsayed21
Copy link

Summary

This PR adds support for dynamic date format placeholders in fileName and folderPath properties for both templaterCreateNote and createNote button actions. Users can now use moment.js format tokens wrapped in curly braces {format} to automatically generate date-based file names and folder paths.

Motivation

Users often need to create daily notes or organize notes by date with automated buttons. Previously, they had to use static file names or complex workarounds. This feature enables seamless date-based note organization directly from Meta Bind buttons.

Real-world Use Case

Creating daily journal entries with automatic date-based naming and folder organization:

- type: templaterCreateNote
  templateFile: "templates/Daily Template.md"
  folderPath: "001 Journal/{YYYY}/{MM}"
  fileName: "{YYYY-MM-DD}"
  openIfAlreadyExists: true

This creates notes at paths like: 001 Journal/2025/12/2025-12-18.md

Copilot AI review requested due to automatic review settings December 18, 2025 18:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for dynamic date format placeholders in the fileName and folderPath properties of button actions, enabling users to create date-based file names and organize notes by date automatically using moment.js format tokens wrapped in curly braces (e.g., {YYYY-MM-DD}).

Key Changes:

  • Implements date placeholder processing using regex pattern /\{([^}]+)\}/g to detect and replace format tokens
  • Processes both fileName and folderPath before file operations
  • Applies the same functionality to both createNote and templaterCreateNote button actions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
packages/core/src/fields/button/actions/TemplaterCreateNoteButtonActionConfig.ts Adds processDateFormatPlaceholders method and applies date processing to fileName and folderPath before creating notes with Templater
packages/core/src/fields/button/actions/CreateNoteButtonActionConfig.ts Adds processDateFormatPlaceholders method and applies date processing to fileName and folderPath before creating notes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

packages/core/src/utils/Utils.ts:391

		const validMomentFormat = /^[YMDdHhmsaAQWwXxZzGgEeSsokl:/\-\s.,[\]]+$/.test(format);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const processedFileName = processDateFormatPlaceholders(action.fileName);
const processedFolderPath = processDateFormatPlaceholders(action.folderPath);

if (action.openIfAlreadyExists && action.fileName) {
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks action.fileName instead of processedFileName. If date placeholder processing results in an empty string or the original action.fileName is just a placeholder that becomes empty, the openIfAlreadyExists logic may not work as intended. Consider checking processedFileName instead, or ensure the processed value is truthy before attempting to open the existing file.

Copilot uses AI. Check for mistakes.
const processedFileName = processDateFormatPlaceholders(action.fileName);
const processedFolderPath = processDateFormatPlaceholders(action.folderPath);

if (action.openIfAlreadyExists && action.fileName) {
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks action.fileName instead of processedFileName. If date placeholder processing results in an empty string or the original action.fileName is just a placeholder that becomes empty, the openIfAlreadyExists logic may not work as intended. Consider checking processedFileName instead, or ensure the processed value is truthy before attempting to open the existing file.

Copilot uses AI. Check for mistakes.
// Validate that the format string only contains valid moment.js tokens and delimiters
// Moment.js tokens: Y M D d H h m s S a A Q W w X x Z z G g E e o k l
// Common delimiters: : / - space . , [ ]
const validMomentFormat = /^[YMDdHhmsaAQWwXxZzGgEeSsokl:/\-\s.,[\]]+$/.test(format);
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex character class contains 'S' twice: once standalone and once in 'Ss'. While this doesn't break functionality (duplicate characters in character classes are simply ignored), it's redundant and could indicate a typo or oversight. Consider simplifying the pattern to remove the duplication.

Copilot uses AI. Check for mistakes.
action.folderPath ?? '',
action.fileName,
processedFolderPath ?? '',
processedFileName ?? 'Untitled',
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If processedFileName is an empty string (which can happen if action.fileName is an empty string), the nullish coalescing operator won't trigger and an empty string will be passed to mb.file.create(). Consider using a falsy check instead: processedFileName || 'Untitled' to handle empty strings properly.

Copilot uses AI. Check for mistakes.
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