Show tour photos in schedule cards
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
f53721555f
commit
0e86c57987
5 changed files with 70 additions and 14 deletions
|
|
@ -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.
|
- `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" }`.
|
- `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.
|
- `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.
|
For the events managed with Hackertours-Admin, the data file is generated by its website sync; don't edit it by hand.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,29 @@
|
||||||
gap: 0 0.5rem;
|
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 {
|
.schedule__status {
|
||||||
font-family: var(--ff-alt);
|
font-family: var(--ff-alt);
|
||||||
font-size: var(--fs-xs);
|
font-size: var(--fs-xs);
|
||||||
|
|
|
||||||
19
themes/hackertours/layouts/_partials/first-page-image.html
Normal file
19
themes/hackertours/layouts/_partials/first-page-image.html
Normal file
|
|
@ -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 -}}
|
||||||
|
|
@ -6,24 +6,15 @@ gallery-image shortcode, scaled down to at most 1200 pixels wide, with its alt t
|
||||||
og:image:alt.
|
og:image:alt.
|
||||||
*/ -}}
|
*/ -}}
|
||||||
{{- if not ($.Param "image") -}}
|
{{- if not ($.Param "image") -}}
|
||||||
{{- /* Whichever comes first: a Markdown image or a gallery-image shortcode (src and alt in "…" or `…`). */ -}}
|
{{- with partialCached "first-page-image.html" . .RelPermalink -}}
|
||||||
{{- with findRESubmatch `!\[([^\]]*)\]\(\s*<?([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}}
|
{{- $alt := .alt -}}
|
||||||
{{- $alt := index . 0 1 -}}
|
{{- $dest := .dest -}}
|
||||||
{{- $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 -}}
|
|
||||||
{{- $url := "" -}}
|
{{- $url := "" -}}
|
||||||
{{- $width := 0 -}}
|
{{- $width := 0 -}}
|
||||||
{{- $height := 0 -}}
|
{{- $height := 0 -}}
|
||||||
{{- $resource := false -}}
|
{{- $resource := .resource -}}
|
||||||
{{- if findRE `^https?://` $dest -}}
|
{{- if findRE `^https?://` $dest -}}
|
||||||
{{- $url = $dest -}}
|
{{- $url = $dest -}}
|
||||||
{{- else -}}
|
|
||||||
{{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}}
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- with $resource -}}
|
{{- with $resource -}}
|
||||||
{{- $image := . -}}
|
{{- $image := . -}}
|
||||||
|
|
|
||||||
|
|
@ -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. */}}
|
{{- /* A tour's own title, in the page's language, replaces its page's title. */}}
|
||||||
{{- $ownTitle := "" }}
|
{{- $ownTitle := "" }}
|
||||||
{{- with .title }}{{ $ownTitle = index . site.Language.Name | default (index . "en") }}{{ end }}
|
{{- with .title }}{{ $ownTitle = index . site.Language.Name | default (index . "en") }}{{ end }}
|
||||||
<li class="schedule__card{{ if $soldOut }} schedule__card--soldout{{ end }}" style="--schedule-row: {{ add (index $slotRow .time) $nth }}">
|
{{- $photo := false }}
|
||||||
|
{{- $photoAlt := "" }}
|
||||||
|
{{- $photoCredit := "" }}
|
||||||
|
{{- with $page }}
|
||||||
|
{{- with partialCached "first-page-image.html" . .RelPermalink }}
|
||||||
|
{{- if and .resource .alt }}
|
||||||
|
{{- if and (eq .resource.ResourceType "image") (ne .resource.MediaType.SubType "svg") }}
|
||||||
|
{{- $oriented := .resource.Filter images.AutoOrient }}
|
||||||
|
{{- $side := math.Min 240 $oriented.Width $oriented.Height | int }}
|
||||||
|
{{- $photo = $oriented.Fill (printf "%dx%d Smart" $side $side) }}
|
||||||
|
{{- $photoAlt = .alt }}
|
||||||
|
{{- $photoCredit = .credit }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
<li class="schedule__card{{ if $soldOut }} schedule__card--soldout{{ end }}{{ if $photo }} schedule__card--photo{{ end }}" style="--schedule-row: {{ add (index $slotRow .time) $nth }}">
|
||||||
<span class="schedule__when">
|
<span class="schedule__when">
|
||||||
<time class="schedule__time" datetime="{{ $day.date }}T{{ .time }}">{{ .time }}</time>
|
<time class="schedule__time" datetime="{{ $day.date }}T{{ .time }}">{{ .time }}</time>
|
||||||
{{- if $soldOut }}
|
{{- if $soldOut }}
|
||||||
|
|
@ -97,6 +113,12 @@ so an hour without tours still gets a row.
|
||||||
{{- else }}
|
{{- else }}
|
||||||
<span class="schedule__title">{{ $ownTitle | default $entry.tour }}</span>
|
<span class="schedule__title">{{ $ownTitle | default $entry.tour }}</span>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- with $photo }}
|
||||||
|
<figure class="schedule__photo">
|
||||||
|
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="{{ $photoAlt }}" loading="lazy" decoding="async">
|
||||||
|
{{- with $photoCredit }}<figcaption>{{ . }}</figcaption>{{ end }}
|
||||||
|
</figure>
|
||||||
|
{{- end }}
|
||||||
</li>
|
</li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
</ol>
|
</ol>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue