mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
include: second parameter is ignored #281
This commit is contained in:
parent
72770144c4
commit
7570a7c28c
5 changed files with 15 additions and 10 deletions
|
@ -3,4 +3,4 @@ disableToc = false
|
|||
title = "History"
|
||||
weight = 30
|
||||
+++
|
||||
{{% include "basics/CHANGELOG.md" false %}}
|
||||
{{% include "basics/CHANGELOG.md" true %}}
|
||||
|
|
|
@ -16,6 +16,10 @@ This document shows you what's new in the latest release. For a detailed list of
|
|||
|
||||
## 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.
|
||||
|
||||
- **New**: All shortcodes can now be also called from your partials. Examples for this are added to the documentation of each shortcode.
|
||||
|
|
|
@ -12,7 +12,6 @@ While the examples are using shortcodes with named parameter you are free to use
|
|||
{{< tabs groupId="shortcode-parameter">}}
|
||||
{{% tab name="shortcode" %}}
|
||||
|
||||
|
||||
````go
|
||||
{{%/* 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 |
|
||||
|:---------------------|:---------|:-----------------|:------------|
|
||||
| **file** | 1 | _<empty>_ | 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
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{{- $context := .context }}
|
||||
{{- $file := .file }}
|
||||
{{- $showFirstHeading := .showfirstheading | default true }}
|
||||
{{- if eq (printf "%T" $showFirstHeading) "string" }}
|
||||
{{- $showFirstHeading = (eq $showFirstHeading "true") }}
|
||||
{{- $hideFirstHeading := .hidefirstheading | default false }}
|
||||
{{- if eq (printf "%T" $hideFirstHeading) "string" }}
|
||||
{{- $hideFirstHeading = (eq $hideFirstHeading "true") }}
|
||||
{{- end }}
|
||||
{{- if not $showFirstHeading }}<div class="include hide-first-heading">{{ end }}
|
||||
{{- if $hideFirstHeading }}<div class="include hide-first-heading">{{ end }}
|
||||
{{- with $context }}
|
||||
|
||||
{{ $file | readFile | safeHTML }}
|
||||
|
||||
{{- if not $showFirstHeading }}</div>{{ end }}
|
||||
{{- if $hideFirstHeading }}</div>{{ end }}
|
||||
{{- end }}
|
|
@ -1,5 +1,7 @@
|
|||
@@{{ (.Get "hidefirstheading" | default (.Get 1)) | humanize}}@
|
||||
|
||||
{{- partial "shortcodes/include.html" (dict
|
||||
"context" .
|
||||
"file" (.Get "align" | default (.Get 0))
|
||||
"showFirstHeading" (.Get "showfirstheading" | default (.Get 1))
|
||||
"file" (.Get "file" | default (.Get 0))
|
||||
"hidefirstheading" (.Get "hidefirstheading" | default (.Get 1))
|
||||
) }}
|
Loading…
Reference in a new issue