A plugin for creating a real hierarchical navigation, following folders and documents, in Eleventy projects.
npm install @tigersway/eleventy-plugin-ancestry
Open up your Eleventy config file (probably .eleventy.js
) and use addPlugin
:
const pluginAncestry = require("@tigersway/eleventy-plugin-ancestry");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginAncestry);
};
See sample/index.md
& sample/_includes/base.njk
for examples how to access children/parent.
-
find
: Gives access to one - if it exists -collections.all
element. -
children
: Gives access to the folder or subfolderscollections.all
elements. -
sorted
: Allows to sort any collection with a deep property. -
ancestors
(v0.5): Gives access to the parents/ancestors of the elements
- As of today, the use of
_index
(to allow easier search of parent) is not included in Eleventy #1057 & #774.
A permalink rewrite in root directory data file imposeseleventyComputed
in@11ty/eleventy@0.11.0
!
v1.0.3
- Eleventy peer dependency corrected
v1.0.2
- Chaining ancestors
v1.0.1
permalink:false && eleventyExcludeFromCollections: true
are now possible- Eleventy now peerDependency
v0.5.0
- ...