SebastianMC / obsidian-custom-sort

Take full control over the order and sorting of folders and notes in File Explorer in Obsidian
GNU General Public License v3.0
302 stars 23 forks source link

index.md based folder note meta data not recognized #156

Closed octo-kumo closed 2 months ago

octo-kumo commented 3 months ago

Hi I have the following config in /index.md.

---
sorting-spec: |
  target-folder: ctf
  < a-z by-metadata: created
---

I want to sort the folders under /ctf, they all have index.md so the final path is something like /ctf/2024-ictf/index.md. Those files have frontmatter created but the sorting isn't working for some reason.

I know that the sorting is taking some effect because my other files under /ctf are changing order, just not the folders.

SebastianMC commented 3 months ago

Hi @octo-kumo

some questions arise when I read your question. Instead of jumping directly into a series of clarifying questions & answers interchange, let me guess your setup and what you want to achieve.

Guess 1:

Assume you want to keep a single sorting spec configuration in a single place in a single file and let the sorting specification be applied to all subfolders of /ctf.

In that case you should employ the following specification (and keep it in a single place):

---
sorting-spec: |
  target-folder: ctf/*
  < a-z by-metadata: created
---

The above spec will be applied to the ctf folder and all of its descendant subfolders (ctf/* wildard syntax is used for that).

Guess 2:

Assume you want to keep a separate sorting spec in each of index.md files in the subfolders for which you want to apply the sorting.

In that case each of the relevant index.md should include in frontmatter the spec like:

---
sorting-spec: |
  < a-z by-metadata: created
---

When you omit the target-folder: ......... specification the sorting is applied to the folder in which the sorting specification resides.

---

As you can see the specs for both guesses are variants of your original spec with minor addition / removal. That means you were very close!!!

If my guesses were not exactly what you'd expect, please come back with more details.

octo-kumo commented 3 months ago

First I placed guess 1's setup in /index.md.

Then I removed it and placed guess 2 in /ctf/index.md

After each change I did the right click > apply custom sorting.

Neither of the settings worked.   image image image

SebastianMC commented 3 months ago

Hi @octo-kumo

thanks for providing more details and the screenshots, now the scenario is clear!

Knowing exactly what you want to achieve it looks there is a bug in this edge scenario. For now, only the folder notes named exactly as the parent folder variant of folder notes is supported when scanning for folder's metadata. The index file folder notes aren't taken into account.

So, even if you correctly configure the plugin for index based folder notes (which you must have done):

2024-08-18_00-05-58

this configuration only tells the plugin to read sorting configuration from the index files, not the folder's metadata.

The fix to this bug is not trivial, when looking from the perspective of backward compatibility.

The configuration box in custom sort settings window allows entering multiple names and/or paths of notes to scan for sorting specifications. Thus, using that field to specify the index file is only one of its supported functions. In other words, if you enter some note names / paths, the plugin doesn't know if these are related to folder notes or not.

I need to find out some backward-compatible not-confusing smart way of extending the settings window, so that you can tell the plugin that index-file-based approach to folder notes is employed in the vault. Plus confirmation of the index file name (if different than index.md). So, a new checkbox and a new text box plus smart logic not to break backward-compatibility.

What do you think?

octo-kumo commented 2 months ago

Sounds good

SebastianMC commented 2 months ago

The improvement is available in the recent release 2.1.13

@octo-kumo please retest and let me know if it works for you

octo-kumo commented 2 months ago

yeb it works now thanks!