Omphaloskepsis-2/layouts/shortcodes/blockquote.html

98 lines
3.3 KiB
HTML
Raw Normal View History

2024-07-23 10:08:36 +02:00
{{- /*
2025-02-21 23:18:07 +01:00
Renders a block quotation.
2024-07-23 10:08:36 +02:00
2025-02-21 23:18:07 +01:00
@params style Force a blockquote style. Optional.
@params cite URI for work. Optional.
@params source The speaker(s) of the quotation.
2024-07-23 10:08:36 +02:00
2025-02-21 23:18:07 +01:00
For works cited (optional):
@params ibid Whether to use ibidem as the source. Optional.
@see partials/cite.html for full list of args.
2024-07-23 10:08:36 +02:00
2025-02-21 23:18:07 +01:00
For works cited that form part of a series (optional):
@params schemaTypeSeries The Schema.org `itemtype` value for the work series. Default 'CreativeWork'. Optional.
@params titleSeries Title of the work series to display. Optional.
@params citeSeries URI for work series. Optional.
@params titleSeriesLang Language code of a foreign-language work series' title. Optional.
@params titleSeriesTr English translation of a foreign-language work series' title. Optional.
@params numberSeries The number or code of the quoted work within its series. Optional.
*/
-}}
2024-07-23 10:08:36 +02:00
{{- $valid_styles := slice "" "epigram" "script" -}}
2025-02-21 23:18:07 +01:00
2024-07-23 10:08:36 +02:00
<!-- Variable assignment -->
{{- $style := default "" ( index .Params "style" ) -}}
{{- $cite := default "" ( index .Params "cite" ) -}}
2025-02-21 23:18:07 +01:00
{{- $href := default "" ( index .Params "href" ) -}}
2024-07-23 10:08:36 +02:00
{{- $ibid := default false ( index .Params "ibid" ) -}}
{{- $source := .Params.source -}}
{{- $isSourceHidden := default ( not ( or ( isset .Params "source" ) ( isset .Params "ibid" ) ) ) ( index .Params "hideSource" ) -}}
{{- $hasCitedWork := ( isset .Params "title" ) }}
{{- $hasCitedSeries := ( isset .Params "titleSeries" ) -}}
2025-02-21 23:18:07 +01:00
2024-07-23 10:08:36 +02:00
<!-- 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" -}}
2023-06-30 21:16:59 -06:00
{{- end -}}
2024-07-23 10:08:36 +02:00
{{- if ( not ( isset $.Params "cite" ) ) -}}
2025-02-21 23:18:07 +01:00
{{- erroridf "missing-cite" "No cite found for blockquote (%q)" .Page.File.Path -}}
2024-07-23 10:08:36 +02:00
{{- end -}}
2025-02-21 23:18:07 +01:00
2024-07-23 10:08:36 +02:00
<!-- Rendering -->
2023-06-30 21:16:59 -06:00
<figure
2024-07-23 10:08:36 +02:00
class="figure--blockquote blockquote{{- with $style }} blockquote--{{- . -}}{{- end -}}"
2023-06-30 21:16:59 -06:00
itemscope
itemtype="Quotation"
2025-02-21 23:18:07 +01:00
role="group"
>
2024-07-23 10:08:36 +02:00
<blockquote
2023-06-30 21:16:59 -06:00
class="blockquote__body"
2025-02-21 23:18:07 +01:00
{{- with $cite }}cite="{{ . }}"{{- end -}}
>
2023-08-07 18:23:46 -04:00
{{- .Inner | .Page.RenderString -}}
2023-06-30 21:16:59 -06:00
</blockquote>
2025-02-21 23:18:07 +01:00
<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" . -}}
{{- if $hasCitedSeries }}
(
{{- .Scratch.Set "cite" .Params.citeSeries -}}
{{- .Scratch.Set "title" .Params.titleSeries -}}
{{- .Scratch.Set "titleLang" .Params.titleSeriesLang -}}
{{- .Scratch.Set "titleTr" .Params.titleSeriesTr -}}
{{- .Scratch.Set "schemaType" .Params.schemaTypeSeries -}}
{{- .Scratch.Set "href" .Params.hrefSeries -}}
{{- partial "cite.html" . -}}
{{- with .Params.numberSeries }}, {{ . | safeHTML -}}{{- end -}}
)
{{- end -}}</span
>
{{- end -}}
2023-06-30 21:16:59 -06:00
{{- end -}}
</figcaption>
</figure>