include: second parameter is ignored #281

This commit is contained in:
Sören Weber 2022-06-23 13:22:04 +02:00
parent 72770144c4
commit 7570a7c28c
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
5 changed files with 15 additions and 10 deletions

View file

@ -3,4 +3,4 @@ disableToc = false
title = "History" title = "History"
weight = 30 weight = 30
+++ +++
{{% include "basics/CHANGELOG.md" false %}} {{% include "basics/CHANGELOG.md" true %}}

View file

@ -16,6 +16,10 @@ This document shows you what's new in the latest release. For a detailed list of
## 4.2.0 ## 4.2.0
- **Breaking**: The second parameter for the [`include` shortcode]({{% relref "shortcodes/tabs" %}}) was switched in meaning and was renamed from `showfirstheading` to `hidefirstheading`. If you haven't used this parameter in your shortcode, the default behavior hasn't changed and you don't need to change anything.
If you've used the second boolean parameter, you have to rename it and invert its value to achive the same behavior.
- **Change**: Previously, if the [`tabs` shortcode]({{% relref "shortcodes/tabs" %}}) could not find a tab item because, the tabs ended up empty. Now the first tab is selected instead. - **Change**: Previously, if the [`tabs` shortcode]({{% relref "shortcodes/tabs" %}}) could not find a tab item because, the tabs ended up empty. Now the first tab is selected instead.
- **New**: All shortcodes can now be also called from your partials. Examples for this are added to the documentation of each shortcode. - **New**: All shortcodes can now be also called from your partials. Examples for this are added to the documentation of each shortcode.

View file

@ -12,7 +12,6 @@ While the examples are using shortcodes with named parameter you are free to use
{{< tabs groupId="shortcode-parameter">}} {{< tabs groupId="shortcode-parameter">}}
{{% tab name="shortcode" %}} {{% tab name="shortcode" %}}
````go ````go
{{%/* include file="shortcodes/INCLUDE_ME.md" */%}} {{%/* include file="shortcodes/INCLUDE_ME.md" */%}}
```` ````
@ -44,7 +43,7 @@ The included files can even contain Markdown and will be taken into account when
| Name | Position | Default | Notes | | Name | Position | Default | Notes |
|:---------------------|:---------|:-----------------|:------------| |:---------------------|:---------|:-----------------|:------------|
| **file** | 1 | _&lt;empty&gt;_ | The path to the file to be included. Path resolution adheres to [Hugo's build-in `readFile` function](https://gohugo.io/functions/readfile/) | | **file** | 1 | _&lt;empty&gt;_ | The path to the file to be included. Path resolution adheres to [Hugo's build-in `readFile` function](https://gohugo.io/functions/readfile/) |
| **showfirstheading** | 2 | `true` | When `false` and the included file contains headings, the first heading will be hidden. This comes in handy, eg. if you include otherwise standalone Markdown files. | | **hidefirstheading** | 2 | `false` | When `true` and the included file contains headings, the first heading will be hidden. This comes in handy, eg. if you include otherwise standalone Markdown files. |
## Examples ## Examples

View file

@ -1,13 +1,13 @@
{{- $context := .context }} {{- $context := .context }}
{{- $file := .file }} {{- $file := .file }}
{{- $showFirstHeading := .showfirstheading | default true }} {{- $hideFirstHeading := .hidefirstheading | default false }}
{{- if eq (printf "%T" $showFirstHeading) "string" }} {{- if eq (printf "%T" $hideFirstHeading) "string" }}
{{- $showFirstHeading = (eq $showFirstHeading "true") }} {{- $hideFirstHeading = (eq $hideFirstHeading "true") }}
{{- end }} {{- end }}
{{- if not $showFirstHeading }}<div class="include hide-first-heading">{{ end }} {{- if $hideFirstHeading }}<div class="include hide-first-heading">{{ end }}
{{- with $context }} {{- with $context }}
{{ $file | readFile | safeHTML }} {{ $file | readFile | safeHTML }}
{{- if not $showFirstHeading }}</div>{{ end }} {{- if $hideFirstHeading }}</div>{{ end }}
{{- end }} {{- end }}

View file

@ -1,5 +1,7 @@
@@{{ (.Get "hidefirstheading" | default (.Get 1)) | humanize}}@
{{- partial "shortcodes/include.html" (dict {{- partial "shortcodes/include.html" (dict
"context" . "context" .
"file" (.Get "align" | default (.Get 0)) "file" (.Get "file" | default (.Get 0))
"showFirstHeading" (.Get "showfirstheading" | default (.Get 1)) "hidefirstheading" (.Get "hidefirstheading" | default (.Get 1))
) }} ) }}