updated the way I do callouts and alerts. This approach is better than the old way. You use includes here and pass parameters. This approach leads to fewer errors. The output looks the same, and you can use Markdown directly inside of the alerts or callouts instead of switching to HTML syntax.
This commit is contained in:
@ -15,71 +15,121 @@ Alerts are little warnings, info, or other messages that you have called out in
|
||||
|
||||
You can insert an alert by using any of the following code.
|
||||
|
||||
{%raw%}
|
||||
alert | code
|
||||
------|---------
|
||||
note | {{site.data.alerts.note}} your note {{site.data.alerts.end}}
|
||||
tip | {{site.data.alerts.tip}} your tip {{site.data.alerts.end}}
|
||||
warning | {{site.data.alerts.warning}} your warning {{site.data.alerts.end}}
|
||||
important | {{site.data.alerts.important}} your important info {{site.data.alerts.end}}
|
||||
{%endraw%}
|
||||
```
|
||||
{%raw%}{% include note.html content="This is my note. All the content I type here is treated as a single paragraph." %}{% endraw%}
|
||||
```
|
||||
|
||||
The following demonstrate the formatting associated with each alert.
|
||||
Here's the result:
|
||||
|
||||
{{site.data.alerts.tip}} Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. {{site.data.alerts.end}}
|
||||
{% include note.html content="This is my note. All the content I type here is treated as a single paragraph." %}
|
||||
|
||||
{{site.data.alerts.note}} Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. {{site.data.alerts.end}}
|
||||
If you need multiple paragraphs, enter `<br/><br/>` tags, like this:
|
||||
|
||||
{{site.data.alerts.important}} Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. {{site.data.alerts.end}}
|
||||
```
|
||||
{%raw%}{% include note.html content="This is my note. All the content I type here is treated as a single paragraph. <br/><br/> Now I'm typing on a new line." %}{% endraw%}
|
||||
```
|
||||
|
||||
{{site.data.alerts.warning}} Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. {{site.data.alerts.end}}
|
||||
Here's the result:
|
||||
|
||||
{% include note.html content="This is my note. All the content I type here is treated as a single paragraph. <br/><br/> Now I'm typing on a new line." %}
|
||||
|
||||
## Types of alerts available
|
||||
|
||||
There are four types of alerts you can leverage:
|
||||
|
||||
* note.html
|
||||
* tip.html
|
||||
* warning.html
|
||||
* important.html
|
||||
|
||||
They function the same except they have a different color, icon, and alert word. You include the different types by selecting the include template you want. Here are samples of each alert:
|
||||
|
||||
{% include note.html content="This is my note." %}
|
||||
|
||||
{% include tip.html content="This is my tip." %}
|
||||
|
||||
{% include warning.html content="This is my warning." %}
|
||||
|
||||
{% include important.html content="This is my important info." %}
|
||||
|
||||
|
||||
These alerts leverage includes stored in the \_include folder. The `content` option is a parameter that you pass to the include. In the include, the parameter is passed like this:
|
||||
|
||||
|
||||
```
|
||||
{% raw %}<div markdown="span" class="alert alert-info" role="alert"><i class="fa fa-info-circle"></i> <b>Note:</b> {{include.content}}{% endraw %}</div>
|
||||
```
|
||||
|
||||
The content in `content="This is my note."` gets inserted into the `{% raw %}{{include.content}}}{% endraw %}` part of the template. You can follow this same pattern to build additional includes. See this [Jekyll screencast on includes](http://jekyll.tips/jekyll-casts/includes/) for more information.
|
||||
|
||||
## Callouts
|
||||
|
||||
In contrast to the alerts, the callouts don't have a pre-coded bold-formatted preface such as note or tip. You just add one (if desired) in the callout text itself.
|
||||
There's another type of callout available called callouts. This format is typically used for longer callout that spans mreo than one or two paragraphs, but really it's just a stylistic preference whether to use an alert or callout.
|
||||
|
||||
{%raw%}
|
||||
callout | code
|
||||
------|---------
|
||||
callout_default | {{site.data.alerts.callout_default}} your callout_default content {{site.data.alerts.end}}
|
||||
callout_primary | {{site.data.alerts.callout_primary}} your callout_primary content {{site.data.alerts.end}}
|
||||
callout_success | {{site.data.alerts.callout_success}} your callout_success content {{site.data.alerts.end}}
|
||||
callout_warning | {{site.data.alerts.callout_warning}} your callout_warning content {{site.data.alerts.end}}
|
||||
callout_info | {{site.data.alerts.callout_info}} your callout_info content {{site.data.alerts.end}}
|
||||
{%endraw%}
|
||||
Here's the syntax for a callout:
|
||||
|
||||
The following demonstrate the formatting for each callout.
|
||||
```
|
||||
{% raw %}{% include callout.html content="This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs. " type="primary" %} {% endraw %}
|
||||
```
|
||||
|
||||
{{site.data.alerts.callout_danger}}<b>callout_danger</b>: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
|
||||
{{site.data.alerts.end}}
|
||||
Here's the result:
|
||||
|
||||
{% include callout.html content="This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs." type="primary" %}
|
||||
|
||||
{{site.data.alerts.callout_default}}
|
||||
<b>callout_default</b>: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
|
||||
{{site.data.alerts.end}}
|
||||
To include paragraph breaks, use `<br/><br/>` inside the callout:
|
||||
|
||||
{{site.data.alerts.callout_primary}}
|
||||
<b>calloutprimary</b>: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
|
||||
{{site.data.alerts.end}}
|
||||
```
|
||||
{% raw %}{% include callout.html content="**Important information**: This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs. <br/><br/>Here I am starting a new paragraph, because I have lots of information to share. You may wonder why I'm using line breaks instead of paragraph tags. This is because Kramdown processes the Markdown here as a span rather than a div (for whatever reason). Be grateful that you can be using Markdown at all inside of HTML. That's usually not allowed in Markdown syntax, but it's allowed here." type="primary" %} {% endraw %}
|
||||
```
|
||||
|
||||
{{site.data.alerts.callout_success}}
|
||||
<b>calloutsuccess</b>: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
|
||||
{{site.data.alerts.end}}
|
||||
Here's the result:
|
||||
|
||||
{{site.data.alerts.callout_info}}
|
||||
<b>calloutinfo</b>: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
|
||||
{{site.data.alerts.end}}
|
||||
{% include callout.html content="**Important information**: This is my callout. It has a border on the left whose color you define by passing a type parameter. I typically use this style of callout when I have more information that I want to share, often spanning multiple paragraphs. <br/><br/>Here I am starting a new paragraph, because I have lots of information to share. You may wonder why I'm using line breaks instead of paragraph tags. This is because Kramdown processes the Markdown here as a span rather than a div (for whatever reason). Be grateful that you can be using Markdown at all inside of HTML. That's usually not allowed in Markdown syntax, but it's allowed here." type="primary" %}
|
||||
|
||||
{{site.data.alerts.callout_warning}}
|
||||
<b>calloutwarning</b>: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
|
||||
{{site.data.alerts.end}}
|
||||
The type options are as follows:
|
||||
|
||||
* `danger`
|
||||
* `default`
|
||||
* `primary`
|
||||
* `success`
|
||||
* `info`
|
||||
* `warning`
|
||||
|
||||
## Blast a warning to users
|
||||
These types just define the color of the left border. Each of these callout types get inserted as a class name in the callout template. These class names correspond with styles in Bootstrap. These classes are common Bootstrap class names whose style attributes differ depending on your Bootstrap theme and style definitions.
|
||||
|
||||
If you want to blast a warning to users on every page, add the alert or callout to the layouts/page.html page right below the frontmatter. Every page using the page layout (all, by defaut) will show this message.
|
||||
Here's an example of each different type of callout:
|
||||
|
||||
## Using Markdown inside of notes
|
||||
{% include callout.html content="This is my **danger** type callout. It has a border on the left whose color you define by passing a type parameter." type="danger" %}
|
||||
|
||||
You can't use Markdown formatting inside alerts. This is because the alerts leverage HTML, and you can't use Markdown inside of HTML tags. It's very easy to forget this, which is why I recommend using HTML formatting for links in every case. This way you're less likely to forget to switch into HTML mode when you're writing content in a tip. You must remember, however, to avoid Markdown with code and bold formatting inside of notes.
|
||||
{% include callout.html content="This is my **default** type callout. It has a border on the left whose color you define by passing a type parameter." type="default" %}
|
||||
|
||||
{% include callout.html content="This is my **primary** type callout. It has a border on the left whose color you define by passing a type parameter." type="primary" %}
|
||||
|
||||
{% include callout.html content="This is my **success** type callout. It has a border on the left whose color you define by passing a type parameter." type="success" %}
|
||||
|
||||
{% include callout.html content="This is my **info** type callout. It has a border on the left whose color you define by passing a type parameter." type="info" %}
|
||||
|
||||
{% include callout.html content="This is my **warning** type callout. It has a border on the left whose color you define by passing a type parameter." type="warning" %}
|
||||
|
||||
Now that in contrast to alerts, callouts don't include the alert word (note, tip, warning, or important).
|
||||
|
||||
## Markdown inside of callouts and alerts
|
||||
|
||||
You can use Markdown inside of callouts and alerts, even though this content actually gets inserted inside of HTML in the include. This is one of the advantages of Kramdown Markdown. The include template has an attribute of `markdown="span"` that allows for the processer to parse Markdown inside of HTML.
|
||||
|
||||
## Validity checking
|
||||
|
||||
If you have some of the syntax wrong with an alert or callout, you'll see an error when Jekyll tries to build your site. The error may look like this:
|
||||
|
||||
```
|
||||
{% raw %}Liquid Exception: Invalid syntax for include tag: content="This is my **info** type callout. It has a border on the left whose color you define by passing a type parameter. type="info" Valid syntax: {% include file.ext param='value' param2='value' %} in mydoc/mydoc_alerts.md {% endraw %}
|
||||
```
|
||||
|
||||
These errors are a good thing, because it lets you know there's an error in your syntax. Without the errors, you may not realize that you coded something incorrectly until you see the lack of alert or callout styling in your output.
|
||||
|
||||
In this case, the quotation marks aren't set correctly. I forgot the closing quotation mark for the content parameter include.
|
||||
|
||||
## Blast a warning to users on every page
|
||||
|
||||
If you want to blast a warning to users on every page, add the alert or callout to the \_layouts/page.html page right below the frontmatter. Every page using the page layout (all, by defaut) will show this message.
|
||||
|
||||
|
Reference in New Issue
Block a user