Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
docpad-plugin-tree-branched
Advanced tools
DocPad plugin that when given a collection will construct a hierarchical tree of documents. Perfect for navigation menus!
DocPad plugin that when given a collection will construct a hierarchical tree of documents. Perfect for navigation menus!
$ docpad install tree
The plugin exposes a template helper, tree(collection, context, includeRoot)
, that you can use for constructing a tree of documents from any given collection:
tree(...) | Type | Description |
---|---|---|
collection | string | The name of the collection used for constructing the tree. Default: documents |
context | object | The context in which this tree is to be constructed. Will "highlight" the current document path if set. You'll typically want to set it to @document . Optional |
includeRoot | boolean | Whether or not to include the root of the collection in the constructed tree. Default: false |
For each document in the collection, you can set the following meta information:
title: "Fishing with my uncle" # Title of the page
menu: "Fishing tricks" # Title that will appear in the tree (optional)
order: 0 # Sort order
hidden: false # Whether or not to hide the item from the tree
A constructed tree will look something like this:
[
{
"title": "Some page",
"url": "/some-page",
"order": 0,
"hidden": false,
"active": false,
"current": false,
"children": [
{
"title": "A child page",
"url": "/some-page/a-child-page",
"order": 0,
"hidden": false,
"active": false,
"current": false
}
]
},
{
"title": "Parent of current page",
"url": "/parent-of-current-page",
"order": 0,
"hidden": false,
"active": true,
"current": false,
"children": [
{
"title": "Current page",
"url": "/parent-of-current-page/current-page",
"order": 0,
"hidden": false,
"active": true,
"current": true
}
]
}
]
The tree can then be used to create, say, a nested navigation menu:
<% menu = (items) => %>
<ul class="nav nav-stacked">
<% for item in items: %>
<li<%= " class=active" if item.active %>>
<a href="<%= item.url %>"><%= item.title %></a>
<%- menu item.children if item.children %>
</li>
<% end %>
</ul>
<% end %>
<%= menu @tree('html', @document) %>
You could also use it to create breadcrumbs (notice inclusion of the root):
<% trail = (items) => %>
<% for item in items: %>
<% if item.active: %>
<% if item.current: %>
<li class="active"><%= item.title %></li>
<% else: %>
<li><a href="<%= item.url %>"><%= item.title %></a></li>
<% end %>
<%- trail item.children if item.children %>
<% end %>
<% end %>
<% end %>
<ol class="breadcrumb">
<%= trail @tree('html', @document, true) %>
</ol>
Copyright © 2014 Kasper Kronborg Isager. Licensed under the terms of the MIT License.
FAQs
DocPad plugin that when given a collection will construct a hierarchical tree of documents. Perfect for navigation menus!
The npm package docpad-plugin-tree-branched receives a total of 0 weekly downloads. As such, docpad-plugin-tree-branched popularity was classified as not popular.
We found that docpad-plugin-tree-branched demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.