From c0b2464f654a083d2a9fe260d82d053fdafbeebb Mon Sep 17 00:00:00 2001 From: PCloud Date: Mon, 16 Sep 2024 20:35:44 +0100 Subject: [PATCH] feat: support blockquotes render hooks (#1353) --- assets/css/_variables.scss | 4 ++++ .../posts/tests/markdown-tests/index.en.md | 15 +++++++++++++++ .../_default/_markup/render-blockquote-alert.html | 3 +++ .../_markup/render-blockquote-regular.html | 3 +++ layouts/partials/plugin/admonitionPre.html | 2 ++ layouts/shortcodes/admonition.html | 3 +-- 6 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 layouts/_default/_markup/render-blockquote-alert.html create mode 100644 layouts/_default/_markup/render-blockquote-regular.html diff --git a/assets/css/_variables.scss b/assets/css/_variables.scss index 69227c6d8..0bdf860d1 100644 --- a/assets/css/_variables.scss +++ b/assets/css/_variables.scss @@ -201,6 +201,8 @@ $admonition-color-map: ( "bug": #f50057, "example": #651fff, "quote": #9e9e9e, + "important": #8957e5, + "caution": #da3633, ) !default; // Color map of the admonition background @@ -217,6 +219,8 @@ $admonition-background-color-map: ( "bug": rgba(245, 0, 87, 0.1), "example": rgba(101, 31, 255, 0.1), "quote": rgba(159, 159, 159, 0.1), + "important": rgba(137, 87, 229, 0.1), + "caution": rgba(218, 54, 51, 0.1), ) !default; // ========== Friend Link ========== // // Color of friend link background diff --git a/exampleSite/content/posts/tests/markdown-tests/index.en.md b/exampleSite/content/posts/tests/markdown-tests/index.en.md index 07df129d5..987f6eba2 100644 --- a/exampleSite/content/posts/tests/markdown-tests/index.en.md +++ b/exampleSite/content/posts/tests/markdown-tests/index.en.md @@ -85,6 +85,21 @@ Nunc augue augue, aliquam non hendrerit ac, commodo vel nisi. >> Sed adipiscing elit vitae augue consectetur a gravida nunc vehicula. Donec auctor odio non est accumsan facilisis. Aliquam id turpis in dolor tincidunt mollis ac eu diam. +> [!NOTE] +> Useful information that users should know, even when skimming content. + +> [!TIP] +> Helpful advice for doing things better or more easily. + +> [!IMPORTANT] +> Key information users need to know to achieve their goal. + +> [!WARNING] +> Urgent info that needs immediate user attention to avoid problems. + +> [!CAUTION] +> Advises about risks or negative outcomes of certain actions. + ## Lists diff --git a/layouts/_default/_markup/render-blockquote-alert.html b/layouts/_default/_markup/render-blockquote-alert.html new file mode 100644 index 000000000..a720bc797 --- /dev/null +++ b/layouts/_default/_markup/render-blockquote-alert.html @@ -0,0 +1,3 @@ +{{- partial "plugin/admonitionPre.html" (dict "Type" .AlertType "Title" (.AlertTitle | default (strings.FirstUpper .AlertType)) "Open" (not (eq .AlertSign "-"))) -}} +{{- .Text -}} +{{- partial "plugin/admonitionPost.html" -}} \ No newline at end of file diff --git a/layouts/_default/_markup/render-blockquote-regular.html b/layouts/_default/_markup/render-blockquote-regular.html new file mode 100644 index 000000000..7fc13068f --- /dev/null +++ b/layouts/_default/_markup/render-blockquote-regular.html @@ -0,0 +1,3 @@ +
+ {{ .Text }} +
\ No newline at end of file diff --git a/layouts/partials/plugin/admonitionPre.html b/layouts/partials/plugin/admonitionPre.html index 26daa58f5..adc742da9 100644 --- a/layouts/partials/plugin/admonitionPre.html +++ b/layouts/partials/plugin/admonitionPre.html @@ -10,6 +10,8 @@ {{- $iconMap = dict "bug" (dict "Style" "solid" "Icon" "bug") | merge $iconMap -}} {{- $iconMap = dict "example" (dict "Style" "solid" "Icon" "list-ol") | merge $iconMap -}} {{- $iconMap = dict "quote" (dict "Style" "solid" "Icon" "quote-right") | merge $iconMap -}} +{{- $iconMap = dict "important" (dict "Style" "solid" "Icon" "exclamation") | merge $iconMap -}} +{{- $iconMap = dict "caution" (dict "Style" "solid" "Icon" "exclamation-circle") | merge $iconMap -}} {{/* diff --git a/layouts/shortcodes/admonition.html b/layouts/shortcodes/admonition.html index 03cdaee2d..e21f765f0 100644 --- a/layouts/shortcodes/admonition.html +++ b/layouts/shortcodes/admonition.html @@ -1,7 +1,6 @@ -{{- $inner := .Inner | .Page.RenderString -}} {{- $type := cond .IsNamedParams (.Get "type") (.Get 0) | default "note" -}} {{- $title := cond .IsNamedParams (.Get "title") (.Get 1) | default (T $type) -}} {{- $open := cond .IsNamedParams (.Get "open") (.Get 2) -}} {{- partial "plugin/admonitionPre.html" (dict "Type" $type "Title" $title "Open" $open) -}} -{{- $inner -}} +{{- .Inner | .Page.RenderString -}} {{- partial "plugin/admonitionPost.html" -}} \ No newline at end of file