created: 20200702112112330 modified: 20200706222227355 tags: $:/tags/Macro title: $:/ou/macros/ContentsTree type: text/vnd.tiddlywiki \define contents-leaf-link(full-title,chunk,separator: "/") <$set name="section" tiddler=<<__full-title__>> field="section"> <$list filter="[title[$(full-title)$]!has[section]]"> <$link to=<<__full-title__>>><$text text=<<__chunk__>>/></$link> </$list> <$list filter="[title[$(full-title)$]has[section]]"> <$link to=<<__full-title__>>><$text text=<<section>>/>. <$text text=<<__chunk__>>/></$link> </$list> </$set> \end \define contents-leaf-node(prefix,chunk) <li> <$list filter="[<__prefix__>addsuffix<__chunk__>is[shadow]] [<__prefix__>addsuffix<__chunk__>is[tiddler]]" variable="full-title"> <$list filter="[<full-title>removeprefix<__prefix__>]" variable="chunk"> <$macrocall $name="contents-leaf-link" full-title=<<full-title>> chunk=<<chunk>>/> </$list> </$list> </li> \end \define contents-branch-node(prefix,chunk,separator: "/") <li> <$set name="stripped" filter="[[$chunk$]removesuffix[$separator$]]" > <b class="contents-branch"><<stripped>></b> </$set> <$macrocall $name="contents-tree-node" prefix={{{ [<__prefix__>addsuffix<__chunk__>] }}} separator=<<__separator__>>/> </li> \end \define contents-tree-node(prefix,separator: "/") <ol class="compact-list"> <$list filter="[!is[system]!has[section]!tag[image]!tag[hidden]!tag[toc]removeprefix<__prefix__>splitbefore<__separator__>sortan[]!suffix<__separator__>] [all[tiddlers]has[section]sortan[section]removeprefix<__prefix__>splitbefore<__separator__>!suffix<__separator__>]" variable="chunk"> <$macrocall $name="contents-leaf-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>>/> </$list> <$list filter="[all[tiddlers]!tag[toc]!tag[hidden]!tag[image]removeprefix<__prefix__>splitbefore<__separator__>sortan[]suffix<__separator__>]" variable="chunk"> <$macrocall $name="contents-branch-node" prefix=<<__prefix__>> chunk=<<chunk>> separator=<<__separator__>>/> </$list> </ol> \end \define contents-tree(path, separator: "/") <div class="tc-tree"> <$macrocall $name="contents-tree-node" prefix=<<__path__>> separator=<<__separator__>>/> </div> \end