A simple mkdocs plugin, enable to sort nav by setting "weight" in markdown metadata
Project description
mkdocs-nav-weight
A simple mkdocs plugin, enable to sort nav by setting "weight" in markdown metadata
I'm only sure it's runnable, not sure if it works (at least it does in my local docs). Only the compatibility ofsection
,index
andpage
has been considered.
mkdocs getnav
first, and then reads markdown resource topage
, so using this plugin means reading markdown source twice, which may introduce performance problems
Install
I don't know how to package, so let it be:
pip install git+https://github.com/shu307/mkdocs-nav-weight
mkdocs.yml
plugins:
- search
- mkdocs-nav-weight
Intro
A document tree like this:
│ bar.md
│ foo.md
│
├─have_index_folder
│ │ another.md
│ │ index.md
│ │
│ └─level2
│ another.md
│ bar.md
│ foo.md
│
└─no_index_folder
alone.md
Markdown metadata like this:
Note, try not to forget the
space
betweenweight:
andnumber
, sometimes it causes bugs, I use mkdocs its own way to get metadata, and I'm not a proficient pythoner, so I don't know how to fix it.
foo.md
---
title: foo
weight: 4
---
...
bar.md // no "weight", default = 0
---
title: bar
---
...
index.md
---
title: index
weight: 3
---
...
another.md
---
title: another
weight: 1
---
...
alone.md
---
title: alone
weight: 2
---
Get a nav like this:
bar // 0: no 'weight', default 0
No index folder // 0: will not get weight from 'alone', so it's defalut 0
alone // 2
Have index folder // 3: get from 'index'
index // 3: but as 0 in same level
Level2 // 0: no index, default 0
bar // 0
another // 1
foo // 4
another // 1
foo // 4
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mkdocs_nav_weight-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 889224830d4a1eff7e957b14eaf61393673d00ce332378948cf9ece26b5c91ef |
|
MD5 | e91bdb2a192ac2396a30be4742a3f641 |
|
BLAKE2b-256 | e378a095e7e2ef246117019ec9be08639581684c45c973059f6b8f6b1b8af41b |