Skip to content

Instantly share code, notes, and snippets.

@BoyCook
Created March 28, 2017 22:44
Show Gist options
  • Save BoyCook/c1f3d63e8a3b7e06282b65798929454b to your computer and use it in GitHub Desktop.
Save BoyCook/c1f3d63e8a3b7e06282b65798929454b to your computer and use it in GitHub Desktop.
#macro (findRoot $page)
#if ($page.parent)
#findRoot($page.parent)
#else
#set($root = $page)
#end
#end
#findRoot($page)
#set($current = $page)
#macro (selected)
#if ($page.title == $current.title)
class="selected-index"
#end
#end
#macro (createTreeNode $item)
<ul>
#foreach($child in $item.children)
<li>
($item.parent.title // $page.title)
#if ($item.parent.title == $page.title)
#set($down = false)
#end
<a href="$child.link">$child.title</a>
#if ($down != false)
#createTreeNode($child)
#end
</li>
#end
</ul>
#end
#macro (createNode $page)
<li #selected()>
<a href="$page.link">$page.title</a>
#if ($page.children)
<ul>
#foreach($child in $page.children)
<li>
<a href="$child.link">$child.title</a>
</li>
#end
</ul>
#end
</li>
#end
<section class="content-margin-top blog-index light-content">
<a href="/"><h3>Docs</h3></a>
#createTreeNode($root)
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment