-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎉 Feat: support alert foldable title for blockquote compatible with O…
…bsidian Callouts refactor admonition shortcode: add todo type and aliases type change min hugo version: 0.134.0
- Loading branch information
Showing
23 changed files
with
151 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,10 @@ | |
@include details-transition-close; | ||
} | ||
} | ||
|
||
&.disabled { | ||
.details-summary { | ||
cursor: default; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- if .AlertTitle -}} | ||
{{- /* The extended syntax is compatible with Obsidian and FixIt admonition shortcode. */ -}} | ||
{{- /* BUG of Hugo https://github.com/gohugoio/hugo/issues/12913 */ -}} | ||
{{- $openMap := dict "+" true "-" false -}} | ||
{{- $open := index $openMap .AlertSign | default true -}} | ||
{{- $foldable := ne .AlertSign "" -}} | ||
{{- dict | ||
"Type" .AlertType | ||
"Title" .AlertTitle | ||
"Open" $open | ||
"Text" .Text | ||
"Foldable" $foldable | ||
| partial "plugin/admonition.html" | ||
-}} | ||
{{- else -}} | ||
{{- /* The basic syntax is compatible with GitHub, Obsidian, and Typora. */ -}} | ||
{{- dict | ||
"Type" .AlertType | ||
"Text" .Text | ||
"Attributes" .Attributes | ||
| partial "plugin/alert.html" | ||
-}} | ||
{{- end -}} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
{{- /* | ||
* The extended syntax of alert is compatible with Obsidian and FixIt admonition shortcode. | ||
* @param {String} .Text the content of the admonition box | ||
* @param {String} [.Type] the type of the admonition box | ||
* @param {String} [.Title] the title of the admonition box | ||
* @param {Boolean} [.Open] whether the admonition box is open, default is true | ||
* @param {Boolean} [.Foldable] whether the admonition box is foldable, default is true | ||
* TODO support customize admonitions by any .AlertType (add params to config iconMap) | ||
*/ -}} | ||
|
||
{{- $iconMap := dict | ||
"note" "fa-solid fa-pencil-alt" | ||
"abstract" "fa-solid fa-clipboard-list" | ||
"info" "fa-solid fa-circle-info" | ||
"todo" "fa-solid fa-list-check" | ||
"tip" "fa-regular fa-lightbulb" | ||
"success" "fa-solid fa-check" | ||
"question" "fa-regular fa-circle-question" | ||
"warning" "fa-solid fa-exclamation-triangle" | ||
"failure" "fa-solid fa-xmark" | ||
"danger" "fa-solid fa-bolt" | ||
"bug" "fa-solid fa-bug" | ||
"example" "fa-solid fa-list-ul" | ||
"quote" "fa-solid fa-quote-right" | ||
-}} | ||
{{- $aliasMap := dict | ||
"summary" "abstract" | ||
"tldr" "abstract" | ||
"hint" "tip" | ||
"important" "tip" | ||
"check" "success" | ||
"done" "success" | ||
"help" "question" | ||
"faq" "question" | ||
"caution" "warning" | ||
"attention" "warning" | ||
"fail" "failure" | ||
"missing" "failure" | ||
"error" "danger" | ||
"cite" "quote" | ||
-}} | ||
{{- $type := .Type | lower -}} | ||
{{- $type = index $aliasMap $type | default $type | default "note" -}} | ||
{{- $icon := index $iconMap $type | default "fa-solid fa-pencil-alt" -}} | ||
{{- $title := .Title | default (T (printf "admonition.%v" $type)) | default (title $type) -}} | ||
{{- $foldable := ne .Foldable false -}} | ||
|
||
<div class="details admonition {{ $type }}{{ if .Open | ne false }} open{{ end }}{{ if not $foldable }} disabled{{ end }}"> | ||
<div class="details-summary admonition-title"> | ||
{{- dict "Class" (add "icon fa-fw " $icon) | partial "plugin/icon.html" -}} | ||
{{- $title | safeHTML -}} | ||
{{- if $foldable -}} | ||
{{- dict "Class" "details-icon fa-solid fa-angle-right fa-fw" | partial "plugin/icon.html" -}} | ||
{{- end -}} | ||
</div> | ||
<div class="details-content"> | ||
<div class="admonition-content"> | ||
{{- .Text | safeHTML -}} | ||
</div> | ||
</div> | ||
</div> | ||
{{- /* EOF */ -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,12 @@ | ||
{{- $type := cond .IsNamedParams (.Get "type") (.Get 0) -}} | ||
{{- $title := cond .IsNamedParams (.Get "title") (.Get 1) | .Page.RenderString -}} | ||
{{- $open := cond .IsNamedParams (.Get "open") (.Get 2) -}} | ||
{{- $inner := .Inner | .Page.RenderString -}} | ||
|
||
{{- $iconMap := dict "note" "fa-solid fa-pencil-alt fa-fw" -}} | ||
{{- $iconMap = dict "abstract" "fa-solid fa-list-ul fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "info" "fa-solid fa-info-circle fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "tip" "fa-solid fa-lightbulb fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "success" "fa-solid fa-check-circle fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "question" "fa-solid fa-question-circle fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "warning" "fa-solid fa-exclamation-triangle fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "failure" "fa-solid fa-times-circle fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "danger" "fa-solid fa-skull-crossbones fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "bug" "fa-solid fa-bug fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "example" "fa-solid fa-list-ol fa-fw" | merge $iconMap -}} | ||
{{- $iconMap = dict "quote" "fa-solid fa-quote-right fa-fw" | merge $iconMap -}} | ||
{{- $iconDetails := "fa-solid fa-angle-right fa-fw" -}} | ||
|
||
{{- if .IsNamedParams -}} | ||
{{- $type := .Get "type" | default "note" -}} | ||
<div class="details admonition {{ $type }}{{ if .Get `open` | ne false }} open{{ end }}"> | ||
<div class="details-summary admonition-title"> | ||
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}" aria-hidden="true"></i>{{ .Get "title" | .Page.RenderString | default (T (printf "admonition.%v" $type)) }}<i class="details-icon {{ $iconDetails }}" aria-hidden="true"></i> | ||
</div> | ||
<div class="details-content"> | ||
<div class="admonition-content"> | ||
{{- $inner -}} | ||
</div> | ||
</div> | ||
</div> | ||
{{- else -}} | ||
{{- $type := .Get 0 | default "note" -}} | ||
<div class="details admonition {{ $type }}{{ if .Get 2 | ne false }} open{{ end }}"> | ||
<div class="details-summary admonition-title"> | ||
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}" aria-hidden="true"></i>{{ .Get 1 | .Page.RenderString | default (T (printf "admonition.%v" $type)) }}<i class="details-icon {{ $iconDetails }}" aria-hidden="true"></i> | ||
</div> | ||
<div class="details-content"> | ||
<div class="admonition-content"> | ||
{{- $inner -}} | ||
</div> | ||
</div> | ||
</div> | ||
{{- end -}} | ||
{{- dict | ||
"Type" $type | ||
"Title" $title | ||
"Open" $open | ||
"Text" $inner | ||
| partial "plugin/admonition.html" | ||
-}} |