mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 15:31:52 +00:00
feat(admonition): support arbitrary icon
This commit is contained in:
@@ -71,18 +71,20 @@ Admonitions allow you to insert eye-catching callout boxes in your content.
|
|||||||
Admonitions serve a similar purpose as the alert shortcode but are implemented via Hugo render hooks. The key difference is syntax: admonitions use Markdown syntax, making them more portable across different platforms, whereas shortcodes are specific to Hugo. The syntax resembles GitHub alerts:
|
Admonitions serve a similar purpose as the alert shortcode but are implemented via Hugo render hooks. The key difference is syntax: admonitions use Markdown syntax, making them more portable across different platforms, whereas shortcodes are specific to Hugo. The syntax resembles GitHub alerts:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> A Note type admonition.
|
> A Tip type admonition.
|
||||||
|
|
||||||
> [!TIP]+ Custom Title
|
> [!TIP]+ Custom Title
|
||||||
> A collapsible admonition with custom title.
|
> A collapsible admonition with custom title.
|
||||||
|
{icon="twitter"}
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> A Note type admonition.
|
> A Tip type admonition.
|
||||||
|
|
||||||
> [!TIP]+ Custom Title
|
> [!TIP]+ Custom Title
|
||||||
> A collapsible admonition with custom title.
|
> A collapsible admonition with custom title.
|
||||||
|
{icon="twitter"}
|
||||||
|
|
||||||
The alert sign (`+` or `-`) is optional to control whether the admonition is folded or not. Note that alert sign is only compatible in Obsidian.
|
The alert sign (`+` or `-`) is optional to control whether the admonition is folded or not. Note that alert sign is only compatible in Obsidian.
|
||||||
|
|
||||||
|
|||||||
@@ -71,18 +71,20 @@ Admonitions は、文書内で読者の注意を引くための強調表示を
|
|||||||
Admonitions は alert ショートコードと同様の目的を持ちますが、Hugo の render hooks を用いて実装されています。両者の主な違いは構文にあります。admonitions は Markdown 構文を使用するため、異なるプラットフォーム間でも扱いやすく、一方、ショートコードは Hugo 固有の仕組みです。構文は GitHub の alerts に近い形式です。
|
Admonitions は alert ショートコードと同様の目的を持ちますが、Hugo の render hooks を用いて実装されています。両者の主な違いは構文にあります。admonitions は Markdown 構文を使用するため、異なるプラットフォーム間でも扱いやすく、一方、ショートコードは Hugo 固有の仕組みです。構文は GitHub の alerts に近い形式です。
|
||||||
|
|
||||||
```md
|
```md
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> NOTE タイプの表示例。
|
> Tip タイプの表示例。
|
||||||
|
|
||||||
> [!TIP]+ カスタムタイトル
|
> [!TIP]+ カスタムタイトル
|
||||||
> タイトルを指定した折りたたみ可能な表示例。
|
> タイトルを指定した折りたたみ可能な表示例。
|
||||||
|
{icon="twitter"}
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> NOTE タイプの表示例。
|
> Tip タイプの表示例。
|
||||||
|
|
||||||
> [!TIP]+ カスタムタイトル
|
> [!TIP]+ カスタムタイトル
|
||||||
> タイトルを指定した折りたたみ可能な表示例。
|
> タイトルを指定した折りたたみ可能な表示例。
|
||||||
|
{icon="twitter"}
|
||||||
|
|
||||||
記号(`+` または `-`)は任意で、表示を折りたたむかどうかを制御します。なお、この記号は Obsidian のみ対応しています。
|
記号(`+` または `-`)は任意で、表示を折りたたむかどうかを制御します。なお、この記号は Obsidian のみ対応しています。
|
||||||
|
|
||||||
|
|||||||
@@ -71,18 +71,20 @@ Admonitions allow you to insert eye-catching callout boxes in your content.
|
|||||||
Admonitions serve a similar purpose as the alert shortcode but are implemented via Hugo render hooks. The key difference is syntax: admonitions use Markdown syntax, making them more portable across different platforms, whereas shortcodes are specific to Hugo. The syntax resembles GitHub alerts:
|
Admonitions serve a similar purpose as the alert shortcode but are implemented via Hugo render hooks. The key difference is syntax: admonitions use Markdown syntax, making them more portable across different platforms, whereas shortcodes are specific to Hugo. The syntax resembles GitHub alerts:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> A Note type admonition.
|
> A Tip type admonition.
|
||||||
|
|
||||||
> [!TIP]+ Custom Title
|
> [!TIP]+ Custom Title + Custom Icon
|
||||||
> A collapsible admonition with custom title.
|
> A collapsible admonition with custom title.
|
||||||
|
{icon="twitter"}
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> A Note type admonition.
|
> A Tip type admonition.
|
||||||
|
|
||||||
> [!TIP]+ Custom Title
|
> [!TIP]+ Custom Title + Custom Icon
|
||||||
> A collapsible admonition with custom title.
|
> A collapsible admonition with custom title.
|
||||||
|
{icon="twitter"}
|
||||||
|
|
||||||
The alert sign (`+` or `-`) is optional to control whether the admonition is folded or not. Note that alert sign is only compatible in Obsidian.
|
The alert sign (`+` or `-`) is optional to control whether the admonition is folded or not. Note that alert sign is only compatible in Obsidian.
|
||||||
|
|
||||||
|
|||||||
@@ -71,18 +71,20 @@ Admonition 用于在内容中插入醒目提示。
|
|||||||
Admonition 的用途与 alert shortcode 类似,但其实现方式是通过 Hugo 的 render hooks。两者的关键区别在于语法:admonition 使用 Markdown 语法,因此在不同平台之间具有更好的可移植性;而 shortcode 是 Hugo 专有的。其语法类似 GitHub 的 alerts:
|
Admonition 的用途与 alert shortcode 类似,但其实现方式是通过 Hugo 的 render hooks。两者的关键区别在于语法:admonition 使用 Markdown 语法,因此在不同平台之间具有更好的可移植性;而 shortcode 是 Hugo 专有的。其语法类似 GitHub 的 alerts:
|
||||||
|
|
||||||
```md
|
```md
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> 一个 NOTE 类型的提示块。
|
> 一个 Tip 类型的提示块。
|
||||||
|
|
||||||
> [!TIP]+ 自定义标题
|
> [!TIP]+ 自定义标题
|
||||||
> 一个带有自定义标题的可折叠提示块。
|
> 一个带有自定义标题的可折叠提示块。
|
||||||
|
{icon="twitter"}
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!TIP]
|
||||||
> 一个 NOTE 类型的提示块。
|
> 一个 Tip 类型的提示块。
|
||||||
|
|
||||||
> [!TIP]+ 自定义标题
|
> [!TIP]+ 自定义标题
|
||||||
> 一个带有自定义标题的可折叠提示块。
|
> 一个带有自定义标题的可折叠提示块。
|
||||||
|
{icon="twitter"}
|
||||||
|
|
||||||
提示符号(`+` 或 `-`)是可选的,用于控制提示块是否默认折叠。请注意,该提示符号仅在 Obsidian 中兼容。
|
提示符号(`+` 或 `-`)是可选的,用于控制提示块是否默认折叠。请注意,该提示符号仅在 Obsidian 中兼容。
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,8 @@
|
|||||||
|
|
||||||
{{- $rawType := .AlertType | lower -}}
|
{{- $rawType := .AlertType | lower -}}
|
||||||
{{- $normalizedType := index $typeMap $rawType | default $rawType -}}
|
{{- $normalizedType := index $typeMap $rawType | default $rawType -}}
|
||||||
{{- $iconName := index $iconMap $normalizedType | default "circle-info" -}}
|
{{- $iconName := .Attributes.icon | default (index $iconMap $normalizedType) | default "circle-info" -}}
|
||||||
|
|
||||||
{{- $admonitionTitle := .AlertTitle | default (i18n (printf "admonition.%s" $normalizedType) | default $normalizedType) -}}
|
{{- $admonitionTitle := .AlertTitle | default (i18n (printf "admonition.%s" $normalizedType) | default $normalizedType) -}}
|
||||||
|
|
||||||
{{- $containerClass := "admonition relative overflow-hidden rounded-lg border-l-4 my-3 px-4 py-3 shadow-sm" -}}
|
{{- $containerClass := "admonition relative overflow-hidden rounded-lg border-l-4 my-3 px-4 py-3 shadow-sm" -}}
|
||||||
@@ -84,7 +85,12 @@
|
|||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<blockquote {{ with .Attributes }}{{ . | safeHTMLAttr }}{{ end }}>
|
<blockquote
|
||||||
|
{{- range $k, $v := .Attributes -}}
|
||||||
|
{{- if $v -}}
|
||||||
|
{{- printf " %s=%q" $k ($v | transform.HTMLEscape) | safeHTMLAttr -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}>
|
||||||
{{- .Text | safeHTML -}}
|
{{- .Text | safeHTML -}}
|
||||||
</blockquote>
|
</blockquote>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|||||||
Reference in New Issue
Block a user