jackyzha0 / quartz

🌱 a fast, batteries-included static-site generator that transforms Markdown content into fully functional websites
https://quartz.jzhao.xyz
MIT License
7.09k stars 2.5k forks source link

Explorer `filterFn` does not see `index.md` files in folder children #1140

Open bachrc opened 5 months ago

bachrc commented 5 months ago

strongly related to #941

Describe the bug When using the filterFn on the Explorer component, the filter mechanism works for notes, but not for folders.

I've tried to add an index.md file in the folder i wanted to hide, with an excluded tag. Though, in the filterFn, on the FileNode of the folder, I would expect the index.md to me listed as the children. Though, it does not : the index file is not listed in the folder's children

To Reproduce

  1. Have the explorer component enabled, and the folder page plugin
  2. Create a folder pouet
  3. Create a index.md file in the folder pouet
  4. In the filterFn function of the Explorer component, the node of the folder is found, but in its children, we cannot see the index.md file

Expected behavior Even in not displayed, I would expect to find the index file in the node children

Screenshots and Source If applicable, add screenshots to help explain your problem.

You can help speed up fixing the problem by either

  1. providing a simple reproduction
  2. linking to your Quartz repository where the problem can be observed

Desktop (please complete the following information):

bachrc commented 5 months ago

Okay it's because when we are reaching the index file, we are not adding it to the tree : https://github.com/jackyzha0/quartz/blob/e3cfe1f22fb5054c09f845bc3317b85eb4b0e426/quartz/components/ExplorerNode.tsx#L69

Problem is: in the filterFn function, the content of the file is lost.

We could think that we could just put the index file attribute in the folder file, but this would introduce some regression. People following the docs already rely on the data attribute to know if a FileNode is a folder : https://github.com/jackyzha0/quartz/blob/e3cfe1f22fb5054c09f845bc3317b85eb4b0e426/docs/features/explorer.md?plain=1#L109

aarnphm commented 1 month ago

Hmm, i'm not sure, since the folder page is generated from FolderPage.tsx

You can filter it with slug.startswith(...) iirc