Javascript code for use in Dataview query with Obsidian PKM
Budget: $30 – $250 AUD
The Obsidian PKM uses Dataview for generating various queries which I mainly use for generating lists and tables. One of my queries is to generate an annual list or table of all the Daily Notes that I have made. The query works fine and puts the notes into groups by month.
Unfortunately, dataview does not facilitate collapsing the list so only the months are viewed.
I am looking for a script that will collapse the contents of each month group with an icon to expand the monthly list and also close it again for each month. The expand and collapse icons should be consistent with standards, i.e. Λ Collapse and V for Expand.
The code for generating the list view is contained in a callout works except for collapsing the monthly notes as follows:-
[!EXAMPLE] Journal Notes As List View
```dataview
LIST rows.file.link
FROM "Path to your folder of Daily Notes for the year"
WHERE file.ctime.year = "Year of the list e.g. 2022"
SORT file.name ASC
GROUP BY dateformat(file.ctime, "yyyy-MM")
```
The code below generates the TABLE view, which is preferred.
[!EXAMPLE]+ Journal Notes as Table View
```dataview
TABLE rows.file.link AS DATE
FROM "90 - Personal/91 - Daily Notes/91.22 - 2022"
SORT file.name ASC
GROUP BY dateformat(file.ctime, "yyyy-MM") AS MONTH
```
If I can get this working in my own Obsidian vault, I may commission an extension of this project to create a plugin for Obsidian to collapse any List or Table Group in Dataview.
Unfortunately, dataview does not facilitate collapsing the list so only the months are viewed.
I am looking for a script that will collapse the contents of each month group with an icon to expand the monthly list and also close it again for each month. The expand and collapse icons should be consistent with standards, i.e. Λ Collapse and V for Expand.
The code for generating the list view is contained in a callout works except for collapsing the monthly notes as follows:-
[!EXAMPLE] Journal Notes As List View
```dataview
LIST rows.file.link
FROM "Path to your folder of Daily Notes for the year"
WHERE file.ctime.year = "Year of the list e.g. 2022"
SORT file.name ASC
GROUP BY dateformat(file.ctime, "yyyy-MM")
```
The code below generates the TABLE view, which is preferred.
[!EXAMPLE]+ Journal Notes as Table View
```dataview
TABLE rows.file.link AS DATE
FROM "90 - Personal/91 - Daily Notes/91.22 - 2022"
SORT file.name ASC
GROUP BY dateformat(file.ctime, "yyyy-MM") AS MONTH
```
If I can get this working in my own Obsidian vault, I may commission an extension of this project to create a plugin for Obsidian to collapse any List or Table Group in Dataview.