oleeskild / obsidian-digital-garden

MIT License
1.36k stars 125 forks source link

Frontmatter isn't parsed for files edited in external programs #176

Open Yetenol opened 1 year ago

Yetenol commented 1 year ago

Summary

Files whose dg-publish tag has been enabled in external programs are uploaded when running Digital Garden: Publish Multiple Notes in Obsidian, but their frontmatter is not converted to json and remains untouched. Thus the url, folder paths and all possible links are broken.

Motivation

I often publish notes, on a topic, only after all the subcategories are done. Therefore, I activate the dg-publish tag for many files through external programs.

I use programs that directly create finished markdown files with the dg-publish tag, without opening them again in Obsidian.

Steps to reproduce

  1. Open a vault with published notes in Obsidian
  2. Open the vault as a folder in Visual Studio Code
  3. Press Ctrl + Shift + F to replace in all files
  4. Replace ^dg-publish: true$ using regular expression with dg-publish: ignore on multiple files
  5. Open Obsidian and run Digital Garden: Publish Multiple Notes
    • Looking at the digital-garden repository confirms, that the modified notes have been deleted, since we just disabled their publish tag
  6. Open Visual Studio Code again
  7. Replace ^dg-publish: ignore$ using regular expression with dg-publish: true on all files
  8. Open Obsidian
  9. Open only one of the modified files
  10. Run Digital Garden: Publish Multiple Notes
  11. Looking at the digital-garden repository reveals the bugs

Problem

The file we also opened in Obsidian was parsed correctly. It's update commit in the digital-garden repository shows a correctly parsed frontmatter at the beginning:

---
{"dg-publish":true,"dg-permalink":"home","permalink":"/home/","tags":["gardenEntry"],"dgEnableSearch":true}
---

On the other hand, the file we didn't open in Obsidian was still published, but it's frontmatter wasn't parsed as you can see in it's update commit:

---
dg-publish: true
dg-permalink: 'powershell'
---

Therefore the page modifications aren't applied. No permalink is set. The url is wrong and does't correctly include the subfolder. You cannot enable/disable page-specific settings.

pawelel commented 1 year ago

Hi, the difficulty may be related to the fact that Obsidian indexes every open file and its contents in the .Obsidian file. If changes were made externally, Obsidian will not take them into account. The issue was reported on the forum in 2021: https://forum.obsidian.md/t/provide-a-way-to-re-index-files-that-have-been-changed-outside-of-obsidian/20370 Similar question was already answered here: #172