mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-30 16:37:13 +00:00
docs: example for cascading sidebar menu reusing existing menus #970
This commit is contained in:
parent
d25f856477
commit
49b2f8f770
2 changed files with 17 additions and 7 deletions
|
@ -9,12 +9,16 @@ weight = 4
|
||||||
|
|
||||||
The theme can build menu trees from [the structure of your page files](authoring/structure) or from [Hugo's build in menu feature](https://gohugo.io/content-management/menus/).
|
The theme can build menu trees from [the structure of your page files](authoring/structure) or from [Hugo's build in menu feature](https://gohugo.io/content-management/menus/).
|
||||||
|
|
||||||
- {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} All configuration options in your `hugo.toml` apply to all menus but can be changed individually.
|
---
|
||||||
|
|
||||||
|
- {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} Configuration options in your `hugo.toml` apply to all menus.
|
||||||
|
|
||||||
- {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} In case of page structure menus, individual configuration is done via a page's front matter.
|
- {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} In case of page structure menus, individual configuration is done via a page's front matter.
|
||||||
|
|
||||||
- {{% badge color="blueviolet" icon="bars" title=" " %}}Menu{{% /badge %}}. In case of Hugo menus, individual configuration is done via a menu entry's configuration.
|
- {{% badge color="blueviolet" icon="bars" title=" " %}}Menu{{% /badge %}}. In case of Hugo menus, individual configuration is done via a menu entry's configuration.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Expand State of Submenus
|
## Expand State of Submenus
|
||||||
|
|
||||||
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} You can change how submenus appear with `alwaysopen`.
|
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} You can change how submenus appear with `alwaysopen`.
|
||||||
|
@ -222,7 +226,9 @@ sidebarmenus = [
|
||||||
|
|
||||||
Suppose you are building a site that contains a topmost `blog` and `documentation` section.
|
Suppose you are building a site that contains a topmost `blog` and `documentation` section.
|
||||||
|
|
||||||
When the user is on one of the blog pages he should only see a menu containing all blog pages, while on a documentation page he should only see a menu containing all doc pages.
|
When the user is on one of the blog pages he should only see a page menu containing all blog pages, while on a documentation page he should only see a page menu containing all doc pages.
|
||||||
|
|
||||||
|
For both sections, the default `shortcuts` Hugo menu should be displayed as if [defaults menus](#defining-sidebar-menus) were used.
|
||||||
|
|
||||||
Directory structure:
|
Directory structure:
|
||||||
|
|
||||||
|
@ -232,23 +238,26 @@ content
|
||||||
│ ├── post-1.md
|
│ ├── post-1.md
|
||||||
│ ├── post-2.md
|
│ ├── post-2.md
|
||||||
│ ├── post-3.md
|
│ ├── post-3.md
|
||||||
│ └── _index_.md
|
│ └── _index.md
|
||||||
├── docs
|
├── docs
|
||||||
│ ├── topic-1.md
|
│ ├── topic-1.md
|
||||||
│ ├── topic-2.md
|
│ ├── topic-2.md
|
||||||
│ ├── topic-3.md
|
│ ├── topic-3.md
|
||||||
│ └── _index_.md
|
│ └── _index.md
|
||||||
└── _index.md
|
└── _index.md
|
||||||
````
|
````
|
||||||
|
|
||||||
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} Using [Hugo's cascade feature](https://gohugo.io/content-management/front-matter/#cascade), we can redefine the menus once in `blog/_index.md` and `docs/_index.md` setting `sidebarmenus` so they will be used in all children pages.
|
{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} Using [Hugo's cascade feature](https://gohugo.io/content-management/front-matter/#cascade), we can redefine the menus once in `blog/_index.md` and `docs/_index.md` setting `sidebarmenus` so they will be used in all children pages.
|
||||||
|
|
||||||
|
Setting the `sidebarmenus` Front Matter will overwrite all default menus. If you want to display the `shortcuts` Hugo menu as well like in this example, you have to declare it with the Front Matter as given in the [default options](#defining-sidebar-menus).
|
||||||
|
|
||||||
{{< multiconfig fm=true file="blog/_index.md">}}
|
{{< multiconfig fm=true file="blog/_index.md">}}
|
||||||
title = 'Blog'
|
title = 'Blog'
|
||||||
[[cascade]]
|
[[cascade]]
|
||||||
[cascade.params]
|
[cascade.params]
|
||||||
sidebarmenus = [
|
sidebarmenus = [
|
||||||
{ type = 'page', identifier = 'blog', pageRef = '/blog' },
|
{ type = 'page', identifier = 'blog', pageRef = '/blog' },
|
||||||
|
{ type = 'menu', identifier = 'shortcuts' },
|
||||||
]
|
]
|
||||||
{{< /multiconfig >}}
|
{{< /multiconfig >}}
|
||||||
|
|
||||||
|
@ -258,6 +267,7 @@ title = 'Documentation'
|
||||||
[cascade.params]
|
[cascade.params]
|
||||||
sidebarmenus = [
|
sidebarmenus = [
|
||||||
{ type = 'page', identifier = 'docs', pageRef = '/docs' },
|
{ type = 'page', identifier = 'docs', pageRef = '/docs' },
|
||||||
|
{ type = 'menu', identifier = 'shortcuts' },
|
||||||
]
|
]
|
||||||
{{< /multiconfig >}}
|
{{< /multiconfig >}}
|
||||||
|
|
||||||
|
@ -273,11 +283,11 @@ content
|
||||||
│ ├── ref-a.md
|
│ ├── ref-a.md
|
||||||
│ ├── ref-b.md
|
│ ├── ref-b.md
|
||||||
│ ├── ref-c.md
|
│ ├── ref-c.md
|
||||||
│ └── _index_.md
|
│ └── _index.md
|
||||||
├── topic-blue.md
|
├── topic-blue.md
|
||||||
├── topic-red.md
|
├── topic-red.md
|
||||||
├── topic-yellow.md
|
├── topic-yellow.md
|
||||||
└── _index_.md
|
└── _index.md
|
||||||
````
|
````
|
||||||
|
|
||||||
You now want to include `ref-b` as separate `topic-green` entry after `topic-blue` in your menu.
|
You now want to include `ref-b` as separate `topic-green` entry after `topic-blue` in your menu.
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
7.2.1+ec88e24f46955bcf1aa3f38ac143982eff08d8a6
|
7.2.1+d25f856477223170b0de0b284252aa54b3e6255b
|
Loading…
Add table
Reference in a new issue