Skip to content

Commit

Permalink
Shortcode 'blocks/lead':lead: improvements
Browse files Browse the repository at this point in the history
- use Hugo's native support for processing HTML & markdown (google#906)
- drop support for pre-Hugo-0.54.x behavior of {{% %}} google#939
  • Loading branch information
chalin committed Mar 8, 2023
1 parent c05c214 commit 430e317
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
23 changes: 12 additions & 11 deletions layouts/shortcodes/blocks/lead.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{{ $_hugo_config := `{ "version": 1 }` -}}
{{ $col_id := .Get "color" | default .Ordinal -}}
{{ $height := .Get "height" | default "auto" -}}
{{/* Height can be one of: auto, min, med, max, full. */ -}}
{{ with .Get "height" -}}
{{ if not ( or ( eq . "auto" ) ( eq . "min" ) ( eq . "med" ) ( eq . "max" ) ( eq . "full" ) ) -}}
{{ errorf "shortcode 'lead': parameter height is '%s', must be one of 'auto', 'min', 'med', 'max' or 'full'." . -}}
{{ end -}}
{{ end -}}
<a id="td-block-{{ .Ordinal }}" class="td-offset-anchor"></a>
<section class="row td-box td-box--{{ $col_id }} position-relative td-box--height-{{ $height }}">
<div class="container text-center td-arrow-down">
<div class="h4 mb-0">
{{ if eq .Page.File.Ext "md" -}}
{{ .Inner | markdownify -}}
{{ else -}}
{{ .Inner | htmlUnescape | safeHTML -}}
{{ end -}}
</div>
</div>
<div class="container text-center td-arrow-down">
<div class="h4 mb-0">
{{/* Do NOT remove this comment! It ends above HTML block. See https://spec.commonmark.org/0.30/#html-blocks, 7. */}}
{{ .Inner -}}
</div>
</div>
</section>
{{/**/ -}}
4 changes: 2 additions & 2 deletions userguide/content/en/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>
{{< /blocks/cover >}}

{{% blocks/lead color="primary" %}}
{{< blocks/lead color="primary" >}}
Docsy is a theme for the Hugo static site generator that's specifically designed
for technical documentation sets. Our aim is to help you get a working
documentation site up and running as easily as possible, so you can concentrate
Expand All @@ -24,7 +24,7 @@
<a href="https://www.netlify.com" target="_blank" rel="noopener">
<img src="https://www.netlify.com/img/global/badges/netlify-color-accent.svg" alt="Deploys by Netlify" />
</a>
{{% /blocks/lead %}}
{{< /blocks/lead >}}

{{< blocks/section color="dark" type="features">}}
{{% blocks/feature icon="fa-lightbulb" title="See Docsy in action!" url="/docs/examples/" %}}
Expand Down
10 changes: 6 additions & 4 deletions userguide/content/en/docs/adding-content/shortcodes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ Runs on **bare metal** in the **cloud**!
{{%/* /blocks/lead */%}}
```

| Parameter | Default | Description |
| ---------------- |------------| ------------|
| height | | See above.
| color | | See above.
Use the syntax printed above if the inner content of your `/blocks/lead` shortcode is authored in markdown. In case of HTML content, use square brackets `<>` as innermost delimiters: `{{</* blocks/lead >}}<b>HTML</b> content{{< /blocks/lead */>}}`.

| Parameter | Default | Description |
| --------- |--------- | ------------------------------- |
| height | `auto` | [See above.](#shortcode-blocks) |
| color | .Ordinal | [See above.](#shortcode-blocks) |

### blocks/section

Expand Down

0 comments on commit 430e317

Please sign in to comment.