Skip to content

Commit 7e087da

Browse files
peeeyowepwalsh
andauthored
feat(backlinks): make relative to root links searchable (#626)
Co-authored-by: Pete <epwalsh10@gmail.com>
1 parent 89cab28 commit 7e087da

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Added
11+
12+
- Added relative to root markdown links as search pattern for backlinks.
13+
1014
### Fixed
1115

1216
- Searching for notes by file name is case insensitive.

lua/obsidian/client.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,22 +1303,30 @@ Client.find_backlinks_async = function(self, note, callback, opts)
13031303
search_terms[#search_terms + 1] = string.format("[[%s|", ref)
13041304
-- Markdown link without anchor/block.
13051305
search_terms[#search_terms + 1] = string.format("(%s)", ref)
1306+
-- Markdown link without anchor/block and is relative to root.
1307+
search_terms[#search_terms + 1] = string.format("(/%s)", ref)
13061308
-- Wiki links with anchor/block.
13071309
search_terms[#search_terms + 1] = string.format("[[%s#", ref)
13081310
-- Markdown link with anchor/block.
13091311
search_terms[#search_terms + 1] = string.format("(%s#", ref)
1312+
-- Markdown link with anchor/block and is relative to root.
1313+
search_terms[#search_terms + 1] = string.format("(/%s#", ref)
13101314
elseif anchor then
13111315
-- Note: Obsidian allow a lot of different forms of anchor links, so we can't assume
13121316
-- it's the standardized form here.
13131317
-- Wiki links with anchor.
13141318
search_terms[#search_terms + 1] = string.format("[[%s#", ref)
13151319
-- Markdown link with anchor.
13161320
search_terms[#search_terms + 1] = string.format("(%s#", ref)
1321+
-- Markdown link with anchor and is relative to root.
1322+
search_terms[#search_terms + 1] = string.format("(/%s#", ref)
13171323
elseif block then
13181324
-- Wiki links with block.
13191325
search_terms[#search_terms + 1] = string.format("[[%s#%s", ref, block)
13201326
-- Markdown link with block.
13211327
search_terms[#search_terms + 1] = string.format("(%s#%s", ref, block)
1328+
-- Markdown link with block and is relative to root.
1329+
search_terms[#search_terms + 1] = string.format("(/%s#%s", ref, block)
13221330
end
13231331
end
13241332
end

0 commit comments

Comments
 (0)