Created
September 5, 2022 12:47
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```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