{{- /* Renders a work citation with semantic markup, called using the `cite` shortcode. @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 schemaType 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. */ -}} {{- $cite := default .Params.cite ( .Scratch.Get "cite" ) -}} {{- $title := default .Params.title ( .Scratch.Get "title" ) -}} {{- $titleLang := default .Params.titleLang ( .Scratch.Get "titleLang" ) -}} {{- $titleTr := default .Params.titleTr ( .Scratch.Get "titleTr" ) -}} {{- $schemaType := default .Params.schemaType ( .Scratch.Get "schemaType" ) -}} {{- if ( strings.Contains $cite "#" ) -}} {{- erroridf "cite-with-fragment" "Cite parameter includes fragment identifier, which probably isn't what you want." -}} {{- $cite = delimit ( split $cite "#" ) "" -}} {{- end -}} {{- if ( and ( isset .Params "citeStyle" ) ( not ( in ( slice "inherit" "enquote" "normal" ) .Params.citeStyle ) ) ) -}} {{- erroridf "invalid-citeStyle" "Invalid `citeStyle` value %q for %q" .Params.citeStyle $title -}} {{- end -}} {{- if ( and $schemaType ( not ( in $.Site.Data.itemtypes $schemaType ) ) ) -}} {{- erroridf "invalid-schemaType" "Invalid Schema.org type value %q for %q" $schemaType $title -}} {{- end -}} {{- if ( or $titleLang $titleTr ) -}} {{- if ( not ( and $titleLang $titleTr ) ) -}} {{- erroridf "invalid-foreign-title" "Must have both title translation and language set for foreign language title %q" $title -}} {{- end -}} {{- end -}} {{- $itemType := default "CreativeWork" $schemaType -}} {{- if ( or ( in $.Site.Data.itemtypes $itemType ) ( eq .Params.suppress "true" ) ) -}} {{- with .Params.href -}} {{- end -}} {{- with $cite -}} {{- end -}} {{- if $titleLang -}} {{- end -}} {{- ( default $title .Params.shortTitle ) | markdownify | safeHTML -}} {{- if $titleLang -}} {{- end -}} {{- /**/ -}} {{- with .Params.href -}} {{- end -}} {{- else -}} {{- erroridf "invalid-schema-type" "Invalid Schema.org type value %q for %q" $itemType $title -}} {{- end -}}