refactor: citations
This commit is contained in:
parent
de341f4191
commit
810805f9ab
6 changed files with 76 additions and 54 deletions
|
@ -9,14 +9,6 @@
|
|||
For works cited (optional):
|
||||
@params ibid Whether to use ibidem as the source. Optional.
|
||||
@see partials/cite.html for full list of args.
|
||||
|
||||
For works cited that form part of a series (optional):
|
||||
@params itemtypeSeries 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.
|
||||
*/
|
||||
-}}
|
||||
|
||||
|
@ -35,7 +27,6 @@
|
|||
{{- $isSourceHidden := default ( not ( or ( isset .Params "source" ) ( isset .Params "ibid" ) ) ) ( index .Params "hideSource" ) -}}
|
||||
|
||||
{{- $hasCitedWork := ( isset .Params "title" ) }}
|
||||
{{- $hasCitedSeries := ( isset .Params "titleSeries" ) -}}
|
||||
|
||||
|
||||
<!-- Validation -->
|
||||
|
@ -79,20 +70,8 @@
|
|||
{{- 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 "itemtype" .Params.itemtypeSeries -}}
|
||||
{{- .Scratch.Set "href" .Params.hrefSeries -}}
|
||||
{{- partial "cite.html" . -}}
|
||||
{{- with .Params.numberSeries }}, {{ . | safeHTML -}}{{- end -}}
|
||||
)
|
||||
{{- end -}}</span
|
||||
>
|
||||
>{{- partial "cite.html" ( dict "sc" $ "pc" . "Params" .Params ) -}}
|
||||
</span>
|
||||
{{- end -}}
|
||||
{{- with $comment -}}
|
||||
{{- printf " (%s)" . -}}
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
{{- /*
|
||||
Renders a work citation with semantic markup.
|
||||
Renders a work citation with semantic markup.
|
||||
|
||||
@params cite URI for work. Optional.
|
||||
@params citeStyle Force a citation style. Optional.
|
||||
@params href URI for citation, or 'asCite' to use value of `cite`. Optional.
|
||||
@params itemtype The Schema.org `itemtype` value. Default 'CreativeWork'.
|
||||
@params shortTitle Abbreviated display title. Optional.
|
||||
@params title Title of the work to display.
|
||||
@params titleLang Language code of a foreign-language work's title. Optional.
|
||||
@params titleTr English translation of a foreign-language work's title. Optional.
|
||||
*/
|
||||
-}}
|
||||
|
||||
@params cite URI for work. Optional.
|
||||
@params citeStyle Force a citation style. Optional.
|
||||
@params href URI for citation, or 'asCite' to use value of `cite`. Optional.
|
||||
@params itemtype The Schema.org `itemtype` value. Default 'CreativeWork'.
|
||||
@params shortTitle Abbreviated display title. Optional.
|
||||
@params title Title of the work to display.
|
||||
@params titleLang Language code of a foreign-language work's title. Optional.
|
||||
@params titleTr English translation of a foreign-language work's title. Optional.
|
||||
*/ -}}
|
||||
|
||||
<!-- Validation -->
|
||||
|
||||
{{- if ( not ( isset .Params "title" ) ) -}}
|
||||
{{- errorf "No title found for citation (%q)" .Page.File.Path -}}
|
||||
{{- errorf "No title found for citation (%q)" .Page.File.Path -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if ( not ( isset $.Params "cite" ) ) -}}
|
||||
{{- erroridf "missing-cite" "No cite found for citation '%q' (%q)" .Params.title .Page.File.Path -}}
|
||||
{{- erroridf "missing-cite" "No cite found for citation '%q' (%q)" .Params.title .Page.File.Path -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
<!-- Rendering -->
|
||||
|
||||
{{- $citationId := printf "%s%s" ( cond ( isset .Params "cite" ) .Params.cite .Params.title ) ( default "" .Params.shortTitle ) -}}
|
||||
|
||||
{{- partialCached "cite.html" . $citationId -}}
|
||||
{{- partial "cite.html" ( dict "sc" $ "pc" . "Params" .Params ) -}}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
itemprop="image">
|
||||
<img itemprop="thumbnail"
|
||||
class="u-photo gallery__thumbnail"
|
||||
{{ if ( or ( eq .MediaType.SubType "svg" ) ( eq .MediaType.SubType "gif" ) ) }}
|
||||
{{ if ( in ( slice "avif" "svg" "gif" ) .MediaType.SubType ) }}
|
||||
src="{{ .RelPermalink }}"
|
||||
{{ else }}
|
||||
{{ with .Resize "600x webp" }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue