From 304211dba0377ebbf088ae457d34b64e5c20f56f Mon Sep 17 00:00:00 2001 From: George Cushen Date: Mon, 10 Sep 2018 19:34:06 +0100 Subject: [PATCH] Support multiple instances of docs layout with their own menus Close #682 --- exampleSite/content/tutorial/_index.md | 2 +- exampleSite/content/tutorial/example.md | 2 +- layouts/partials/docs_sidebar.html | 15 +++++++++++---- layouts/partials/footer_section.html | 2 ++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/exampleSite/content/tutorial/_index.md b/exampleSite/content/tutorial/_index.md index 0bcfc09c..00b97b0d 100644 --- a/exampleSite/content/tutorial/_index.md +++ b/exampleSite/content/tutorial/_index.md @@ -9,7 +9,7 @@ toc = true # Show table of contents? true/false type = "docs" # Do not modify. # Add menu entry to sidebar. -[menu.docs] +[menu.tutorial] name = "Overview" weight = 1 diff --git a/exampleSite/content/tutorial/example.md b/exampleSite/content/tutorial/example.md index 16947d5c..7d51255c 100644 --- a/exampleSite/content/tutorial/example.md +++ b/exampleSite/content/tutorial/example.md @@ -10,7 +10,7 @@ type = "docs" # Do not modify. # Add menu entry to sidebar. linktitle = "Example Page" -[menu.docs] +[menu.tutorial] parent = "Example Topic" weight = 1 diff --git a/layouts/partials/docs_sidebar.html b/layouts/partials/docs_sidebar.html index 4948dbe3..142868f6 100644 --- a/layouts/partials/docs_sidebar.html +++ b/layouts/partials/docs_sidebar.html @@ -1,4 +1,9 @@ {{ $current_page := . }} +{{ $menu_name := .Section }} +{{ with (index .Site.Menus $menu_name) }} +{{ else }} +{{ errorf "Please define menu items named `[menu.%s]` in your %s front matter or in `config.toml`." $menu_name $menu_name }} +{{ end }} {{ if eq $.Site.Params.search.engine 1 }}