diff --git a/README.md b/README.md index 5ec6083..9fbafe9 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ days: - `time` is `HH:MM` with a leading zero (`09:30`). Tours are sorted by time, so their order in the file doesn't matter. - `title` (optional) replaces the page's title on the card, with one entry per language: `title: { de: "Hafen am Abend", en: "Harbour by Night" }`. - `status` (optional): `soldout` marks the tour as fully booked. Other values are ignored. +- The first local photo in the tour page is shown on its card when it has alt text; its gallery credit is displayed below it. For the events managed with Hackertours-Admin, the data file is generated by its website sync; don't edit it by hand. diff --git a/themes/hackertours/assets/css/_schedule.css b/themes/hackertours/assets/css/_schedule.css index d752402..ae64c53 100644 --- a/themes/hackertours/assets/css/_schedule.css +++ b/themes/hackertours/assets/css/_schedule.css @@ -133,6 +133,29 @@ gap: 0 0.5rem; } +.schedule__card--photo { + grid-template-columns: minmax(0, 1fr) auto minmax(0, 6rem); + + .schedule__title { + grid-column: 1 / 3; + } +} + +.schedule__photo { + grid-column: 3; + grid-row: 1 / 3; + margin: 0; + font-size: var(--fs-xs); + color: var(--color-text-meta); + overflow-wrap: anywhere; + + img { + display: block; + width: 100%; + height: auto; + } +} + .schedule__status { font-family: var(--ff-alt); font-size: var(--fs-xs); diff --git a/themes/hackertours/layouts/_partials/first-page-image.html b/themes/hackertours/layouts/_partials/first-page-image.html new file mode 100644 index 0000000..5225aa8 --- /dev/null +++ b/themes/hackertours/layouts/_partials/first-page-image.html @@ -0,0 +1,19 @@ +{{- $result := dict -}} +{{- with findRESubmatch `!\[([^\]]*)\]\(\s*([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}} + {{- $alt := index . 0 1 -}} + {{- $dest := index . 0 2 -}} + {{- $credit := "" -}} + {{- with index . 0 3 -}} + {{- $dest = "" -}} + {{- $alt = "" -}} + {{- with findRESubmatch "\\bsrc=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $dest = or (index . 0 1) (index . 0 2) }}{{ end -}} + {{- with findRESubmatch "\\balt=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $alt = or (index . 0 1) (index . 0 2) }}{{ end -}} + {{- with findRESubmatch "\\bcredit=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $credit = or (index . 0 1) (index . 0 2) }}{{ end -}} + {{- end -}} + {{- $resource := false -}} + {{- if not (findRE `^https?://` $dest) -}} + {{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}} + {{- end -}} + {{- $result = dict "alt" $alt "credit" $credit "dest" $dest "resource" $resource -}} +{{- end -}} +{{- return $result -}} diff --git a/themes/hackertours/layouts/_partials/head/extra.html b/themes/hackertours/layouts/_partials/head/extra.html index 74fd6b7..6bedff0 100644 --- a/themes/hackertours/layouts/_partials/head/extra.html +++ b/themes/hackertours/layouts/_partials/head/extra.html @@ -6,24 +6,15 @@ gallery-image shortcode, scaled down to at most 1200 pixels wide, with its alt t og:image:alt. */ -}} {{- if not ($.Param "image") -}} - {{- /* Whichever comes first: a Markdown image or a gallery-image shortcode (src and alt in "…" or `…`). */ -}} - {{- with findRESubmatch `!\[([^\]]*)\]\(\s*([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}} - {{- $alt := index . 0 1 -}} - {{- $dest := index . 0 2 -}} - {{- with index . 0 3 -}} - {{- $dest = "" -}} - {{- $alt = "" -}} - {{- with findRESubmatch "\\bsrc=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $dest = or (index . 0 1) (index . 0 2) }}{{ end -}} - {{- with findRESubmatch "\\balt=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $alt = or (index . 0 1) (index . 0 2) }}{{ end -}} - {{- end -}} + {{- with partialCached "first-page-image.html" . .RelPermalink -}} + {{- $alt := .alt -}} + {{- $dest := .dest -}} {{- $url := "" -}} {{- $width := 0 -}} {{- $height := 0 -}} - {{- $resource := false -}} + {{- $resource := .resource -}} {{- if findRE `^https?://` $dest -}} {{- $url = $dest -}} - {{- else -}} - {{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}} {{- end -}} {{- with $resource -}} {{- $image := . -}} diff --git a/themes/hackertours/layouts/_shortcodes/schedule.html b/themes/hackertours/layouts/_shortcodes/schedule.html index fb933b5..09200c1 100644 --- a/themes/hackertours/layouts/_shortcodes/schedule.html +++ b/themes/hackertours/layouts/_shortcodes/schedule.html @@ -81,7 +81,23 @@ so an hour without tours still gets a row. {{- /* A tour's own title, in the page's language, replaces its page's title. */}} {{- $ownTitle := "" }} {{- with .title }}{{ $ownTitle = index . site.Language.Name | default (index . "en") }}{{ end }} -