liamcain / obsidian-periodic-notes

Create/manage your daily, weekly, and monthly notes in Obsidian
MIT License
946 stars 62 forks source link

Weekly Notes Templates is not working #171

Open pourmand1376 opened 1 year ago

pourmand1376 commented 1 year ago

Hi, Thanks for creating this awesome obsidian plugin. I've been using your plugin for some time now. It is odd to me that the template for daily notes and monthly notes and yearly notes are working properly but the weekly notes template is not.

For example, I use this template at the top of my daily notes files and It actually replaces it with corresponding dates.

[[{{date:gggg-[W]ww}} | برنامه این هفته]] - [[{{date:gggg-MM}} | برنامه این ماه]] - [[{{date:gggg-[Q]Q}} | برنامه این فصل]] - [[{{date:gggg}} | برنامه امسال]]

But when I use this one for weekly notes, it doesn't replace any of those values:

[[{{date:gggg-MM}} | برنامه این ماه]] - [[{{date:gggg-[Q]Q}} | برنامه این فصل]] - [[{{date:gggg}} | برنامه امسال]]

and If I click the generated file, it says: "Filename can not contain any of the following characters". It is because it hasn't still replaced those values with an actual date.

What should I do?

More Information: I also use this code to see my week at a glance and it is working very well.

[[{{saturday:gggg-MM-DD}}|شنبه]] -[[{{sunday:gggg-MM-DD}} | یک شنبه]] - [[{{monday:gggg-MM-DD}}| دوشنبه]] - [[{{tuesday:gggg-MM-DD}}| سه شنبه]] - [[{{wednesday:gggg-MM-DD}}|چهارشنبه]] - [[{{thursday:gggg-MM-DD}}| پنج شنبه]] - [[{{friday:gggg-MM-DD}}|جمعه]]

It seems that date and time variables are not injected into weekly notes properly.

lukasoppermann commented 1 year ago

I think the problem is that the date is mutated here: https://github.com/liamcain/obsidian-periodic-notes/blob/main/src/main.ts#L218

I tried to fix this, but I can't get my fork to be loaded via BRAT.

A simple solution could be to replace this line with:

const filename = date.clone().format(format);

@liamcain could you please check if this is a viable solution. Happy to send a PR or for you to add it. Would be great as this should solve a lot of issues.

When I use {{date}} in my weekly template I get 2023-W11 which is exactly the format I have for the weekly note.

GamerGirlandCo commented 1 year ago

I think the problem is that the date is mutated here: https://github.com/liamcain/obsidian-periodic-notes/blob/main/src/main.ts#L218

I tried to fix this, but I can't get my fork to be loaded via BRAT.

A simple solution could be to replace this line with:

const filename = date.clone().format(format);

@liamcain could you please check if this is a viable solution. Happy to send a PR or for you to add it. Would be great as this should solve a lot of issues.

When I use {{date}} in my weekly template I get 2023-W11 which is exactly the format I have for the weekly note.

you need to create a new release on your forked repository which points to the one commit you added in order for BRAT to pick it up. the release assets should also contain the main.js, manifest.json and styles.css (if applicable)

lukasoppermann commented 1 year ago

Yeah, I did try but it did not work. Feel free to copy the change over and create a release. It would be great to be able to use it.

The release script had to many issues on my setup to get it to run. No idea why.

GamerGirlandCo commented 1 year ago

@lukasoppermann i pulled your PR into my fork, and built and released it manually. i also added a couple changes of my own that add time calculations to the weekly note template parser.

https://github.com/GamerGirlandCo/obsidian-periodic-notes/releases/tag/1.0.0-beta.4

cewood commented 1 year ago

@lukasoppermann @GamerGirlandCo will either of you open a PR with those changes to get them upstreamed here? Would be nice to have this be fixed for the wider community, and installable from the plugin manager without manual intervention.

Also I discovered this issue seems to also affect the monthly, quarterly, and yearly notes as well 😔

lukasoppermann commented 1 year ago

Hey @cewood I actually found out that this did not completely solve the issue.