Allow cascade to be a slice with a _target discriminator

Fixes #7782
This commit is contained in:
Bjørn Erik Pedersen
2020-10-05 20:01:52 +02:00
parent 5e2a547cb5
commit c63db7f1f6
11 changed files with 375 additions and 29 deletions

View File

@@ -159,6 +159,39 @@ show_comments: false
Any node or section can pass down to descendents a set of Front Matter values as long as defined underneath the reserved `cascade` Front Matter key.
### Target Specific Pages
{{< new-in "0.76.0" >}}
Since Hugo 0.76 the `cascade` block can be a slice with a optional `_target` keyword, allowing for multiple `cascade` values targeting different page sets.
{{< code-toggle copy="false" >}}
title ="Blog"
[[cascade]]
background = "yosemite.jpg"
[cascade._target]
path="/blog/**"
lang="en"
kind="page"
[[cascade]]
background = "goldenbridge.jpg"
[cascade._target]
kind="section"
{{</ code-toggle >}}
Keywords available for `_target`:
path
: A [Glob](https://github.com/gobwas/glob) pattern matching the content path below /content. Expects Unix-styled slashes. Note that this is the virtual path, so it starts at the mount root.
kind
: A Glob pattern matching the Page's Kind(s), e.g. "{home,section}".
lang
: A Glob pattern matching the Page's language, e.g. "{en,sv}".
Any of the above can be omitted.
### Example
In `content/blog/_index.md`
@@ -174,6 +207,8 @@ With the above example the Blog section page and its descendents will return `im
- Said descendent has its own `banner` value set
- Or a closer ancestor node has its own `cascade.banner` value set.
## Order Content Through Front Matter
You can assign content-specific `weight` in the front matter of your content. These values are especially useful for [ordering][ordering] in list views. You can use `weight` for ordering of content and the convention of [`<TAXONOMY>_weight`][taxweight] for ordering content within a taxonomy. See [Ordering and Grouping Hugo Lists][lists] to see how `weight` can be used to organize your content in list views.