silverbulletmd / silverbullet

The knowledge tinkerer's notebook
https://silverbullet.md
MIT License
2.36k stars 169 forks source link

Customize template for search results (enhancement) #747

Open damufo opened 7 months ago

damufo commented 7 months ago

From https://community.silverbullet.md/t/customize-search-results/235

When file name is not relevant (add image). For example for zettelkasten system.

How can I customize search results?

This is an enhancement request.

It is about allowing to modify the model that shows the searches so that it can show other fields besides the only the file name. It would be to use the name of the file to create the links but it would be better to show the yaml title if it has it and if it doesn't have it it can show the first level 1 header that the document has or show the first x characters of the document, let's imagine a short note without more than a few comments.

Image imaxe

Very thanks.

justyns commented 2 months ago

I was thinking of making a few changes to the results page, mostly to show snippets of the found text. Would it be better to offer the ability of specifying a template for the results instead? E.g. in SETTINGS:

searchResultsTemplate: [[Library/Core/Query/SearchResultsPage]]

and then Library/Core/Query/SearchResultsPage:

---
tags: template
description: A search result item
---
## [[{{name}}]] (score {{score}})
> {{snippet}}