2020-03-08 14:02:21 +01:00
---
2020-03-21 09:59:23 +01:00
weight: 4
title: "Theme Documentation - Extended Shortcodes"
date: 2020-03-03T16:29:41+08:00
lastmod: 2020-03-03T16:29:41+08:00
2020-03-08 14:02:21 +01:00
draft: false
author: "Dillon"
authorLink: "https://dillonzq.com"
description: "LoveIt theme provides multiple shortcodes on top of built-in ones in Hugo."
2022-05-12 21:41:37 +02:00
images: []
2020-05-28 11:05:37 +02:00
resources:
- name: "featured-image"
src: "featured-image.jpg"
- name: "featured-image-preview"
src: "featured-image-preview.jpg"
2020-03-08 14:02:21 +01:00
tags: ["shortcodes"]
categories: ["documentation"]
lightgallery: true
2022-05-06 17:54:15 +02:00
math:
enable: true
2020-03-08 14:02:21 +01:00
---
**LoveIt** theme provides multiple shortcodes on top of built-in ones in Hugo.
<!-- more -->
2020-04-30 18:32:24 +02:00
## 1 style
2020-03-08 14:02:21 +01:00
2020-04-26 19:19:23 +02:00
{{< version 0 . 2 . 0 changed > }}
2020-05-04 09:19:18 +02:00
{{< admonition > }}
Hugo **extended** version is necessary for `style` shortcode.
{{< / admonition > }}
2020-03-08 14:02:21 +01:00
`style` is a shortcode to insert custom style in your post.
2020-03-19 05:35:37 +01:00
The `style` shortcode has two positional parameters.
2020-03-08 14:02:21 +01:00
2020-04-26 19:19:23 +02:00
The **first** one is the custom style content,
2020-05-15 11:43:04 +02:00
which supports nesting syntax in [:(fab fa-sass fa-fw): SASS ](https://sass-lang.com/documentation/style-rules/declarations#nesting )
2020-04-26 19:19:23 +02:00
and `&` referring to this parent HTML element.
2020-03-19 05:35:37 +01:00
2020-04-26 19:19:23 +02:00
And the **second** one is the tag name of the HTML element wrapping the content you want to change style, and whose default value is `div` .
2020-03-19 05:35:37 +01:00
Example `style` input:
2020-03-08 14:02:21 +01:00
```markdown
2020-04-26 19:19:23 +02:00
{{< /* style "text-align:right; strong{color:#00b1ff;}" */>}}
This is a **right-aligned** paragraph.
2020-03-08 14:02:21 +01:00
{{< /* /style */>}}
```
The rendered output looks like this:
2020-04-26 19:19:23 +02:00
{{< style " text-align:right ; strong { color: # 00b1ff ; } " > } }
This is a **right-aligned** paragraph.
2020-03-08 14:02:21 +01:00
{{< / style > }}
2020-04-30 18:32:24 +02:00
## 2 link
2020-03-17 14:16:04 +01:00
2020-03-17 17:52:36 +01:00
{{< version 0 . 2 . 0 > }}
2020-03-17 14:16:04 +01:00
2020-04-27 19:38:22 +02:00
`link` shortcode is an alternative to [Markdown link syntax ](../basic-markdown-syntax#links ). `link` shortcode can provide some other features and can be used in code blocks.
2020-03-17 14:16:04 +01:00
2020-05-28 11:05:37 +02:00
{{< version 0 . 2 . 10 > }} The complete usage of [local resource references ](../theme-documentation-content#contents-organization ) is supported.
2020-03-19 05:35:37 +01:00
The `link` shortcode has the following named parameters:
2020-03-17 14:16:04 +01:00
2020-03-19 05:35:37 +01:00
* **href** *[required]* (**first** positional parameter)
2020-03-17 14:16:04 +01:00
Destination of the link.
2020-03-19 05:35:37 +01:00
* **content** *[optional]* (**second** positional parameter)
2020-03-17 14:16:04 +01:00
2020-03-21 09:59:23 +01:00
Content of the link, default value is the value of **href** parameter.
2020-03-17 14:16:04 +01:00
2020-03-19 05:35:37 +01:00
*Markdown or HTML format is supported.*
2020-03-17 14:16:04 +01:00
2020-03-19 05:35:37 +01:00
* **title** *[optional]* (**third** positional parameter)
2020-03-17 14:16:04 +01:00
2020-03-19 05:35:37 +01:00
`title` attribute of the HTML `a` tag, which will be shown when hovering on the link.
2020-03-17 14:16:04 +01:00
2020-03-19 05:35:37 +01:00
* **class** *[optional]*
2020-03-17 14:16:04 +01:00
`class` attribute of the HTML `a` tag.
2020-03-19 05:35:37 +01:00
* **rel** *[optional]*
Additional `rel` attributes of the HTML `a` tag.
2020-03-17 14:16:04 +01:00
2020-03-19 05:35:37 +01:00
Example `link` input:
2020-03-17 14:16:04 +01:00
```markdown
{{< /* link "https://assemble.io" */>}}
Or
{{< /* link href="https://assemble.io" */>}}
{{< /* link "mailto:contact@revolunet.com" */>}}
Or
{{< /* link href="mailto:contact@revolunet.com" */>}}
{{< /* link "https://assemble.io" Assemble */>}}
Or
{{< /* link href="https://assemble.io" content=Assemble */>}}
```
The rendered output looks like this:
* {{< link " https: // assemble . io " > }}
* {{< link " mailto:contact @ revolunet . com " > }}
* {{< link " https: // assemble . io " Assemble > }}
2020-03-19 05:35:37 +01:00
Example `link` input with a title:
2020-03-17 14:16:04 +01:00
```markdown
{{< /* link "https://github.com/upstage/" Upstage "Visit Upstage!" */>}}
Or
{{< /* link href="https://github.com/upstage/" content=Upstage title="Visit Upstage!" */>}}
```
The rendered output looks like this (hover over the link, there should be a tooltip):
{{< link " https: / / github . com / upstage / " Upstage " Visit Upstage ! " > }}
2020-04-30 18:57:30 +02:00
## 3 image {#image}
2020-03-08 14:02:21 +01:00
2020-03-19 09:54:47 +01:00
{{< version 0 . 2 . 0 changed > }}
2022-05-11 23:35:34 +02:00
`image` shortcode is an alternative to [`figure` shortcode ](../theme-documentation-built-in-shortcodes#figure ). `image` shortcode can take full advantage of the dependent libraries of [lazysizes ](https://github.com/aFarkas/lazysizes ) and [lightGallery ](https://github.com/sachinchoolur/lightgallery ).
2020-03-08 14:02:21 +01:00
2020-05-28 11:05:37 +02:00
{{< version 0 . 2 . 10 > }} The complete usage of [local resource references ](../theme-documentation-content#contents-organization ) is supported.
2020-03-19 05:35:37 +01:00
The `image` shortcode has the following named parameters:
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
* **src** *[required]* (**first** positional parameter)
2020-03-08 14:02:21 +01:00
URL of the image to be displayed.
2020-03-19 05:35:37 +01:00
* **alt** *[optional]* (**second** positional parameter)
2020-03-21 09:59:23 +01:00
Alternate text for the image if the image cannot be displayed, default value is the value of **src** parameter.
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
*Markdown or HTML format is supported.*
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
* **caption** *[optional]* (**third** positional parameter)
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
Image caption.
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
*Markdown or HTML format is supported.*
* **title** *[optional]*
Image title that will be shown when hovering on the image.
* **class** *[optional]*
2020-03-08 14:02:21 +01:00
`class` attribute of the HTML `figure` tag.
2020-03-19 05:35:37 +01:00
* **src_s** *[optional]*
2020-03-21 09:59:23 +01:00
URL of the image thumbnail, used for lightgallery, default value is the value of **src** parameter.
2020-03-19 05:35:37 +01:00
* **src_l** *[optional]*
2020-03-21 09:59:23 +01:00
URL of the HD image, used for lightgallery, default value is the value of **src** parameter.
2020-03-19 05:35:37 +01:00
* **height** *[optional]*
`height` attribute of the image.
* **width** *[optional]*
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
`width` attribute of the image.
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
* **linked** *[optional]*
2020-03-08 14:02:21 +01:00
2020-03-21 09:59:23 +01:00
Whether the image needs to be hyperlinked, default value is `true` .
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
* **rel** *[optional]*
Additional `rel` attributes of the HTML `a` tag, if **linked** parameter is set to `true` .
Example `image` input:
2020-03-08 14:02:21 +01:00
```markdown
2020-05-28 11:05:37 +02:00
{{< /* image src="/images/lighthouse.jpg" caption="Lighthouse (`image`)" src_s="/images/lighthouse-small.jpg" src_l="/images/lighthouse-large.jpg" */>}}
2020-03-08 14:02:21 +01:00
```
The rendered output looks like this:
2020-05-28 11:05:37 +02:00
{{< image src = "/images/lighthouse.jpg" caption = "Lighthouse (`image`)" src_s = "/images/lighthouse-small.jpg" src_l = "/images/lighthouse-large.jpg" > }}
2020-03-08 14:02:21 +01:00
2020-04-30 18:32:24 +02:00
## 4 admonition
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
The `admonition` shortcode supports **12** types of banners to help you put notice in your page.
*Markdown or HTML format in the content is supported.*
2020-03-08 14:02:21 +01:00
{{< admonition > }}
A **note** banner
{{< / admonition > }}
{{< admonition abstract > }}
An **abstract** banner
{{< / admonition > }}
{{< admonition info > }}
A **info** banner
{{< / admonition > }}
{{< admonition tip > }}
A **tip** banner
{{< / admonition > }}
{{< admonition success > }}
A **success** banner
{{< / admonition > }}
{{< admonition question > }}
A **question** banner
{{< / admonition > }}
{{< admonition warning > }}
A **warning** banner
{{< / admonition > }}
{{< admonition failure > }}
A **failure** banner
{{< / admonition > }}
{{< admonition danger > }}
A **danger** banner
{{< / admonition > }}
{{< admonition bug > }}
A **bug** banner
{{< / admonition > }}
{{< admonition example > }}
An **example** banner
{{< / admonition > }}
{{< admonition quote > }}
A **quote** banner
{{< / admonition > }}
2020-03-19 05:35:37 +01:00
The `admonition` shortcode has the following named parameters:
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
* **type** *[optional]* (**first** positional parameter)
2020-03-08 14:02:21 +01:00
2020-03-21 09:59:23 +01:00
Type of the `admonition` banner, default value is `note` .
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
* **title** *[optional]* (**second** positional parameter)
2020-03-08 14:02:21 +01:00
2020-03-21 09:59:23 +01:00
Title of the `admonition` banner, default value is the value of **type** parameter.
2020-03-08 14:02:21 +01:00
2020-04-27 19:38:22 +02:00
* **open** *[optional]* (**third** positional parameter) {{< version 0 . 2 . 0 changed > }}
2020-03-08 14:02:21 +01:00
2020-04-27 19:38:22 +02:00
Whether the content will be expandable by default, default value is `true` .
2020-03-08 14:02:21 +01:00
2020-03-19 05:35:37 +01:00
Example `admonition` input:
2020-03-08 14:02:21 +01:00
```markdown
2020-04-27 19:38:22 +02:00
{{< /* admonition type=tip title="This is a tip" open=false */>}}
2020-03-08 14:02:21 +01:00
A **tip** banner
{{< /* /admonition */>}}
Or
2020-04-27 19:38:22 +02:00
{{< /* admonition tip "This is a tip" false */>}}
2020-03-08 14:02:21 +01:00
A **tip** banner
{{< /* /admonition */>}}
```
The rendered output looks like this:
2020-04-27 19:38:22 +02:00
{{< admonition tip " This is a tip " false > }}
2020-03-08 14:02:21 +01:00
A **tip** banner
{{< / admonition > }}
2020-04-30 18:32:24 +02:00
## 5 mermaid
2020-03-08 14:02:21 +01:00
2022-05-08 19:31:17 +02:00
The `mermaid` shortcode supports diagrams in Hugo with [Mermaid ](https://mermaidjs.github.io/ ) library.
2020-03-08 14:02:21 +01:00
2022-05-08 19:31:17 +02:00
The full documentation is provided in [Theme Documentation - mermaid Shortcode ](../theme-documentation-mermaid-shortcode ).
2020-03-08 14:02:21 +01:00
2020-04-30 18:32:24 +02:00
## 6 echarts
2020-03-08 14:02:21 +01:00
2022-05-08 19:31:17 +02:00
The `echarts` shortcode supports data visualization in Hugo with [ECharts ](https://echarts.apache.org/ ) library.
2020-03-08 14:02:21 +01:00
2022-05-08 19:31:17 +02:00
The full documentation is provided in [Theme Documentation - echarts Shortcode ](../theme-documentation-echarts-shortcode ).
2020-03-21 13:52:12 +01:00
2020-04-30 18:32:24 +02:00
## 7 mapbox
2020-03-21 09:59:23 +01:00
{{< version 0 . 2 . 0 > }}
2022-05-08 19:31:17 +02:00
The `mapbox` shortcode supports interactive maps in Hugo with [Mapbox GL JS ](https://docs.mapbox.com/mapbox-gl-js ) library.
2020-03-21 09:59:23 +01:00
2022-05-08 19:31:17 +02:00
The full documentation is provided in [Theme Documentation - mapbox Shortcode ](../theme-documentation-mapbox-shortcode ).
2020-03-21 09:59:23 +01:00
2020-04-30 18:32:24 +02:00
## 8 music
2020-03-08 14:02:21 +01:00
2022-05-08 19:31:17 +02:00
The `music` shortcode embeds a responsive music player based on [APlayer ](https://github.com/MoePlayer/APlayer ) and [MetingJS ](https://github.com/metowolf/MetingJS ) library.
2020-03-19 05:35:37 +01:00
2022-05-08 19:31:17 +02:00
The full documentation is provided in [Theme Documentation - music Shortcode ](../theme-documentation-music-shortcode ).
2020-03-19 05:35:37 +01:00
2020-04-30 18:32:24 +02:00
## 9 bilibili
2020-03-08 14:02:21 +01:00
2020-04-15 12:30:22 +02:00
{{< version 0 . 2 . 0 changed > }}
2020-03-08 14:02:21 +01:00
The `bilibili` shortcode embeds a responsive video player for bilibili videos.
2022-05-08 19:31:17 +02:00
The full documentation is provided in [Theme Documentation - bilibili Shortcode ](../theme-documentation-bilibili-shortcode ).
2020-03-08 14:02:21 +01:00
2020-04-30 18:32:24 +02:00
## 10 typeit
2020-03-08 14:02:21 +01:00
2022-05-08 19:31:17 +02:00
The `typeit` shortcode provides typing animation based on [TypeIt ](https://typeitjs.com/ ) library.
2020-03-08 14:02:21 +01:00
2022-05-08 19:31:17 +02:00
The full documentation is provided in [Theme Documentation - typeit Shortcode ](../theme-documentation-typeit-shortcode ).
2020-05-15 11:43:04 +02:00
## 11 script
{{< version 0 . 2 . 8 > }}
`script` is a shortcode to insert custom ** :(fab fa-js fa-fw): Javascript** in your post.
{{< admonition > }}
The script content can be guaranteed to be executed in order after all third-party libraries are loaded. So you are free to use third-party libraries.
{{< / admonition > }}
Example `script` input:
```markdown
{{< /* script */>}}
console.log('Hello LoveIt!');
{{< /* /script */>}}
```
You can see the output in the console of the developer tool.
{{< script > } }
console.log('Hello LoveIt!');
{{< / script > }}
2022-05-06 17:54:15 +02:00
## 12 raw
`raw` is a shortcode to insert raw ** :(fab fa-html5 fa-fw): HTML** content in your post.
This is useful when you want to include some Markdown content to **avoid being rendered or escaped** by Hugo.
Example `raw` input:
```markdown
Inline Formula: {{< /* raw */>}}\(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{</* /raw */>}}
Block Formula:
{{< /* raw */>}}
\[ a=b+c \\ d+e=f \]
{{< /* /raw */>}}
Raw content using Markdown syntax: {{< /* raw */>}}* *Hello**{{< /* /raw */>}}
```
The rendered output looks like this:
Inline Formula: {{< raw > }}\(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{< / raw > }}
Block Formula:
{{< raw > }}
\[ a=b+c \\ d+e=f \]
{{< / raw > }}
Raw content using Markdown syntax: {{< raw > }}**Hello**{{< / raw > }}