Skip to content

Used to generate navigations in metalsmith from info block in the files itself

Notifications You must be signed in to change notification settings

Daviot/gobha-navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gobha-navigation

A Metalsmith plugin to generate navigations in metalsmith from meta informations

Installation

$ npm install gobha-navigation

Javascript Usage

let navigation = require('gobha-navigation')

metalsmith.use(navigation())

Options

{
	extension: "html|php|md|hbs"
}

extension

The plugin checks every file extension and when the extension matches the regex it will process the file and change the file extension

Create new navigation

Just add a new meta information into the file itself to create a new navigation

---
nav: main
---

The text "main" is the name of the navigaton

Now you can access the navigation main in your templates

{{#if navigation.main}}
	<ul>
	{{#each navigation.main}}
		<li><a href="{{file}}">{{title}}</a></li>
	{{/each}}
	</ul>
{{/if}}

Inside the loop you can access the url of the file via{{file}} and the title via {{title}}

Change order of the files in the navigation

To set an order for the files in the navigation add the sign = followed by a index(number) to the meta informationen in the file.

---
nav: main=10
---

1 is the first file, 2 the second and so on...
If you add a number twice it uses the order in which the files are processed

License

MIT

About

Used to generate navigations in metalsmith from info block in the files itself

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published