What I’m trying to do
Is it possible to limit a text search to a page as well as all of the pages that it links to or that link to it? This would be a gamechanging feature for me, but I haven’t figured it out yet.
Is it possible to limit a text search to a page as well as all of the pages that it links to or that link to it? This would be a gamechanging feature for me, but I haven’t figured it out yet.
I don’t know if there’s a better way to do this, but it’s easy to do with Dataview:
```dataviewjs
const searchString = 'asdf'
const me = dv.current().file
const matches = [...me.inlinks.array(), ...me.outlinks.array()]
.filter(async (page) => {
const file = app.vault.getAbstractFileByPath(page.path)
return (await app.vault.read(file)).match(new RegExp(searchString))
})
.map(x => dv.page(x.path).file.link)
dv.list(matches)
```
Paste this into any page, and it will search the inlinks and outlinks for that page for the string asdf
(or whatever you specify for the searchString
variable).
Using the sidebar search, where “term” is your search term and “note” is your note name: term (file:/^note$/ OR /\[\[(.+/)?note(\||\[)/)
(This assumes no duplicate note names.)
Not something you want to type every time, but you can save it (using the core Starred plugin or as an embedded search) and replace the term and note when you use it.
Details:
file:/^note$/
uses a regular expression to match the note name exactly (^
means the start of the string and $
the end).
The regular expression /\[\[(.+/)?note(\||\[)/
matches
Square brackets and pipes both mean things in regular expressions, so most of them are preceded by backslashes to mark them as just plain text, making the whole thing harder to read.
It was hard to pick just one solution. Thank you both!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.