From 417c38cfd15c465081ea6efe344b7d02faeb0e4b Mon Sep 17 00:00:00 2001 From: Ben Goldsworthy Date: Wed, 14 May 2025 18:44:50 +0200 Subject: [PATCH] refactor: rename `schemaType` to `itemtype`, fix caching titles --- assets/css/components/_item-tile.scss | 3 ++- content/styleguide/index.md | 5 +++-- layouts/locations/list.html | 2 +- layouts/partials/cite.html | 10 +++++----- layouts/partials/images/get-image.html | 2 +- layouts/partials/single/main-header/item-tile.html | 9 +++++++-- layouts/partials/util/render_recursive_list.html | 10 +++++----- layouts/shortcodes/blockquote.html | 4 ++-- layouts/shortcodes/cite.html | 2 +- 9 files changed, 27 insertions(+), 20 deletions(-) diff --git a/assets/css/components/_item-tile.scss b/assets/css/components/_item-tile.scss index 173f430..adfd197 100644 --- a/assets/css/components/_item-tile.scss +++ b/assets/css/components/_item-tile.scss @@ -80,8 +80,9 @@ border-end-start-radius: 10px; text-align: center; text-decoration: none !important; - line-height: 1.8em; + line-height: 1.2em; background-color: #ebebeb; + padding-block: 0.25em; } & hgroup { diff --git a/content/styleguide/index.md b/content/styleguide/index.md index 58dfaf3..b570d3e 100644 --- a/content/styleguide/index.md +++ b/content/styleguide/index.md @@ -7,8 +7,9 @@ resources: - name: lena src: images/lena.* params: - alt: Woman smiling - attr: + alt: Well-known Standard Test Image "Lenna" + attr: Playboy + attrlink: https://en.wikipedia.org/wiki/File:Lenna_(test_image).png --- ## HTML diff --git a/layouts/locations/list.html b/layouts/locations/list.html index fc5d1ec..6bc16c9 100644 --- a/layouts/locations/list.html +++ b/layouts/locations/list.html @@ -44,7 +44,7 @@ style="width: 100%; height: 500px; margin: 0; display: block;" > - {{- with ( partial "util/render_recursive_list.html" ( dict "sc" $ "pc" . "items" $.Site.Data.locations "schemaType" "Place" ) ) -}} + {{- with ( partial "util/render_recursive_list.html" ( dict "sc" $ "pc" . "items" $.Site.Data.locations "itemtype" "Place" ) ) -}}
{{- . -}}
diff --git a/layouts/partials/cite.html b/layouts/partials/cite.html index cf39d3e..c53609c 100644 --- a/layouts/partials/cite.html +++ b/layouts/partials/cite.html @@ -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 @@ -{{- 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 -}} @@ -48,7 +48,7 @@ {{- end -}} -{{- $itemType := default "CreativeWork" $schemaType -}} +{{- $itemType := default "CreativeWork" $itemtype -}} {{- if ( or ( in $.Site.Data.itemtypes $itemType ) ( eq .Params.suppress "true" ) ) -}} {{- with .Params.href -}} diff --git a/layouts/partials/images/get-image.html b/layouts/partials/images/get-image.html index 758530b..1ea645a 100644 --- a/layouts/partials/images/get-image.html +++ b/layouts/partials/images/get-image.html @@ -21,5 +21,5 @@ {{- .RelPermalink -}} {{- end -}} {{- else }} - {{- .RelPermalink -}} + {{- .img.RelPermalink -}} {{- end -}} diff --git a/layouts/partials/single/main-header/item-tile.html b/layouts/partials/single/main-header/item-tile.html index b104f80..3c9547f 100644 --- a/layouts/partials/single/main-header/item-tile.html +++ b/layouts/partials/single/main-header/item-tile.html @@ -37,8 +37,13 @@ class="article-header__featured-image" {{ with .pc.Params.featured_image }} {{ with ( $.pc.Resources.GetMatch . ) }} - style="background-image: url({{ partialCached "images/get-image.html" ( dict "img" . ) $.pc }})" + style="background-image: url({{ partial "images/get-image.html" ( dict "img" . ) }})" {{ else }} + {{- if $.pc.Page.Resources -}} + {{- errorf "No Page Resource found for src '%q' (%q).\n\n\tAvailable Page Resources are:\n\t\t%v" . $.pc.Page.File.Path $.pc.Page.Resources -}} + {{- else -}} + {{- warnf "No Page Resource found for src '%q' (%q)." . $.pc.Page.File.Path -}} + {{- end -}} style="background-image: url({{ . }})" {{ end }} {{ end -}} @@ -50,7 +55,7 @@ href="{{ .pc.Permalink }}" > {{- with .pc.File -}} - {{- partialCached "text/item-title.html" ( dict "pc" $.pc "sc" $.sc "class" "article-header" ) .Filename -}} + {{- partial "text/item-title.html" ( dict "pc" $.pc "sc" $.sc "class" "article-header" ) -}} {{- else -}} {{- partial "text/item-title.html" ( dict "pc" $.pc "sc" $.sc "class" "article-header" ) -}} {{- end -}} diff --git a/layouts/partials/util/render_recursive_list.html b/layouts/partials/util/render_recursive_list.html index 8dc2882..cfe2b42 100644 --- a/layouts/partials/util/render_recursive_list.html +++ b/layouts/partials/util/render_recursive_list.html @@ -5,7 +5,7 @@ @params sc Site context @params pc Page context @params items Set of items to render a list from. - @params schemaType Schema.org type to apply. Optional. + @params itemtype Schema.org type to apply. Optional. @params listType "unordered" or "ordered". Default "unordered". --> @@ -19,8 +19,8 @@ {{- warnf "No items passed to list partial (%q)" .pc.File.Path -}} {{- end -}} -{{- if ( and .schemaType ( not ( in .sc.Site.Data.itemtypes .schemaType ) ) ) -}} - {{- erroridf "invalid-schemaType" "Invalid Schema.org type value %q (%q)" .schemaType .pc.File.Path -}} +{{- if ( and .itemtype ( not ( in .sc.Site.Data.itemtypes .itemtype ) ) ) -}} + {{- erroridf "invalid-itemtype" "Invalid Schema.org type value %q (%q)" .itemtype .pc.File.Path -}} {{- end -}} {{- if ( and .listType ( not ( in ( slice "unordered" "ordered" ) .listType ) ) ) -}} @@ -29,7 +29,7 @@ -{{- $schemaType := default "" .schemaType -}} +{{- $itemtype := default "" .itemtype -}} {{- $listType := default "unordered" .listType -}} @@ -45,7 +45,7 @@
  • {{- $k -}} {{- if ( not ( isset $v "lat" ) ) -}} - {{- partial "util/render_recursive_list.html" ( dict "sc" $.sc "pc" $.pc "items" $v "schemaType" $schemaType "listType" $listType ) -}} + {{- partial "util/render_recursive_list.html" ( dict "sc" $.sc "pc" $.pc "items" $v "itemtype" $itemtype "listType" $listType ) -}} {{- end -}}
  • {{- end -}} diff --git a/layouts/shortcodes/blockquote.html b/layouts/shortcodes/blockquote.html index 77db8e2..b13aa36 100644 --- a/layouts/shortcodes/blockquote.html +++ b/layouts/shortcodes/blockquote.html @@ -11,7 +11,7 @@ @see partials/cite.html for full list of args. 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 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. @@ -86,7 +86,7 @@ {{- .Scratch.Set "title" .Params.titleSeries -}} {{- .Scratch.Set "titleLang" .Params.titleSeriesLang -}} {{- .Scratch.Set "titleTr" .Params.titleSeriesTr -}} - {{- .Scratch.Set "schemaType" .Params.schemaTypeSeries -}} + {{- .Scratch.Set "itemtype" .Params.itemtypeSeries -}} {{- .Scratch.Set "href" .Params.hrefSeries -}} {{- partial "cite.html" . -}} {{- with .Params.numberSeries }}, {{ . | safeHTML -}}{{- end -}} diff --git a/layouts/shortcodes/cite.html b/layouts/shortcodes/cite.html index b489344..73898a6 100644 --- a/layouts/shortcodes/cite.html +++ b/layouts/shortcodes/cite.html @@ -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.