WHAT I’M TYRING TO DO
I have a file I-mentioned-this-file.md that look like this:
// I-mentioned-this-file.md sample
# h1
here I mentioned [[the-file]] once.
## h2
I miss [[the-file]] again
And I was trying to get all links to the current file(this-file.md ) with dataviewu using this query :
dv.list(
dv.pages(`[[${this.currentFilePath}]]`)
.map(page => page.file.link))
which would results lists of titles of links like the following.
[[I-mentioned-this-file]]
But actually in file I-mentioned-this-file.md
, I have multiple mention parts, and I want to show them individually.
DESIRED OUTPUT
// I want the result looks like this
// in `link + " :: " + paragraph` format
- [[I-mentioned-this-file]] > h1 :: here I mentioned [[the-file]] once.
- [[I-mentioned-this-file]] > h2 :: I miss [[the-file]] again
THINGS I’VE TRIED
I’ve found out if you mentioned in lists - [[this-file]] is mentioned
, you can they query using file.lists.sections
and file.lists.text
.
But I really dont find a way to get text of the linked paragraph.
How can I imporve the query?
gino_m
April 3, 2024, 5:06pm
2
It’s not possible to retrieve any paragraph content with DataView.
You can use javascript using DV API.
I have tinkered with this kind of before on occasions but my javascript is probably bulky or unclean (but functional and not destructive in any way):
Hi
I have found a piece of brilliant code which is working very well. It collects text from my notes that includes a specific word. But I would also like to show the backlink - the note where the text is collected from. The piece of code:
dv.list(dv.pages().file.lists.where(t => t.text.includes("Specifik word")).map((t ) => t.text))
I would like it to render something like this:
Backlink. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pretium nisi eu pellentesque feugiat. Pe…
I slight upgrade would be to also give context on those files:
// Define folderstoCheck array (Add your own folders)
const folderstoCheck = ["Placeholder1", "Placeholder2"];
let currentPage = dv.current().file.path;
let pages = new Set();
let stack = [currentPage];
while (stack.length > 0) {
let elem = stack.pop();
let meta = dv.page(elem);
if (!meta) continue;
for (let inlink of meta.file.inlinks.array()) {
if (pages.has(inlink.path)) continue;
// Check if an…
There have been at least 2-3 similar requests in the Help section in the last couple of months but they elude me now.
built in search block:“[[link-name]]”
Also, the linked mentions at the bottom of that note will list all blocks to that note.
gino_m
April 3, 2024, 6:52pm
4
Cannot copy content to another note or integrate in any way currently, unfortunately.
Although inline queries can be used, granted.
system
Closed
July 2, 2024, 6:52pm
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.