From 17d5e8ebe0fcf4d6e4ba7ea25f55728609b687bf Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Tue, 19 Jun 2018 16:53:31 +0200 Subject: [PATCH] Add menu order feature Menu items are now sorted by the menuorder attribute of their page. As we have a page for each language, this attribute has to be set for both of them. The default value is 100. pages with equal value are sorted by name. The index pages are set 0. --- _config.yml | 1 + _includes/menu.html | 3 ++- index-en.md | 1 + index.md | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 60f8ac0..e25612b 100644 --- a/_config.yml +++ b/_config.yml @@ -4,6 +4,7 @@ defaults: path: "" values: layout: "page" + menuorder: 100 langs: de: "DE" en: "EN" diff --git a/_includes/menu.html b/_includes/menu.html index 340fc5a..335261f 100644 --- a/_includes/menu.html +++ b/_includes/menu.html @@ -1,4 +1,5 @@ -{%- for node in site.pages -%} +{% assign sorted_nodes = site.pages | sort:"menutitle" | sort:"menuorder" %} +{%- for node in sorted_nodes -%} {%- if node.lang == page.lang and node.menutitle -%} {%- if node.url == page.url -%}
  • {{ node.menutitle | escape }}
  • diff --git a/index-en.md b/index-en.md index 3d79117..ac3ea35 100644 --- a/index-en.md +++ b/index-en.md @@ -3,6 +3,7 @@ title: The friendly neighborhood undead tech community menutitle: Home lang: en ref: home +menuorder: 0 --- # Welcome to Zombi diff --git a/index.md b/index.md index b1634a7..00a4a32 100644 --- a/index.md +++ b/index.md @@ -3,6 +3,7 @@ title: The friendly neighborhood undead tech community menutitle: Startseite lang: de ref: home +menuorder: 0 --- # Willkommen bei Zombi