The notes in Dendron are stored in a so-called “vault” in a flat structure with “dotted” filenames that represent the hierarchy of the note. An example file name would be: reference.computers.setup.docker-install.md
with the hierarchy being self-evident in the naming scheme. Each note is in MarkDown for the most part, with some Dendron-specific syntax thrown in for features like wikilinks, transclusion etc.
https://github.com/sagarbehere/dendron-hugo-export/blob/main/export-hierarchy.py
This script
- Looks at all files in the Dendron vault (only top level, not subdirs) whose name ends in
.md
- Extracts a filename like
pqr.abc.xyz.md
into- An
export_fname
xyz.md - A
export_dir
pqr/abc/
- An
- If the
export_fname
orexport_dir
are part of an exclusion list, they are excluded - Populates an sqlite database table, named
files
, with the dotted file namepqr.abc.xyz.md
and its corresponding exported pathpqr/abc/xyz.md
- Copies the file from the Dendron vault to the correct folder in exported hierarchy
- moves e.g
foo/bar/baz.md
tofoo/bar/baz/_index.md
iffoo/bar/baz
exists - moves
root.md
tocontent/notes/_index.md
- And adds
title
, cascadedtype
, a nav bar menu entry to the frontmatter
- And adds
- Adds a
date
field to each note’s frontmatter- Date matches the
updated
variable in Dendron frontmatter, if it exists. Else - Date matches the
created
variable
- Date matches the