-
Notifications
You must be signed in to change notification settings - Fork 907
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shortcode 'card': Use Hugo's native support for processing HTML & mar…
…kdown (#906)
- Loading branch information
Showing
4 changed files
with
86 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
{{ warnf `shortcode 'card-code' is deprecated: use shortcode 'card' with named parameter 'code=true' instead.` -}} | ||
{{ $lang := default "" ($.Get "lang") -}} | ||
{{ $highlight := default "" ($.Get "highlight") -}} | ||
|
||
<div class="td-card card border me-4"> | ||
{{ $lang := "" }} | ||
{{ with $.Get "lang" }} | ||
{{ $lang = $.Get "lang" }} | ||
{{ end }} | ||
{{ $highlight := "" }} | ||
{{ with $.Get "highlight" }} | ||
{{ $highlight = $.Get "highlight" }} | ||
{{ end }} | ||
{{- with $.Get "header" -}} | ||
{{ with $.Get "header" -}} | ||
<div class="card-header bg-white"> | ||
{{- $.Get "header" | markdownify -}} | ||
{{ . | markdownify -}} | ||
</div> | ||
{{end}} | ||
{{ end -}} | ||
<div class="card-body code p-0 m-0"> | ||
{{ with $.Inner }} | ||
{{- highlight $.Inner $lang $highlight -}} | ||
{{ end }} | ||
{{ with $.Inner -}} | ||
{{ highlight . $lang $highlight -}} | ||
{{ end -}} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,47 @@ | ||
{{/* Check parameter type */ -}} | ||
{{ $code := false -}} | ||
{{ with .Get "code" -}} | ||
{{ $type := printf "%T" . -}} | ||
{{ if ne $type "bool" -}} | ||
{{ errorf `shortcode 'card': boolean value expected for parameter 'code', but got %s` $type -}} | ||
{{ else }} | ||
{{ $code = . -}} | ||
{{ end -}} | ||
{{ end -}} | ||
|
||
{{ $lang := default "" (.Get "lang") -}} | ||
{{ $highlight := default "" (.Get "highlight") -}} | ||
|
||
<div class="td-card card border me-4"> | ||
{{ with $.Get "header" }} | ||
<div class="card-header"> | ||
{{ if eq $.Page.File.Ext "md" }} | ||
{{ $.Get "header" | markdownify }} | ||
{{ else }} | ||
{{ $.Get "header" | htmlUnescape | safeHTML }} | ||
{{ end }} | ||
{{ with $.Get "header" -}} | ||
<div class="card-header{{- cond $code " bg-white" "" -}}"> | ||
{{ . | markdownify }} | ||
</div> | ||
{{ end }} | ||
<div class="card-body"> | ||
{{ with $.Get "title" }} | ||
{{ end -}} | ||
<div class="card-body{{- cond $code " code p-0 m-0" "" -}}"> | ||
{{ with $.Get "title" -}} | ||
<h5 class="card-title"> | ||
{{ if eq $.Page.File.Ext "md" }} | ||
{{ $.Get "title" | markdownify }} | ||
{{ else }} | ||
{{ $.Get "title" | htmlUnescape | safeHTML }} | ||
{{ end }} | ||
{{ . | markdownify -}} | ||
</h5> | ||
{{ end }} | ||
{{ with $.Get "subtitle" }} | ||
{{ end -}} | ||
{{ with $.Get "subtitle" -}} | ||
<h6 class="card-title ms-2 text-muted"> | ||
{{ if eq $.Page.File.Ext "md" }} | ||
{{ $.Get "subtitle" | markdownify }} | ||
{{ else }} | ||
{{ $.Get "subtitle" | htmlUnescape | safeHTML }} | ||
{{ end }} | ||
{{ . | markdownify -}} | ||
</h6> | ||
{{ end }} | ||
{{ with $.Inner }} | ||
{{ end -}} | ||
{{ with $.Inner -}} | ||
{{ if $code -}} | ||
{{ highlight . $lang $highlight -}} | ||
{{ else -}} | ||
<p class="card-text"> | ||
{{ if eq $.Page.File.Ext "md" }} | ||
{{ $.Inner | markdownify }} | ||
{{ else }} | ||
{{ $.Inner | htmlUnescape | safeHTML }} | ||
{{ end }} | ||
{{ . -}} | ||
</p> | ||
{{ end }} | ||
{{ end -}} | ||
{{ end -}} | ||
</div> | ||
{{ with $.Get "footer" }} | ||
{{ with $.Get "footer" -}} | ||
<div class="card-footer"> | ||
{{ if eq $.Page.File.Ext "md" }} | ||
{{ $.Get "footer" | markdownify }} | ||
{{ else }} | ||
{{ $.Get "footer" | htmlUnescape | safeHTML }} | ||
{{ end }} | ||
{{ . | markdownify -}} | ||
</div> | ||
{{ end }} | ||
{{ end -}} | ||
</div> |
Oops, something went wrong.