Skip to content

Commit

Permalink
feat: add blockquotes parameters (#237)
Browse files Browse the repository at this point in the history
feat: add blockquote render hook
  • Loading branch information
razonyang authored Sep 5, 2024
1 parent 6823fbb commit 5e67dcb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ striped = true
striped_columns = false
style = "" # light, dark, primary, success, warning, danger and so on.
thead_style = "" # similar to the style.

[params.hb.blockquotes]
bordered = true
border_width = 4 # 1-5.
border_style = "primary"
31 changes: 31 additions & 0 deletions layouts/_default/_markup/render-blockquote-regular.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- $params := site.Params.hb.blockquotes }}
{{- $borderClass := "" }}
{{- if $params.bordered }}
{{- $borderClass = "border-start ps-3 py-1" }}
{{- with default "primary" $params.border_style }}
{{- $borderClass = printf "%s border-%s" $borderClass . }}
{{- end }}
{{- with default 4 $params.border_width }}
{{- $borderClass = printf "%s border-%d" $borderClass . }}
{{- end }}
{{- end }}
{{- if .Attributes }}
<figure
class="{{ $borderClass }}{{ with .Attributes.align }} text-{{ . }}{{ end }}">
<blockquote class="blockquote mb-0">
{{ .Text }}
</blockquote>
{{- with .Attributes.caption }}
{{- $caption := . | $.Page.RenderString }}
<figcaption class="blockquote-footer mt-1 mb-0">
<cite title="{{ $caption }}">
{{ $caption }}
</cite>
</figcaption>
{{- end }}
</figure>
{{- else }}
<blockquote class="blockquote {{ $borderClass }}">
{{ .Text }}
</blockquote>
{{- end }}

0 comments on commit 5e67dcb

Please sign in to comment.