retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.01k stars 201 forks source link

Sidebar Search Issue #646

Closed altworkz closed 8 months ago

altworkz commented 8 months ago

Is it by design that the items with index.yml cannot be searched in the sidebar? The structure is:

folder1 --index.md (label: data configuration) folder2 --index.yml (label: data manipulation) folder3 --index.md (label: data structures)

The header title from folder2 is not showing in the sidebar search when you search for the word "data."

But, when the structure is:

folder4 --folder4.1 ----folder4.1.1 ------index.yml (label: data management)

The header appears in the search bar. I'm wondering if the header from folder4 is just showing because there are other .md files inside the folder4.1.1 with label: data something.

geoffreymcgill commented 8 months ago

Hi @altworkz. Any chance you could publish your project or a stripped down project to GitHub demonstrating how you have this all configured? Or even just attaching a simplified project structure as a .zip file to this issue?

I think the issue here is that label should only be used to set the label of the node in the left tree navigation and is not added to the search index, as the label is not actually used for any content of the page if the page also has a primary heading.

Here is a .zip of a simple project demonstrating how to reproduce the issue:

https://github.com/retypeapp/retype/files/13034608/label-issue.zip

The most basic .md page would be:

# My Page Title

You can change the left tree nav label by setting the label page config:

---
label: Custom label
---
# My Page Title

If I add a label, the left tree nav will now say Custom label, but that value is not added to the search index. Within the search, the term My Page Title will be result.

In generally, I would recommend not using the label or the title config. The best approach is to set the primary heading of each page with a proper heading, such as # My Page Title. Then the left tree nav label and breadcrumb label are generated automatically from the page H1 heading.

Retype will use the label config as the page heading when no page heading is available. This might be what is happening in your folder2 and folder4.1.1 scenarios.

When a page # H1 heading is available, Retype will add that value to the search index, even if a label is also set.

If only a label is available (no # H1 heading), then Retype will use the label for the tree nav label, the page heading, and also add that value to the search index.

Hope this helps.

altworkz commented 8 months ago

Hello @geoffreymcgill, I'll be attaching here the simplified project structure.

In this setup: image

We expected that 2 data manipulation will still show when "data" is searched. image

label-issue.zip

geoffreymcgill commented 8 months ago

We expected that 2 data manipulation will still show when "data" is searched.

Thanks. I have reproduced.

Looks like the filter is only filtering on the content files, not the folder names.

We will investigate and try to improve the functionality.

geoffreymcgill commented 8 months ago

This sidebar filter issue has been fixed and the fix will be included in the upcoming v3.6.0 release.

Screen Shot 2023-10-20 at 4 15 05 PM

https://github.com/retypeapp/retype/assets/62210/2cc600e0-5faa-4404-b89f-b36dfcac0e33