Johny Decimal automatic index

let areas = dv.pages("").file.folder.groupBy(g=>g.split("/")[0])
for (let area = 0; area < areas.length; area++) {
	dv.header(3, areas[area].key)
	dv.list(areas[area].rows.groupBy(g=>g.split("/")[1]).key)
}

Results:
it queries all your notes and on the basis of that spits out the folder structure. If you’re using Johny Decimal system, it makes it easier to track your areas and categories.

Sample index:

Limitations:
The list nests only once, to make space for Areas (big headers), and categories (individual bullets). If you have a Johny Decimal system that uses three levels of nesting, it’ll show up something like this:

### Area
- Category
- Category/sub_category_1
- Category/sub_category_2

If anyone’s willing to make this simple code better, feel free.

EDIT:
This one counts how many notes are in each category:

let areas = dv.pages("").file.folder.groupBy(g=>g.split("/")[0])
for (let area = 0; area < areas.length; area++) {
	dv.header(3, areas[area].key)
	let categories = areas[area].rows.groupBy(g=>g.split("/")[1]);
	let category_names = []
	for (let i = 0; i < categories.length; i++){
		if (categories[i].key) category_names.push(categories[i].key + " (" + categories[i].rows.length + " notes)")
	}
	dv.list(dv.array(category_names))
}
```
5 Likes