icon: add style and color options

This commit is contained in:
Sören Weber 2025-03-24 15:59:19 +01:00
parent a5b517d1aa
commit 42ccc9d636
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
6 changed files with 35 additions and 16 deletions
docs/content/shortcodes

View file

@ -6,9 +6,9 @@ title = 'Icon'
The `icon` shortcode displays icons using the [Font Awesome](https://fontawesome.com) library.
{{% icon exclamation-triangle %}}
{{% icon angle-double-up %}}
{{% icon skull-crossbones %}}
{{% icon style="warning" %}}
{{% icon icon="angle-double-up" color="blue" %}}
## Usage
@ -16,18 +16,18 @@ The `icon` shortcode displays icons using the [Font Awesome](https://fontawesome
{{% tab title="shortcode" %}}
````go
{{%/* icon icon="exclamation-triangle" */%}}
{{%/* icon icon="angle-double-up" */%}}
{{%/* icon icon="skull-crossbones" */%}}
{{%/* icon style="warning" */%}}
{{%/* icon icon="angle-double-up" color="blue" */%}}
````
{{% /tab %}}
{{% tab title="shortcode (positional)" %}}
````go
{{%/* icon skull-crossbones */%}}
{{%/* icon exclamation-triangle */%}}
{{%/* icon angle-double-up */%}}
{{%/* icon skull-crossbones */%}}
````
{{% /tab %}}
@ -36,15 +36,16 @@ The `icon` shortcode displays icons using the [Font Awesome](https://fontawesome
````go
{{ partial "shortcodes/icon.html" (dict
"page" .
"icon" "exclamation-triangle"
"icon" "skull-crossbones"
)}}
{{ partial "shortcodes/icon.html" (dict
"page" .
"style" "warning"
)}}
{{ partial "shortcodes/icon.html" (dict
"page" .
"icon" "angle-double-up"
)}}
{{ partial "shortcodes/icon.html" (dict
"page" .
"icon" "skull-crossbones"
"color" "blue"
)}}
````
@ -56,6 +57,8 @@ The `icon` shortcode displays icons using the [Font Awesome](https://fontawesome
| Name | Position | Default | Notes |
|-----------------------|----------|-----------------|-------------|
| **icon** | 1 | _<empty>_ | [Font Awesome icon name](#finding-an-icon) to be displayed. It will be displayed in the text color of its according context. |
| **style** | | _&lt;empty&gt;_ | The style scheme used for the icon.<br><br>- by severity: `caution`, `important`, `info`, `note`, `tip`, `warning`<br>- by brand color: `primary`, `secondary`, `accent`<br>- by color: `blue`, `cyan`, `green`, `grey`, `magenta`, `orange`, `red`<br>- by special color: `default`, `transparent`, `code`<br><br>You can also [define your own styles](shortcodes/notice#defining-own-styles). |
| **color** | | _&lt;empty&gt;_ | The [CSS color value](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value) to be used. If not set, the chosen color depends on the **style**. Any given value will overwrite the default.<br><br>- for severity styles: a nice matching color for the severity<br>- for all other styles: the corresponding color<br><br> |
### Finding an icon
@ -63,7 +66,7 @@ Browse through the available icons in the [Font Awesome Gallery](https://fontawe
Once on the Font Awesome page for a specific icon, for example the page for the [heart](https://fontawesome.com/v6/icons/heart?s=solid), copy the icon name and paste into the Markdown content.
### Customising Icons
### Customizing Icons
Font Awesome provides many ways to modify the icon
@ -84,6 +87,14 @@ Built with {{%/* icon heart */%}} by Relearn and Hugo
Built with {{% icon heart %}} by Relearn and Hugo
### With color
````go
Built with {{%/* icon icon="heart" style="red" */%}} by Relearn and Hugo
````
Built with {{% icon icon="heart" style="red" %}} by Relearn and Hugo
### Advanced HTML Usage
While the shortcode simplifies using standard icons, the icon customization and other advanced features of the Font Awesome library require you to use HTML directly. Paste the `<i>` HTML into markup, and Font Awesome will load the relevant icon.