Skip to content

Commit 2996bd1

Browse files
committed
Rework alert shortcode
1 parent 20489c2 commit 2996bd1

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

assets/scss/_alerts.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@
1717
border-width: 0 0 0 4px;
1818
}
1919
}
20+
21+
:last-child {
22+
margin-bottom: 0;
23+
}
2024
}

layouts/shortcodes/alert.html

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
{{ $_hugo_config := `{ "version": 1 }` }}
2-
{{ $color := .Get "color" | default "primary" }}
1+
{{ $color := .Get "color" | default "primary" -}}
32
<div class="alert alert-{{ $color }}" role="alert">
4-
{{ with .Get "title" }}<h4 class="alert-heading">{{ . | safeHTML }}</h4>{{ end }}
5-
{{ if eq .Page.File.Ext "md" }}
6-
{{ .Inner | markdownify }}
7-
{{ else }}
8-
{{ .Inner | htmlUnescape | safeHTML }}
9-
{{ end }}
3+
{{ with .Get "title" -}}
4+
<h4 class="alert-heading">
5+
{{- . | safeHTML -}}
6+
</h4>
7+
{{ end -}}
8+
{{ if .Get "markdownify" -}}
9+
{{ .Inner | markdownify }}
10+
{{ else -}}
11+
{{ .Inner }}
12+
{{ end -}}
1013
</div>

userguide/content/en/docs/Adding content/Shortcodes/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The **blocks/cover** shortcode creates a landing page type of block that fills t
4949
Note that the relevant shortcode parameters above will have sensible defaults, but is included here for completeness.
5050

5151
{{% alert title="Hugo Tip" %}}
52-
> Using the bracket styled shortcode delimiter, `>}}`, tells Hugo that the inner content is HTML/plain text and needs no further processing. Changing the delimiter to `%}}` means Hugo will treat the content as Markdown. You can use both styles in your pages.
52+
Using the bracket styled shortcode delimiter, `>}}`, tells Hugo that the inner content is HTML/plain text and needs no further processing. Changing the delimiter to `%}}` means Hugo will treat the content as Markdown. You can use both styles in your pages.
5353
{{% /alert %}}
5454

5555

userguide/content/en/docs/Deployment/_index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Depending on your deployment choice you may want to serve your site locally duri
1818
git clone --recurse-submodules --depth 1 https://github.com/my/example.git
1919
```
2020
21-
{{% alert title="Note" color="primary" %}}
21+
{{< alert title="Note" markdownify=true >}}
2222
If you've just added the theme as a submodule in a local version of your site and haven't committed it to a repo yet, you must get local copies of the theme's own submodules before serving your site.
23-
23+
2424
git submodule update --init --recursive
25-
{{% /alert %}}
25+
{{< /alert >}}
2626
2727
1. Ensure you have the tools described in [Prerequisites and installation](/docs/getting-started/#prerequisites-and-installation) installed on your local machine, including `postcss-cli` (you'll need it to generate the site resources the first time you run the server).
2828
1. Run the `hugo server` command in your site root. By default your site will be available at http://localhost:1313/.
@@ -59,7 +59,7 @@ Then follow the instructions in [Host on Netlify](https://gohugo.io/hosting-and-
5959
1. Specify `HUGO_VERSION` as the **Key** for the new variable, and `0.53` or later as its **Value**.
6060
1. Click **Deploy site**.
6161
62-
{{% alert title="Note" color="primary" %}}
62+
{{% alert title="Note" %}}
6363
Netlify uses your site repo's `package.json` file to install any JavaScript dependencies (like `postcss`) before building your site. If you haven't just copied our example site's version of this file, make sure that you've specified all our [prerequisites](/docs/getting-started/#install-postcss).
6464
6565
For example, if you want to use a version of `postcss-cli` later than version 8.0.0, you need to ensure that your `package.json` also specifies `postcss` separately:
@@ -121,12 +121,12 @@ There are several options for publishing your web site using [Amazon Web Service
121121
122122
For more information about the Hugo `deploy` command, including command line options, see this [synopsis](https://gohugo.io/commands/hugo_deploy). In particular, you may find the `--maxDeletes int` option or the `--force` option (which forces upload of all files) useful.
123123
124-
{{% alert title="Automated deployment with GitHub actions" color="primary" %}}
124+
{{% alert title="Automated deployment with GitHub actions" %}}
125125
If the source of your site lives in a GitHub repository, you can use [GitHub Actions](https://docs.github.com/en/actions) to deploy the site to your S3 bucket as soon as you commit changes to your GitHub repo. Setup of this workflow is described in this [blog post](https://capgemini.github.io/development/Using-GitHub-Actions-and-Hugo-Deploy-to-Deploy-to-AWS/).
126126
{{% /alert %}}
127127
128128
129-
{{% alert title="Handling aliases" color="primary" %}}
129+
{{% alert title="Handling aliases" %}}
130130
If you are using [aliases](https://gohugo.io/content-management/urls/#aliases) for URL management, you should have a look at this [blog post](https://blog.cavelab.dev/2021/10/hugo-aliases-to-s3-redirects/). It explains how to turn aliases into proper `301` redirects when using Amazon S3.
131131
{{% /alert %}}
132132

0 commit comments

Comments
 (0)