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

Incorrect daily notes retrieved from filename templates that generate subdirectories #21

Open
ardunster opened this issue Dec 1, 2021 · 5 comments

Comments

@ardunster
Copy link

A couple of us have reported issues on the obsidian-calendar-plugin repo (Issue 216 and Issue 184 ) related to the Calendar plugin placing notes incorrectly when they are generated using a template that creates subdirectories.

I tracked this down I think to this call here:

return getDateFromFilename(file.basename, granularity);

Because file.basename is only the part of the file after the final /, it does not account for subdirectory structure inside the template folder at all.

Maybe this would be a quick fix for someone more familiar with the codebase? If not, I could fork it and take a stab at it, but I have not done any development for Obsidian and would have to figure out how to set up an environment, etc.

@liamcain
Copy link
Owner

Hi @ardunster, thanks for doing the digging!

I am embarrassingly behind on the calendar plugin bug reports but I'm not sure this is the issue. Both periodic notes and the calendar plugin intentionally only look at the basename for disambiguating dates. There was a long discussion here about why, but the TL;DR is that some users keep their notes in nested directories within their daily note folder and even archive older notes each month. There have been a lot of other issues and requests since that decision was made to make it support different workflows though, including YYYY/MM/DD.md and other variants where the basename is ambiguous.


I think the better fix is probably:

  1. First check the exact path
  2. Fallback to the current behavior

I'll try to play around with this on the weekend.

@jpolchlo
Copy link

jpolchlo commented Feb 11, 2022

Hi, I'd like to poke this issue as I encountered a related problem. I have my daily notes folder with files having the YYYY-mm-DD.md name format. But I also have a folder under daily notes containing sidecar files with the same names. The calendar plugin seems to confuse the two, linking to the contents of the sidecar (subfolder) file, not the actual daily note in the top-level daily notes directory. Oddly, this mistake doesn't happen for all days. I am not sure of the pattern, though.

@pae23
Copy link

pae23 commented Aug 25, 2023

I had the same issue configuring Obsidian "date format" of "Daily notes" with "YYYY/MM/DD".
In this case, all the time it use the file with the correct day but the wrong month and years (it use the first year and first month created). For example today 2023-08-25, it should use 2023/08/25.md but it return 2017/05/25.md (because I start using it in May 2017).

When I dig in the code, I understand why:
In : obsidian-daily-notes-interface/src/daily.ts

const dailyNotes: Record<string, TFile> = {};  
Vault.recurseChildren(dailyNotesFolder, (note) => {  
  if (note instanceof TFile) {  
    const date = getDateFromFile(note, "day");  
    if (date) {  
      const dateString = getDateUID(date, "day");  
      dailyNotes[dateString] = note;  
    }  
  }  
});

We can notice that it will recursively parse the folder (value in "new file location") which is not the folder inlucindg the date time as this part was added in the "Daily note" part , in my case "new file location" = "content/diary/" and "daily note = "YYYY/MM/DD" and that it only focus on the day.

The workaround I found to mitigate this issue, is to add years and month to my filename using this variable in "daily note" =
"YYYY/MM/YYY-MM-DD", it doesn't the same result but it's ok for me.

Hope my 2 cents will help to fix it.

@obvionaoe
Copy link

@liamcain any news regarding this? It's still broken for people who have a directory structure like: daily/2023/09/18.md

@Erallie
Copy link

Erallie commented Aug 7, 2024

Is the dev still working on this?

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

No branches or pull requests

6 participants