Skip to content

Commit

Permalink
fix: allow specifying extra class name for blockquotes and tables (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang authored Sep 10, 2024
1 parent c27eea4 commit b1e818d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions layouts/_default/_markup/render-blockquote-regular.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
{{- $borderClass = printf "%s border-%d" $borderClass . }}
{{- end }}
{{- end }}
{{- if .Attributes }}
{{- $class := slice "blockquote" }}
{{- with .Attributes.class }}
{{- $class = $class | append . }}
{{- end }}
{{- if or (isset .Attributes "align") (isset .Attributes "caption") }}
<figure
class="{{ $borderClass }}{{ with .Attributes.align }} text-{{ . }}{{ end }}">
<blockquote class="blockquote mb-0">
<blockquote class="{{ delimit $class ` ` }} mb-0">
{{ .Text }}
</blockquote>
{{- with .Attributes.caption }}
Expand All @@ -25,7 +29,7 @@
{{- end }}
</figure>
{{- else }}
<blockquote class="blockquote {{ $borderClass }}">
<blockquote class="{{ delimit $class ` ` }} {{ $borderClass }}">
{{ .Text }}
</blockquote>
{{- end }}
7 changes: 4 additions & 3 deletions layouts/_default/_markup/render-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
"left" "text-start"
"right" "text-end"
}}
{{- with .Attributes.class }}
{{- $class = printf "%s %s" $class . }}
{{- end }}
<div class="table-responsive">
<table class="{{ $class }}"
{{- range $k, $v := .Attributes }}
{{- if hasPrefix $k "_" }}
{{- if or (hasPrefix $k "_") (eq $k "class") }}
{{- continue }}
{{- else if eq $k "class" }}
{{- $class = printf "%s %s" $class $v }}
{{- else if $v }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
Expand Down

0 comments on commit b1e818d

Please sign in to comment.