feat(admonition): allow full customization

This commit is contained in:
ZhenShuo Leo
2025-12-31 15:41:13 +08:00
parent bf0713c0cf
commit 3c534548df
4 changed files with 69 additions and 32 deletions

View File

@@ -1,36 +1,33 @@
{{- if eq .Type "alert" -}}
{{- $typeMap := dict
"attention" "warning"
"check" "success"
"cite" "quote"
"done" "success"
"error" "danger"
"fail" "failure"
"faq" "question"
"hint" "tip"
"help" "question"
"missing" "failure"
"summary" "abstract"
"tldr" "abstract"
-}}
{{- /* To customize your own admonitions, you can do the following:
{{- $iconMap := dict
"abstract" "file-lines"
"bug" "bug"
"caution" "fire"
"danger" "fire"
"example" "list-ol"
"failure" "xmark"
"important" "star"
"info" "circle-info"
"note" "circle-info"
"success" "check"
"todo" "list-check"
"tip" "lightbulb"
"question" "circle-question"
"quote" "quote-left"
"warning" "triangle-exclamation"
-}}
1. Change colors
Define your colors in `assets/css/custom.css` using the variables from:
https://github.com/nunocoracao/blowfish/blob/main/assets/css/components/admonition.css
Example:
```
:root {
--adm-note-bg: red;
}
html.dark {
--adm-note-bg: green;
}
```
This will update the background color for light and dark mode.
2. Change icons and type settings
You can override the default type and icon mappings by creating your own
`impls/hooks/admonition-maps.html` in your `layouts` folder.
This allows you to assign different icons or styles for each admonition type.
*/ -}}
{{- if eq .Type "alert" -}}
{{- $maps := partialCached "impls/hooks/admonition-maps.html" . -}}
{{- $typeMap := $maps.typeMap -}}
{{- $iconMap := $maps.iconMap -}}
{{- $rawType := .AlertType | lower -}}
{{- $normalizedType := index $typeMap $rawType | default $rawType -}}

View File

@@ -0,0 +1,34 @@
{{- /* Override this file in your site to customize admonition type aliases and icon mappings */ -}}
{{- return dict
"typeMap" (dict
"attention" "warning"
"check" "success"
"cite" "quote"
"done" "success"
"error" "danger"
"fail" "failure"
"faq" "question"
"hint" "tip"
"help" "question"
"missing" "failure"
"summary" "abstract"
"tldr" "abstract"
)
"iconMap" (dict
"abstract" "file-lines"
"bug" "bug"
"caution" "fire"
"danger" "fire"
"example" "list-ol"
"failure" "xmark"
"important" "star"
"info" "circle-info"
"note" "circle-info"
"success" "check"
"todo" "list-check"
"tip" "lightbulb"
"question" "circle-question"
"quote" "quote-left"
"warning" "triangle-exclamation"
)
-}}