Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requesting support for dynamic file names, such as diary notes. #203

Closed
kickTiger opened this issue Feb 3, 2024 · 8 comments
Closed

Requesting support for dynamic file names, such as diary notes. #203

kickTiger opened this issue Feb 3, 2024 · 8 comments
Labels
feature request New feature or request

Comments

@kickTiger
Copy link

Is your Feature Request Related to a Problem?

Requesting support for dynamic file names, such as diary notes.

I hope to support dynamic dates with the templater plugin for the following reasons:

Scenario to Implement

What I want to achieve is the ability to modify the diary for a specific date using Meta Bind, such as today.

Suppose there is a practical application scenario where I've designed a button using Meta Bind and placed it on the right side of the homepage. By clicking the button, I can change the daily status, such as recording exercise, reading, and so on.

To achieve this goal, I certainly can't generate a Meta Bind button every day. It's more convenient to modify it directly in the diary file.

Here are a few issues:

  • The diary file name changes every day, but the frontmatter fields to be modified remain the same.
  • It's only necessary to support getting today's date in the Meta Bind file name to solve this problem.

Current Challenges

  1. Meta Bind generated buttons don't support dynamically obtaining today's date.
  2. I want to use template syntax or obtain the date of the day. Currently, the templater plugin's dynamic query syntax supports generating today's date automatically.

For example:
Using the templater plugin's <%+ tp.date.now("YYYY-MM-DD") %> syntax, in reading mode, it will automatically fetch today's date.

  1. I attempted to combine this command with the Meta Bind plugin, but it failed. INPUT[toggle:<%+ tp.date.now("YYYY-MM-DD") %>#completed]

Describe the Feature you'd Like

Desired Functionality

I hope Meta Bind can be compatible with this dynamic template syntax of the templater plugin, allowing them to be used together. This would make Meta Bind more flexible.

For example, it could be used to create a panel to control diaries in Obsidian for studying, exercising, and recording regular work, making it very practical and interesting.

Additional Context

No response

@kickTiger kickTiger added the feature request New feature or request label Feb 3, 2024
@mProjectsCode
Copy link
Owner

mProjectsCode commented Feb 3, 2024

You can already do something like this by using e.g. JS Engine. I should add an example of that to the docs at some point.

But I am not adding support for this templater syntax.

@kickTiger
Copy link
Author

You can already do something like this by using e.g. JS Engine. I should add an example of that to the docs at some point.

But I am not adding support for this templater syntax.

Thank you very much for your reply.

Are you referring to the JS Engine in the project mProjectsCode/obsidian-js-engine-plugin?
I've looked at this project and found that it inserts code blocks. Does it support inline references within meta-bind?

If it's possible, would you have the time to give me some guidance or provide examples? I would greatly appreciate it.

@mProjectsCode
Copy link
Owner

I will add an example to the docs when i get around to it.

@JayHull
Copy link

JayHull commented Feb 11, 2024

I can get today's date from nldates-obsidian:nlp-today, but I can't figure out how to get it to updateMetadata.

Maybe there is something really obvious I'm missing. This is what I have so far.

style: primary
label: Set update date to today
actions:
  - type: updateMetadata
    bindTarget: last-updated
    evaluate: true
    value: this.app.commands.executeCommandById('nldates-obsidian:nlp-today');

Apologies if this isn't the right place to post this!

@JayHull
Copy link

JayHull commented Feb 14, 2024

style: primary
label: Set update date to today
actions:
  - type: updateMetadata
    bindTarget: last-updated
    evaluate: true
    value: this.app.commands.executeCommandById('nldates-obsidian:nlp-today');

Clicking the button puts the date at the cursor location, not in the metadata field.

@mProjectsCode
Copy link
Owner

yeah, because that's what the command you are running does.
You have to use an expression that evaluates to the current date. E.g. by using the JS Date API.

@mProjectsCode
Copy link
Owner

You can already do something like this by using e.g. JS Engine. I should add an example of that to the docs at some point.
But I am not adding support for this templater syntax.

Thank you very much for your reply.

Are you referring to the JS Engine in the project mProjectsCode/obsidian-js-engine-plugin? I've looked at this project and found that it inserts code blocks. Does it support inline references within meta-bind?

If it's possible, would you have the time to give me some guidance or provide examples? I would greatly appreciate it.

I just added some advanced use-case examples to the docs.
https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/guides/advancedusecases/

@JayHull
Copy link

JayHull commented Feb 16, 2024

yeah, because that's what the command you are running does. You have to use an expression that evaluates to the current date. E.g. by using the JS Date API.

Thanks for the suggestion. I've updated the button and it works as intended!

Here it is if anyone is interested, you'll need JS Engine plug-in installed & enabled.

style: primary
label: Set update date to today
actions:
  - type: updateMetadata
    bindTarget: last-updated
    evaluate: true
    value: new Date().toISOString().split('T')[0];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants