refactor: rename schemaType
to itemtype
, fix caching titles
This commit is contained in:
parent
28033351c7
commit
417c38cfd1
9 changed files with 27 additions and 20 deletions
|
@ -4,7 +4,7 @@
|
|||
@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 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.
|
||||
|
@ -20,7 +20,7 @@
|
|||
{{- $title := trim ( default .Params.title ( .Scratch.Get "title" ) | .Page.RenderString ) "\r\n" -}}
|
||||
{{- $titleLang := default .Params.titleLang ( .Scratch.Get "titleLang" ) -}}
|
||||
{{- $titleTr := default .Params.titleTr ( .Scratch.Get "titleTr" ) -}}
|
||||
{{- $schemaType := default .Params.schemaType ( .Scratch.Get "schemaType" ) -}}
|
||||
{{- $itemtype := default .Params.itemtype ( .Scratch.Get "itemtype" ) -}}
|
||||
|
||||
{{- if ( strings.Contains $cite "#" ) -}}
|
||||
{{- erroridf "cite-with-fragment" "Cite parameter includes fragment identifier, which probably isn't what you want." -}}
|
||||
|
@ -35,8 +35,8 @@
|
|||
|
||||
<!-- TODO: check `.Params.href` is URI or 'asCite' -->
|
||||
|
||||
{{- if ( and $schemaType ( not ( in $.Site.Data.itemtypes $schemaType ) ) ) -}}
|
||||
{{- erroridf "invalid-schemaType" "Invalid Schema.org type value %q for %q" $schemaType $title -}}
|
||||
{{- if ( and $itemtype ( not ( in $.Site.Data.itemtypes $itemtype ) ) ) -}}
|
||||
{{- erroridf "invalid-itemtype" "Invalid Schema.org type value %q for %q" $itemtype $title -}}
|
||||
{{- end -}}
|
||||
|
||||
<!-- TODO: check `.Params.cite` is URI -->
|
||||
|
@ -48,7 +48,7 @@
|
|||
{{- end -}}
|
||||
|
||||
<!-- Rendering -->
|
||||
{{- $itemType := default "CreativeWork" $schemaType -}}
|
||||
{{- $itemType := default "CreativeWork" $itemtype -}}
|
||||
{{- if ( or ( in $.Site.Data.itemtypes $itemType ) ( eq .Params.suppress "true" ) ) -}}
|
||||
{{- with .Params.href -}}
|
||||
<a href="{{- if eq . "asCite" -}}{{- $cite -}}{{- else -}}{{- . -}}{{- end -}}">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue