I'm quite new to SilverBullet. First of all, I'd like to say a huge thank you to the author for creating such an amazing tool β its features and capabilities are truly impressive!
I rely heavily on the Linked Mentions block to connect my pages and navigate back links. However, for some of my more frequently referenced pages, the Linked Mentions section has grown quite large, making it difficult to find specific entries.
Is there a way to filter or search within the Linked Mentions block? For example, filtering entries by tag, by another linked page, or simply running a quick search/filter on the list?
I feel like this would completely solve my issue with growing backlink lists.
Here's the Linked Mentions override I use. Simply place the code in a space-lua block in any page and it will supercede the default Linked Mentions. I tweaked the template for each Linked Mention entry. You can easily modify the query to apply your own filtering and sorting
-- priority: 10
widgets = widgets or {}
local mentionTemplate = template.new [==[
*[[${_.ref}|${_.ref}]]*:
> ${_.snippet}
]==]
-- configuration schema
config.define("std.widgets.linkedMentions", {
type = "object",
properties = {
enabled = schema.boolean(),
}
})
-- configuration default values
config.set("std.widgets.linkedMentions", {
enabled = true,
})
function widgets.linkedMentions(pageName)
pageName = pageName or editor.getCurrentPage()
local linkedMentions = query[[
from index.tag "link"
where _.page != pageName and _.toPage == pageName
order by _.page desc, _.pos
]]
if #linkedMentions > 0 then
return widget.new {
markdown = "# Linked Mentions\n"
.. template.each(linkedMentions, mentionTemplate)
}
end
end
```
The Linked Mentions code you need to override in sb 2.12 has changed slightly. Here is my override in which all I wanted to do was have the Linked mentions show up in page name, descending order, so I just altered the order by line of code
Just include on any page and do a system reload.
-- priority: 10
widgets = widgets or {}
local mentionTemplate = template.new [==[
**[[${_.page}@${_.start}]]**:
${_.snippet}
]==]
function widgets.linkedMentionsMarkdown(pageName)
pageName = pageName or editor.getCurrentPage()
local linkedMentions = query[[
from r = index.relations()
where r.page != pageName
and r.to == pageName
and r.kind != "co-mention"
order by r.page desc, r.range[1]
select mentionTemplate({
page = r.page,
snippet = r.snippet,
start = r.range[1],
})
]]
if #linkedMentions == 0 then
return ""
end
return table.concat(linkedMentions)
end
function widgets.linkedMentions(pageName)
local md = widgets.linkedMentionsMarkdown(pageName)
if md != "" then
return widget.new {
markdown = "# Linked Mentions\n" .. md
}
end
end