You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m totally new to dataviewjs and typescript (actually not familiar with any code at all) so this probably is a dumb question.
I’ve tried to achieve a dv.table() with certain text lines in a markdown file and also with certain tags (for file tags, not the tag comes with the lines ).
for example,
|filename|lines with background color|#tags|
I’ve found this code:
const files = app.vault.getMarkdownFiles()
let arr = files.map(async(file) => {
const content = await app.vault.cachedRead(file);
//turn all the content into an array
let lines = await content.split("/n").filter(line => line.includes("background-color: #"))
return ["[["+file.name.split(".")[0]+"]]", lines]
})
Promise.all(arr).then(values => {
console.log(values)
//filter out files without "Happy" and the note with the dataview script
const exists = values.filter(value => value[1][0] && value[0] != "[[exclude]]")
dv.table(["file", "lines"], exists)
})
I think probably I need to add some filter to files = app.vault.getMarkdownFiles() to filter files with certain tags,
or find a way to display the file.tags for the results.
However, I cannot figure out how to do it.
I've ask a same question at obsidian forum but no one answered.
Hoping someone could help me with this!
Or just let me know whether this is possible.
Thanks in advance!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I’m totally new to dataviewjs and typescript (actually not familiar with any code at all) so this probably is a dumb question.
I’ve tried to achieve a dv.table() with certain text lines in a markdown file and also with certain tags (for file tags, not the tag comes with the lines ).
for example,
I’ve found this code:
I think probably I need to add some filter to
files = app.vault.getMarkdownFiles()
to filter files with certain tags,or find a way to display the file.tags for the results.
However, I cannot figure out how to do it.
I've ask a same question at obsidian forum but no one answered.
Hoping someone could help me with this!
Or just let me know whether this is possible.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions