include: add paramter to hide first heading #43

This commit is contained in:
Sören Weber 2021-08-28 10:08:10 +02:00
parent 4ba89ec502
commit 3931faa1d5
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
7 changed files with 46 additions and 7 deletions

View file

@ -30,7 +30,6 @@ module.exports = {
milestoneMatch: "{{tag_name}}",
onlyMilestones: true,
template: {
changelogTitle: "",
group: "\n### {{heading}}\n",
release: ({ body, date, release }) => `## ${release} (` + date.replace( /(\d+)\/(\d+)\/(\d+)/, '$3-$2-$1' ) + `)\n${body}`,
},

View file

@ -1,3 +1,5 @@
# Changelog
## 1.2.0 (2021-07-26)
### Enhancements
@ -15,11 +17,14 @@
### Bug Fixes
- [**bug**] dependency: upgrade jquery to 3.6.0 [#30](https://github.com/McShelby/hugo-theme-relearn/issues/30)
- [**bug**] attachments: support i18n for attachment size [#21](https://github.com/McShelby/hugo-theme-relearn/issues/21)
- [**bug**] notice: support i18n for box labels [#16](https://github.com/McShelby/hugo-theme-relearn/issues/16)
- [**bug**] notice: support multiple blocks in one box [#15](https://github.com/McShelby/hugo-theme-relearn/issues/15)
### Maintenance
- [**task**] dependency: upgrade jquery to 3.6.0 [#30](https://github.com/McShelby/hugo-theme-relearn/issues/30)
---
## 1.1.1 (2021-07-04)

View file

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

View file

@ -4,7 +4,7 @@ You can add:
- bullet point lists
- _emphasized_, **bold** and even **_bold emphasized_** text
- [links](https://example.com)
- other shortcodes besides `expand`
- other shortcodes besides `include`
- etc.
```plaintext

View file

@ -8,9 +8,13 @@ The include shortcode includes other files from your project inside of the curre
## Usage
````go
{{%/* include "<file>" */%}}
{{%/* include "<file>" { "true" | "false" } */%}}
````
The first parameter is the path to the file to be included.
If the file's content will be displayed as HTML, the second optional parameter controls if the first heading of the included file should be displayed ("true")- which is the default - or be hidden.
## Examples
### Arbitray content

View file

@ -1,2 +1,6 @@
{{ $file := .Get 0 }}
{{ $file | readFile | safeHTML }}
{{ $showFirstHeading := .Get 1 | default true }}
<div class="include{{if not $showFirstHeading }} hide-first-heading{{end}}">
{{ $file | readFile | safeHTML }}
</div>

View file

@ -1153,4 +1153,31 @@ option {
.mermaid {
margin-bottom: 1.7rem;
margin-top: 1.7rem;
}
}
.include.hide-first-heading h1:first-of-type,
.include.hide-first-heading h2:first-of-type,
.include.hide-first-heading h3:first-of-type,
.include.hide-first-heading h4:first-of-type,
.include.hide-first-heading h5:first-of-type,
.include.hide-first-heading h6:first-of-type {
display: none;
}
.include.hide-first-heading h1 + h2:first-of-type,
.include.hide-first-heading h1 + h3:first-of-type,
.include.hide-first-heading h2 + h3:first-of-type,
.include.hide-first-heading h1 + h4:first-of-type,
.include.hide-first-heading h2 + h4:first-of-type,
.include.hide-first-heading h3 + h4:first-of-type,
.include.hide-first-heading h1 + h5:first-of-type,
.include.hide-first-heading h2 + h5:first-of-type,
.include.hide-first-heading h3 + h5:first-of-type,
.include.hide-first-heading h4 + h5:first-of-type,
.include.hide-first-heading h1 + h6:first-of-type,
.include.hide-first-heading h2 + h6:first-of-type,
.include.hide-first-heading h3 + h6:first-of-type,
.include.hide-first-heading h4 + h6:first-of-type,
.include.hide-first-heading h5 + h6:first-of-type {
display: block;
}