refactor templates layout
@see https://gohugo.io/templates/new-templatesystem-overview/
This commit is contained in:
parent
a83f339dc8
commit
230c46411b
102 changed files with 2 additions and 2 deletions
81
layouts/_shortcodes/blockquote.html
Normal file
81
layouts/_shortcodes/blockquote.html
Normal file
|
@ -0,0 +1,81 @@
|
|||
{{- /*
|
||||
Renders a block quotation.
|
||||
|
||||
@params style Force a blockquote style. Optional.
|
||||
@params cite URI for work. Optional.
|
||||
@params source The speaker(s) of the quotation.
|
||||
@params comment A comment to add after the citation. Optional.
|
||||
|
||||
For works cited (optional):
|
||||
@params ibid Whether to use ibidem as the source. Optional.
|
||||
@see partials/cite.html for full list of args.
|
||||
*/
|
||||
-}}
|
||||
|
||||
{{- $valid_styles := slice "" "epigram" "script" -}}
|
||||
|
||||
|
||||
<!-- Variable assignment -->
|
||||
|
||||
{{- $style := default "" ( index .Params "style" ) -}}
|
||||
{{- $cite := default "" ( index .Params "cite" ) -}}
|
||||
{{- $href := default "" ( index .Params "href" ) -}}
|
||||
{{- $ibid := default false ( index .Params "ibid" ) -}}
|
||||
{{- $source := .Params.source -}}
|
||||
{{- $comment := .Params.comment -}}
|
||||
|
||||
{{- $isSourceHidden := default ( not ( or ( isset .Params "source" ) ( isset .Params "ibid" ) ) ) ( index .Params "hideSource" ) -}}
|
||||
|
||||
{{- $hasCitedWork := ( isset .Params "title" ) }}
|
||||
|
||||
|
||||
<!-- Validation -->
|
||||
|
||||
{{- if ( not ( in $valid_styles $style ) ) -}}
|
||||
{{- errorf "Invalid blockquote style (%q) provided" $style -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if ( not ( or ( isset .Params "source" ) ( isset .Params "ibid" ) ) ) -}}
|
||||
{{- erroridf "blockquote-no-params" "No source provided for blockquote" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if ( not ( isset $.Params "cite" ) ) -}}
|
||||
{{- erroridf "missing-cite" "No cite found for blockquote (%q)" .Page.File.Path -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
<!-- Rendering -->
|
||||
|
||||
<figure
|
||||
class="figure--blockquote blockquote {{ with $style }}blockquote--{{- . -}}{{- end -}}"
|
||||
itemscope
|
||||
itemtype="Quotation"
|
||||
role="group"
|
||||
>
|
||||
<blockquote
|
||||
class="blockquote__body"
|
||||
{{- with $cite }}cite="{{ . }}"{{- end -}}
|
||||
>
|
||||
{{- .Inner | .Page.RenderString -}}
|
||||
</blockquote>
|
||||
<figcaption class="blockquote__caption {{ if $isSourceHidden }}blockquote__caption--hidden{{- end -}}">
|
||||
{{- if $ibid -}}
|
||||
<abbr
|
||||
lang="la"
|
||||
title="ibīdem [in the same place]"
|
||||
>Ibid.</abbr
|
||||
>
|
||||
{{- else if $source -}}
|
||||
<span temprop="spokenByCharacter">{{- $source | safeHTML -}}</span>
|
||||
{{- if $hasCitedWork -}}
|
||||
,
|
||||
<span itemprop="isBasedOn"
|
||||
>{{- partial "cite.html" ( dict "sc" $ "pc" . "Params" .Params ) -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
{{- with $comment -}}
|
||||
{{- printf " (%s)" . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
</figcaption>
|
||||
</figure>
|
Loading…
Add table
Add a link
Reference in a new issue