-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
170 additions
and
84 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 |
---|---|---|
@@ -1,40 +1,46 @@ | ||
.details { | ||
.details-summary { | ||
> .details-summary { | ||
@include border-radius($global-border-radius); | ||
|
||
&:hover { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
i.details-icon { | ||
color: $global-font-secondary-color; | ||
@include transition(transform 0.2s ease); | ||
i.details-icon { | ||
color: $global-font-secondary-color; | ||
@include transition(transform 0.2s ease); | ||
|
||
[data-theme='dark'] & { | ||
color: $global-font-secondary-color-dark; | ||
[data-theme='dark'] & { | ||
color: $global-font-secondary-color-dark; | ||
} | ||
} | ||
} | ||
|
||
.details-content { | ||
> .details-content { | ||
max-height: 0; | ||
overflow-y: hidden; | ||
@include details-transition-open; | ||
} | ||
|
||
&.open { | ||
.details-summary { | ||
> .details-summary { | ||
@include border-radius($global-border-radius $global-border-radius 0 0); | ||
} | ||
|
||
i.details-icon { | ||
@include transform(rotate(90deg)); | ||
i.details-icon { | ||
@include transform(rotate(90deg)); | ||
} | ||
} | ||
|
||
.details-content { | ||
> .details-content { | ||
max-height: 100%; | ||
@include border-radius(0 0 $global-border-radius $global-border-radius); | ||
@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,29 @@ | ||
{{- if .AlertTitle -}} | ||
{{- /* The extended syntax is compatible with Obsidian and FixIt admonition shortcode. */ -}} | ||
{{- /* === Dirty hack === */ -}} | ||
{{- $title := .AlertTitle -}} | ||
{{- if ne .AlertTitle (.AlertTitle | plainify) -}} | ||
{{- /* BUG of Hugo https://github.com/gohugoio/hugo/issues/12913 */ -}} | ||
{{- $title = add .AlertTitle ">" -}} | ||
{{- end -}} | ||
{{- /* === Dirty hack === */ -}} | ||
{{- $openMap := dict "+" true "-" false -}} | ||
{{- $open := index $openMap .AlertSign | default true -}} | ||
{{- $foldable := ne .AlertSign "" -}} | ||
{{- dict | ||
"Type" .AlertType | ||
"Title" $title | ||
"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
Oops, something went wrong.