From bd40c855862af61b68c8b0a9b1e77581f1209bb4 Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Mon, 7 Oct 2024 17:03:52 +0800
Subject: [PATCH 1/5] :tada: Feat: support alert foldable title for blockquote
compatible with Obsidian Callouts
refactor admonition shortcode: add todo type and aliases type
change min hugo version: 0.134.0
---
assets/css/_partials/_details.scss | 32 ++++++----
assets/css/_partials/_maps/_admonition.scss | 3 +-
assets/css/_shortcodes/_admonition.scss | 37 +++++++----
assets/js/theme.js | 2 +-
i18n/de.toml | 1 +
i18n/en.toml | 1 +
i18n/es.toml | 1 +
i18n/fr.toml | 1 +
i18n/hi.toml | 1 +
i18n/it.toml | 1 +
i18n/pl.toml | 1 +
i18n/pt-BR.toml | 1 +
i18n/ro.toml | 1 +
i18n/ru.toml | 1 +
i18n/sr.toml | 1 +
i18n/vi.toml | 1 +
i18n/zh-CN.toml | 1 +
i18n/zh-TW.toml | 1 +
.../_markup/render-blockquote-alert.html | 29 +++++++++
.../_default/_markup/render-blockquote.html | 11 ----
layouts/partials/plugin/admonition.html | 63 +++++++++++++++++++
layouts/partials/plugin/alert.html | 14 ++---
layouts/shortcodes/admonition.html | 49 +++------------
23 files changed, 170 insertions(+), 84 deletions(-)
create mode 100644 layouts/_default/_markup/render-blockquote-alert.html
delete mode 100644 layouts/_default/_markup/render-blockquote.html
create mode 100644 layouts/partials/plugin/admonition.html
diff --git a/assets/css/_partials/_details.scss b/assets/css/_partials/_details.scss
index 926288df8..7b4c7c908 100644
--- a/assets/css/_partials/_details.scss
+++ b/assets/css/_partials/_details.scss
@@ -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;
+ }
+ }
}
diff --git a/assets/css/_partials/_maps/_admonition.scss b/assets/css/_partials/_maps/_admonition.scss
index 5c79eeb16..8a0f55911 100644
--- a/assets/css/_partials/_maps/_admonition.scss
+++ b/assets/css/_partials/_maps/_admonition.scss
@@ -3,9 +3,10 @@ $admonition-color-map:
'note' #448aff rgba(68, 138, 255, 0.1),
'abstract' #00b0ff rgba(0, 176, 255, 0.1),
'info' #00b8d4 rgba(0, 184, 212, 0.1),
+ 'todo' #5e9aff rgba(94, 154, 255, 0.1),
'tip' #00bfa5 rgba(0, 191, 165, 0.1),
'success' #00c853 rgba(0, 200, 83, 0.1),
- 'question' #64dd17 rgba(100, 221, 23, 0.1),
+ 'question' #ffbd67 rgba(255, 190, 0, 0.1),
'warning' #ff9100 rgba(255, 145, 0, 0.1),
'failure' #ff5252 rgba(255, 82, 82, 0.1),
'danger' #ff1744 rgba(255, 23, 68, 0.1),
diff --git a/assets/css/_shortcodes/_admonition.scss b/assets/css/_shortcodes/_admonition.scss
index 1a8c38ef1..7a6a38d50 100644
--- a/assets/css/_shortcodes/_admonition.scss
+++ b/assets/css/_shortcodes/_admonition.scss
@@ -16,6 +16,19 @@
.admonition-content {
padding: 0.5rem 0;
+
+ // for extended alert syntax
+ > p {
+ margin: 0;
+ }
+ // title-only alert
+ &:empty {
+ display: none;
+ }
+ // BUG of Hugo https://github.com/gohugoio/hugo/issues/12913
+ &:has(> p:only-child:empty) {
+ display: none;
+ }
}
i.icon {
@@ -36,17 +49,17 @@
background-color: $background-color;
border-left-color: $color;
- .admonition-title {
+ > .admonition-title {
border-bottom-color: $background-color;
background-color: opacify($background-color, 0.15);
- }
- &.open .admonition-title {
- background-color: $background-color;
+ i.icon {
+ color: $color;
+ }
}
- i.icon {
- color: $color;
+ &.open > .admonition-title {
+ background-color: $background-color;
}
}
@@ -55,17 +68,17 @@
background-color: $background-color;
border-left-color: $color;
- .admonition-title {
+ > .admonition-title {
border-bottom-color: $background-color;
background-color: opacify($background-color, 0.15);
- }
- &.open .admonition-title {
- background-color: $background-color;
+ i.icon {
+ color: $color;
+ }
}
- i.icon {
- color: $color;
+ &.open > .admonition-title {
+ background-color: $background-color;
}
}
}
diff --git a/assets/js/theme.js b/assets/js/theme.js
index d5d70c4e5..71aaa49a7 100644
--- a/assets/js/theme.js
+++ b/assets/js/theme.js
@@ -334,7 +334,7 @@ class FixIt {
}
initDetails(target = document) {
- this.util.forEach(target.getElementsByClassName('details'), ($details) => {
+ this.util.forEach(target.querySelectorAll('.details:not(.disabled)'), ($details) => {
const $summary = $details.querySelector('.details-summary');
$summary.addEventListener('click', () => {
$details.classList.toggle('open');
diff --git a/i18n/de.toml b/i18n/de.toml
index d473aef3f..fb2fa6f34 100644
--- a/i18n/de.toml
+++ b/i18n/de.toml
@@ -187,6 +187,7 @@ caution = ""
note = "Notiz"
abstract = "Kurzfassung"
info = "Info"
+todo = "Aufgabe"
tip = "Tipp"
success = "Erfolg"
question = "Frage"
diff --git a/i18n/en.toml b/i18n/en.toml
index c87b63951..e3ae77b3b 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -186,6 +186,7 @@ caution = "Caution"
note = "Note"
abstract = "Abstract"
info = "Info"
+todo = "Todo"
tip = "Tip"
success = "Success"
question = "Question"
diff --git a/i18n/es.toml b/i18n/es.toml
index 4cda041e7..55ba8a003 100644
--- a/i18n/es.toml
+++ b/i18n/es.toml
@@ -187,6 +187,7 @@ caution = ""
note = "Nota"
abstract = "Resumen"
info = "Información"
+todo = "Por hacer"
tip = "Consejo"
success = "Éxito"
question = "Pregunta"
diff --git a/i18n/fr.toml b/i18n/fr.toml
index 10a3437d6..4a07ca56d 100644
--- a/i18n/fr.toml
+++ b/i18n/fr.toml
@@ -186,6 +186,7 @@ caution = ""
note = "Remarque"
abstract = "Résumé"
info = "Info"
+todo = "À faire"
tip = "Astuce"
success = "Succès"
question = "Question"
diff --git a/i18n/hi.toml b/i18n/hi.toml
index dc48801e4..75b46b2a9 100644
--- a/i18n/hi.toml
+++ b/i18n/hi.toml
@@ -187,6 +187,7 @@ caution = ""
note = "ध्यान दें"
abstract = "सारांश"
info = "जानकारी"
+todo = "करने के लिए"
tip = "टिप"
success = "सफलता"
question = "प्रश्न"
diff --git a/i18n/it.toml b/i18n/it.toml
index 2d74d5204..8c72e96f4 100644
--- a/i18n/it.toml
+++ b/i18n/it.toml
@@ -187,6 +187,7 @@ caution = ""
note = "Note"
abstract = "Sommario"
info = "Info"
+todo = "Da fare"
tip = "Suggerimenti"
success = "Successo"
question = "Domande"
diff --git a/i18n/pl.toml b/i18n/pl.toml
index 076ecb65d..be142e67f 100644
--- a/i18n/pl.toml
+++ b/i18n/pl.toml
@@ -187,6 +187,7 @@ caution = ""
note = "Notka"
abstract = "Streszczenie"
info = "Info"
+todo = "Do zrobienia"
tip = "Wskazówka"
success = "Sukces"
question = "Pytanie"
diff --git a/i18n/pt-BR.toml b/i18n/pt-BR.toml
index 34bd6ba15..ceccd54dc 100644
--- a/i18n/pt-BR.toml
+++ b/i18n/pt-BR.toml
@@ -187,6 +187,7 @@ caution = ""
note = "Nota"
abstract = "Abstrato"
info = "Info"
+todo = "A fazer"
tip = "Dica"
success = "Sucesso"
question = "Pergunta"
diff --git a/i18n/ro.toml b/i18n/ro.toml
index c6422dc77..85a24a479 100644
--- a/i18n/ro.toml
+++ b/i18n/ro.toml
@@ -187,6 +187,7 @@ caution = ""
note = "Notă"
abstract = "Rezumat"
info = "Info"
+todo = "De făcut"
tip = "Sfat"
success = "Succes"
question = "Întrebare"
diff --git a/i18n/ru.toml b/i18n/ru.toml
index 73eb947a4..b5fd91e12 100644
--- a/i18n/ru.toml
+++ b/i18n/ru.toml
@@ -187,6 +187,7 @@ caution = ""
note = "Замечание"
abstract = "Краткое описание"
info = "Инфо"
+todo = "Сделать"
tip = "Совет"
success = "Удачто"
question = "Вопрос"
diff --git a/i18n/sr.toml b/i18n/sr.toml
index 84ec9dd03..ae3a6dea1 100644
--- a/i18n/sr.toml
+++ b/i18n/sr.toml
@@ -187,6 +187,7 @@ caution = ""
note = "Напомена"
abstract = "Сажетак"
info = "Инфо"
+todo = "То-до"
tip = "Савет"
success = "Успех"
question = "Питање"
diff --git a/i18n/vi.toml b/i18n/vi.toml
index 2b2b9b71f..ada6b9ffd 100644
--- a/i18n/vi.toml
+++ b/i18n/vi.toml
@@ -186,6 +186,7 @@ caution = ""
note = "Ghi chú"
abstract = "Tóm tắt"
info = "Thông tin"
+todo = "Cần làm"
tip = "Mẹo"
success = "Thành công"
question = "Câu hỏi"
diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml
index 53c719390..7f13f6c8e 100644
--- a/i18n/zh-CN.toml
+++ b/i18n/zh-CN.toml
@@ -182,6 +182,7 @@ caution = "小心"
note = "注意"
abstract = "摘要"
info = "信息"
+todo = "待办"
tip = "技巧"
success = "成功"
question = "问题"
diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml
index 4af6c3bec..53092dead 100644
--- a/i18n/zh-TW.toml
+++ b/i18n/zh-TW.toml
@@ -182,6 +182,7 @@ caution = "小心"
note = "注意"
abstract = "摘要"
info = "資訊"
+todo = "待辦"
tip = "提示"
success = "成功"
question = "問題"
diff --git a/layouts/_default/_markup/render-blockquote-alert.html b/layouts/_default/_markup/render-blockquote-alert.html
new file mode 100644
index 000000000..52a0458e7
--- /dev/null
+++ b/layouts/_default/_markup/render-blockquote-alert.html
@@ -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 -}}
diff --git a/layouts/_default/_markup/render-blockquote.html b/layouts/_default/_markup/render-blockquote.html
deleted file mode 100644
index 7c0eb2815..000000000
--- a/layouts/_default/_markup/render-blockquote.html
+++ /dev/null
@@ -1,11 +0,0 @@
-{{- $attrs := "" }}
-{{- range $key, $value := .Attributes }}
- {{- $attrs = printf "%s %s=%q" $attrs $key $value }}
-{{- end }}
-{{- $attrs = trim $attrs " " }}
-
-{{- if eq .Type "alert" -}}
- {{- dict "Text" .Text "Type" .AlertType "Attributes" .Attributes | partial "plugin/alert.html" -}}
-{{- else -}}
-
- {{- $icon := index $icons .Type -}}
+ {{- $icon := index $iconMap .Type -}}
{{- dict "Src" $icon | partial "plugin/icon.html" }}
{{- or (T (printf "alert.%v" .Type)) (title .Type) -}}
diff --git a/layouts/shortcodes/admonition.html b/layouts/shortcodes/admonition.html
index 07d6ebf8d..c7b929a92 100644
--- a/layouts/shortcodes/admonition.html
+++ b/layouts/shortcodes/admonition.html
@@ -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" -}}
-
-
- {{ .Get "title" | .Page.RenderString | default (T (printf "admonition.%v" $type)) }}
-
-
-
-{{- else -}}
- {{- $type := .Get 0 | default "note" -}}
-
-
- {{ .Get 1 | .Page.RenderString | default (T (printf "admonition.%v" $type)) }}
-
-
-
-{{- end -}}
+{{- dict
+ "Type" $type
+ "Title" $title
+ "Open" $open
+ "Text" $inner
+ | partial "plugin/admonition.html"
+-}}
From cf71f1e289636369b5f5d87499f5debdbd8ff51b Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Tue, 8 Oct 2024 15:26:01 +0800
Subject: [PATCH 2/5] :arrow_up: Chore: update min hugo version to 0.134.0
---
README.md | 2 +-
README.zh-cn.md | 2 +-
hugo.toml | 2 +-
theme.toml | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index b616b6487..314919387 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
# FixIt
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases)
-[![Hugo](https://img.shields.io/badge/Hugo-%5E0.132.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
+[![Hugo](https://img.shields.io/badge/Hugo-%5E0.134.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/hugo-fixit/FixIt)
diff --git a/README.zh-cn.md b/README.zh-cn.md
index cacad9c80..fcab43536 100644
--- a/README.zh-cn.md
+++ b/README.zh-cn.md
@@ -8,7 +8,7 @@
# FixIt
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases)
-[![Hugo](https://img.shields.io/badge/Hugo-%5E0.132.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
+[![Hugo](https://img.shields.io/badge/Hugo-%5E0.134.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/hugo-fixit/FixIt)
diff --git a/hugo.toml b/hugo.toml
index cef4342e4..f0557f727 100644
--- a/hugo.toml
+++ b/hugo.toml
@@ -135,7 +135,7 @@ enableEmoji = true
[module]
[module.hugoVersion]
extended = true
- min = "0.132.0"
+ min = "0.134.0"
# -------------------------------------------------------------------------------------
# Markup related configuration in Hugo
diff --git a/theme.toml b/theme.toml
index 5c3ac03c5..620fb6c9e 100644
--- a/theme.toml
+++ b/theme.toml
@@ -7,7 +7,7 @@ licenselink = "https://github.com/hugo-fixit/FixIt/blob/master/LICENSE"
description = "A Clean, Elegant but Advanced Hugo Theme for Hugo."
homepage = "https://github.com/hugo-fixit/FixIt"
demosite = "https://fixit.lruihao.cn"
-min_version = "0.132.0"
+min_version = "0.134.0"
tags = [
"blog",
From f7670a714b6d2c92427c2ad4ffe2b822c30500ab Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Wed, 9 Oct 2024 10:42:37 +0800
Subject: [PATCH 3/5] :bug: Fix(ignore): resolves Hugo lost closing tag in
.AlertTitle
---
layouts/_default/_markup/render-blockquote-alert.html | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/layouts/_default/_markup/render-blockquote-alert.html b/layouts/_default/_markup/render-blockquote-alert.html
index 52a0458e7..91899da67 100644
--- a/layouts/_default/_markup/render-blockquote-alert.html
+++ b/layouts/_default/_markup/render-blockquote-alert.html
@@ -1,11 +1,8 @@
{{- 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 -}}
+ {{- /* BUG of Hugo https://github.com/gohugoio/hugo/issues/12913 */ -}}
+ {{- $title := replaceRE "([a-zA-Z]+)$" "$1>" .AlertTitle -}}
{{- /* === Dirty hack === */ -}}
{{- $openMap := dict "+" true "-" false -}}
{{- $open := index $openMap .AlertSign | default true -}}
From 39a48f35f0ddf668cfe1b5cddbf906df674ecb7a Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Wed, 9 Oct 2024 11:13:11 +0800
Subject: [PATCH 4/5] :zap: Perf: if .AlertType not in basic types, rendering
to extended alert syntax
---
layouts/_default/_markup/render-blockquote-alert.html | 4 +++-
layouts/partials/plugin/alert.html | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/layouts/_default/_markup/render-blockquote-alert.html b/layouts/_default/_markup/render-blockquote-alert.html
index 91899da67..8e077cf90 100644
--- a/layouts/_default/_markup/render-blockquote-alert.html
+++ b/layouts/_default/_markup/render-blockquote-alert.html
@@ -1,4 +1,6 @@
-{{- if .AlertTitle -}}
+{{- $basicTypes := slice "note" "tip" "important" "warning" "caution" -}}
+
+{{- if .AlertTitle | or .AlertSign | or (.AlertType | in $basicTypes | not) -}}
{{- /* The extended syntax is compatible with Obsidian and FixIt admonition shortcode. */ -}}
{{- /* === Dirty hack === */ -}}
{{- /* BUG of Hugo https://github.com/gohugoio/hugo/issues/12913 */ -}}
diff --git a/layouts/partials/plugin/alert.html b/layouts/partials/plugin/alert.html
index 2d78bdba5..81a2bc341 100644
--- a/layouts/partials/plugin/alert.html
+++ b/layouts/partials/plugin/alert.html
@@ -7,11 +7,11 @@
*/ -}}
{{- $iconMap := dict
- "caution" "images/icons/alerts/stop.svg"
- "important" "images/icons/alerts/report.svg"
"note" "images/icons/alerts/info.svg"
"tip" "images/icons/alerts/light-bulb.svg"
+ "important" "images/icons/alerts/report.svg"
"warning" "images/icons/alerts/alert.svg"
+ "caution" "images/icons/alerts/stop.svg"
-}}
{{- $attrs := "" }}
From 12cc5f7e60b4ddee43b2219d01a00bb6b95bef0e Mon Sep 17 00:00:00 2001
From: Cell <1024@lruihao.cn>
Date: Wed, 9 Oct 2024 15:51:01 +0800
Subject: [PATCH 5/5] :sparkles: Feat: add custom admonitions support
hugo 0.134.1
---
README.md | 2 +-
README.zh-cn.md | 2 +-
assets/css/_partials/_maps/_admonition.scss | 71 ++++++++++++++++-----
assets/css/_partials/_maps/_alert.scss | 60 ++++++++++++-----
assets/css/_partials/_single/_alert.scss | 12 ++--
assets/css/_shortcodes/_admonition.scss | 54 +++++++---------
hugo.toml | 8 ++-
layouts/partials/plugin/admonition.html | 4 +-
theme.toml | 2 +-
9 files changed, 142 insertions(+), 73 deletions(-)
diff --git a/README.md b/README.md
index 314919387..5130afc8a 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
# FixIt
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases)
-[![Hugo](https://img.shields.io/badge/Hugo-%5E0.134.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
+[![Hugo](https://img.shields.io/badge/Hugo-%5E0.134.1-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/hugo-fixit/FixIt)
diff --git a/README.zh-cn.md b/README.zh-cn.md
index fcab43536..49561618c 100644
--- a/README.zh-cn.md
+++ b/README.zh-cn.md
@@ -8,7 +8,7 @@
# FixIt
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases)
-[![Hugo](https://img.shields.io/badge/Hugo-%5E0.134.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
+[![Hugo](https://img.shields.io/badge/Hugo-%5E0.134.1-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/hugo-fixit/FixIt)
diff --git a/assets/css/_partials/_maps/_admonition.scss b/assets/css/_partials/_maps/_admonition.scss
index 8a0f55911..035038086 100644
--- a/assets/css/_partials/_maps/_admonition.scss
+++ b/assets/css/_partials/_maps/_admonition.scss
@@ -1,16 +1,55 @@
-// Color map of admonition [$type $color $background-color, ... ]
-$admonition-color-map:
- 'note' #448aff rgba(68, 138, 255, 0.1),
- 'abstract' #00b0ff rgba(0, 176, 255, 0.1),
- 'info' #00b8d4 rgba(0, 184, 212, 0.1),
- 'todo' #5e9aff rgba(94, 154, 255, 0.1),
- 'tip' #00bfa5 rgba(0, 191, 165, 0.1),
- 'success' #00c853 rgba(0, 200, 83, 0.1),
- 'question' #ffbd67 rgba(255, 190, 0, 0.1),
- 'warning' #ff9100 rgba(255, 145, 0, 0.1),
- 'failure' #ff5252 rgba(255, 82, 82, 0.1),
- 'danger' #ff1744 rgba(255, 23, 68, 0.1),
- 'bug' #f50057 rgba(245, 0, 87, 0.1),
- 'example' #651fff rgba(101, 31, 255, 0.1),
- 'quote' #9e9e9e rgba(159, 159, 159, 0.1)
- !default;
+// Color map of admonitions
+$admonition-color-map: (
+ note: (
+ color: #448aff,
+ bg-color: rgba(68, 138, 255, 0.1),
+ ),
+ abstract: (
+ color: #00b0ff,
+ bg-color: rgba(0, 176, 255, 0.1),
+ ),
+ info: (
+ color: #00b8d4,
+ bg-color: rgba(0, 184, 212, 0.1),
+ ),
+ todo: (
+ color: #5e9aff,
+ bg-color: rgba(94, 154, 255, 0.1),
+ ),
+ tip: (
+ color: #00bfa5,
+ bg-color: rgba(0, 191, 165, 0.1),
+ ),
+ success: (
+ color: #00c853,
+ bg-color: rgba(0, 200, 83, 0.1),
+ ),
+ question: (
+ color: #ffbd67,
+ bg-color: rgba(255, 190, 0, 0.1),
+ ),
+ warning: (
+ color: #ff9100,
+ bg-color: rgba(255, 145, 0, 0.1),
+ ),
+ failure: (
+ color: #ff5252,
+ bg-color: rgba(255, 82, 82, 0.1),
+ ),
+ danger: (
+ color: #ff1744,
+ bg-color: rgba(255, 23, 68, 0.1),
+ ),
+ bug: (
+ color: #f50057,
+ bg-color: rgba(245, 0, 87, 0.1),
+ ),
+ example: (
+ color: #651fff,
+ bg-color: rgba(101, 31, 255, 0.1),
+ ),
+ quote: (
+ color: #9e9e9e,
+ bg-color: rgba(159, 159, 159, 0.1),
+ ),
+) !default;
diff --git a/assets/css/_partials/_maps/_alert.scss b/assets/css/_partials/_maps/_alert.scss
index 4a612839e..0be4ed2c9 100644
--- a/assets/css/_partials/_maps/_alert.scss
+++ b/assets/css/_partials/_maps/_alert.scss
@@ -1,16 +1,46 @@
-// Color map of alert [$type $border-color $color, ... ]
-$alert-color-map:
- 'note' #0969da #0969da,
- 'tip' #1a7f37 #1a7f37,
- 'important' #8250df #8250df,
- 'warning' #bf8700 #9a6700,
- 'caution' #cf222e #d1242f,
- !default;
+// Color map of basic alerts
+$alert-color-map: (
+ note: (
+ border-color: #0969da,
+ color: #0969da,
+ ),
+ tip: (
+ border-color: #1a7f37,
+ color: #1a7f37,
+ ),
+ important: (
+ border-color: #8250df,
+ color: #8250df,
+ ),
+ warning: (
+ border-color: #bf8700,
+ color: #9a6700,
+ ),
+ caution: (
+ border-color: #cf222e,
+ color: #d1242f,
+ ),
+) !default;
-$alert-color-map-dark:
- 'note' #316dca #478be6,
- 'tip' #347d39 #57ab5a,
- 'important' #8256d0 #986ee2,
- 'warning' #966600 #c69026,
- 'caution' #c93c37 #e5534b,
- !default;
+$alert-color-map-dark: (
+ note: (
+ border-color: #316dca,
+ color: #478be6,
+ ),
+ tip: (
+ border-color: #347d39,
+ color: #57ab5a,
+ ),
+ important: (
+ border-color: #8256d0,
+ color: #986ee2,
+ ),
+ warning: (
+ border-color: #966600,
+ color: #c69026,
+ ),
+ caution: (
+ border-color: #c93c37,
+ color: #e5534b,
+ ),
+) !default;
diff --git a/assets/css/_partials/_single/_alert.scss b/assets/css/_partials/_single/_alert.scss
index 492d64744..dac8fe4af 100644
--- a/assets/css/_partials/_single/_alert.scss
+++ b/assets/css/_partials/_single/_alert.scss
@@ -26,18 +26,18 @@
}
}
- @each $type, $border-color, $color in $alert-color-map {
+ @each $type, $item in $alert-color-map {
&.alert-#{$type} {
- --#{$prefix}alert-border-color: #{$border-color};
- --#{$prefix}alert-color: #{$color};
+ --#{$prefix}alert-border-color: #{map-get($item, border-color)};
+ --#{$prefix}alert-color: #{map-get($item, color)};
}
}
[data-theme='dark'] & {
- @each $type, $border-color, $color in $alert-color-map-dark {
+ @each $type, $item in $alert-color-map-dark {
&.alert-#{$type} {
- --#{$prefix}alert-border-color: #{$border-color};
- --#{$prefix}alert-color: #{$color};
+ --#{$prefix}alert-border-color: #{map-get($item, border-color)};
+ --#{$prefix}alert-color: #{map-get($item, color)};
}
}
}
diff --git a/assets/css/_shortcodes/_admonition.scss b/assets/css/_shortcodes/_admonition.scss
index 7a6a38d50..d952e1026 100644
--- a/assets/css/_shortcodes/_admonition.scss
+++ b/assets/css/_shortcodes/_admonition.scss
@@ -43,43 +43,35 @@
top: 0.6rem;
right: 0.3rem;
}
+
+ background-color: var(--#{$prefix}admonition-bg-color);
+ border-left-color: var(--#{$prefix}admonition-color);
- @each $type, $color, $background-color in $admonition-color-map {
- @if $type == 'note' {
- background-color: $background-color;
- border-left-color: $color;
+ > .admonition-title {
+ border-bottom-color: var(--#{$prefix}admonition-bg-color);
+ background-color: var(--#{$prefix}admonition-bg-color-collapsed);
- > .admonition-title {
- border-bottom-color: $background-color;
- background-color: opacify($background-color, 0.15);
-
- i.icon {
- color: $color;
- }
- }
-
- &.open > .admonition-title {
- background-color: $background-color;
- }
+ i.icon {
+ color: var(--#{$prefix}admonition-color);
}
-
- @else {
- &.#{$type} {
- background-color: $background-color;
- border-left-color: $color;
+ }
- > .admonition-title {
- border-bottom-color: $background-color;
- background-color: opacify($background-color, 0.15);
+ &.open > .admonition-title {
+ background-color: var(--#{$prefix}admonition-bg-color);
+ }
- i.icon {
- color: $color;
- }
- }
+ // default admonition type is note
+ --#{$prefix}admonition-color: #{map-get(map-get($admonition-color-map, note), color)};
+ --#{$prefix}admonition-bg-color: #{map-get(map-get($admonition-color-map, note), bg-color)};
+ --#{$prefix}admonition-bg-color-collapsed: #{opacify(map-get(map-get($admonition-color-map, note), bg-color), 0.15)};
- &.open > .admonition-title {
- background-color: $background-color;
- }
+ // set color for each admonition type
+ @each $type, $item in $admonition-color-map {
+ @if $type != 'note' {
+ &.#{$type} {
+ --#{$prefix}admonition-color: #{map-get($item, color)};
+ --#{$prefix}admonition-bg-color: #{map-get($item, bg-color)};
+ --#{$prefix}admonition-bg-color-collapsed: #{opacify(map-get($item, bg-color), 0.15)};
}
}
}
diff --git a/hugo.toml b/hugo.toml
index f0557f727..56d6dfba8 100644
--- a/hugo.toml
+++ b/hugo.toml
@@ -135,7 +135,7 @@ enableEmoji = true
[module]
[module.hugoVersion]
extended = true
- min = "0.134.0"
+ min = "0.134.1"
# -------------------------------------------------------------------------------------
# Markup related configuration in Hugo
@@ -679,6 +679,12 @@ enableEmoji = true
# For values, see https://mermaid.js.org/config/theming.html#available-themes
themes = ["default", "dark"]
+ # FixIt 0.3.13 | NEW Admonitions custom config
+ # See https://fixit.lruihao.cn/documentation/content-management/shortcodes/extended/admonition/#custom-admonitions
+ # syntax:
=
+ [params.admonition]
+ # ban = "fa-solid fa-ban"
+
# FixIt 0.2.12 | NEW PanguJS config
[params.pangu]
# For Chinese writing
diff --git a/layouts/partials/plugin/admonition.html b/layouts/partials/plugin/admonition.html
index 1b9d5bc10..5e4024dc8 100644
--- a/layouts/partials/plugin/admonition.html
+++ b/layouts/partials/plugin/admonition.html
@@ -6,7 +6,7 @@
* @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)
+ * For custom admonitions, see https://fixit.lruihao.cn/documentation/content-management/shortcodes/extended/admonition/#customize-admonitions
*/ -}}
{{- $iconMap := dict
@@ -24,6 +24,8 @@
"example" "fa-solid fa-list-ul"
"quote" "fa-solid fa-quote-right"
-}}
+{{- /* Custom admonitions */ -}}
+{{- $iconMap = site.Params.admonition | merge $iconMap -}}
{{- $aliasMap := dict
"summary" "abstract"
"tldr" "abstract"
diff --git a/theme.toml b/theme.toml
index 620fb6c9e..be4424bfd 100644
--- a/theme.toml
+++ b/theme.toml
@@ -7,7 +7,7 @@ licenselink = "https://github.com/hugo-fixit/FixIt/blob/master/LICENSE"
description = "A Clean, Elegant but Advanced Hugo Theme for Hugo."
homepage = "https://github.com/hugo-fixit/FixIt"
demosite = "https://fixit.lruihao.cn"
-min_version = "0.134.0"
+min_version = "0.134.1"
tags = [
"blog",