Skip to content

Commit

Permalink
feat: support blockquotes render hooks (#1353)
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud authored Sep 16, 2024
1 parent 84334b6 commit c0b2464
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions assets/css/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ $admonition-color-map: (
"bug": #f50057,
"example": #651fff,
"quote": #9e9e9e,
"important": #8957e5,
"caution": #da3633,
) !default;

// Color map of the admonition background
Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions exampleSite/content/posts/tests/markdown-tests/index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions layouts/_default/_markup/render-blockquote-alert.html
Original file line number Diff line number Diff line change
@@ -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" -}}
3 changes: 3 additions & 0 deletions layouts/_default/_markup/render-blockquote-regular.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<blockquote>
{{ .Text }}
</blockquote>
2 changes: 2 additions & 0 deletions layouts/partials/plugin/admonitionPre.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}


{{/*
Expand Down
3 changes: 1 addition & 2 deletions layouts/shortcodes/admonition.html
Original file line number Diff line number Diff line change
@@ -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" -}}

0 comments on commit c0b2464

Please sign in to comment.