Skip to content

Instantly share code, notes, and snippets.

@tgzw
Created September 5, 2022 12:47
Show Gist options
  • Select an option

  • Save tgzw/0bbe5591fd8a6828a9e1d72c44f5fa50 to your computer and use it in GitHub Desktop.

Select an option

Save tgzw/0bbe5591fd8a6828a9e1d72c44f5fa50 to your computer and use it in GitHub Desktop.
Snippet of code for the Obsidian extension Dataview, to show all the notes grouped by unique tags.
```dataviewjs
// Fetching unique tags
let tags = []
for (let tag of dv.pages('"notes"').file.tags) {
if (tags.indexOf(tag) == -1) {
tags.push(tag)
}
}
// Table for each tag
dv.header(5,"Notes by tag:")
for (let tag of tags) {
dv.header(4, tag.substring(1));
dv.table(["name","created"],
dv.pages('"notes"').where(p => p.file.tags.includes(tag))
.map(k => [k.file.link, k["created"]]))
}
// List of unique tags
dv.header(5,"Tags:")
dv.list(tags)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment