Include all photos as links in the RSS and Atom feeds, instead of just the thumbnail
- Move photo_thumbnail.html to photos/thumbnail.html - Add a photos/list.html partial that returns a list of photos for the current page - Use the template above everywhere we need a list of photos for the page
This commit is contained in:
parent
ab172e1e9e
commit
e263b3cb41
7 changed files with 21 additions and 13 deletions
9
layouts/partials/photos/list.html
Normal file
9
layouts/partials/photos/list.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{{ $thumbnailResourcesNames := slice "thumbnail" "Thumbnail" "thumbnail.jpg" "Thumbnail.jpg" }}
|
||||
{{ with index .Params "thumbnail" }}
|
||||
{{ $thumbnailResourcesNames = $thumbnailResourcesNames | append . }}
|
||||
{{ end }}
|
||||
|
||||
{{ $imageResources := .Resources.ByType "image" }}
|
||||
{{ $photos := where $imageResources "Name" "not in" $thumbnailResourcesNames }}
|
||||
|
||||
{{ return $photos }}
|
|
@ -1,11 +1,10 @@
|
|||
{{- $thumbnail := partial "images/photo_thumbnail.html" . -}}
|
||||
{{- $thumbnail := partial "photos/thumbnail.html" . -}}
|
||||
<entry>
|
||||
{{ partial "atom_entry_metadata.xml" . }}
|
||||
<link rel="enclosure" href="{{ $thumbnail.Permalink }}" type="{{ $thumbnail.MediaType }}" length="{{ len $thumbnail.Content }}" />
|
||||
{{- $inlineThumbnail := partial "images/photo_thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) -}}
|
||||
<content type="html">{{ `<![CDATA[` | safeHTML }}
|
||||
{{- with $inlineThumbnail -}}
|
||||
<img src="{{ .Permalink }}">
|
||||
{{- range partial "photos/list.html" . -}}
|
||||
<img src="{{ .Permalink }}"{{ with .Params.alt }} alt="{{ . }}"{{ end }}>
|
||||
{{- end -}}
|
||||
{{- .Content -}}
|
||||
]]></content>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{- $thumbnail := partial "images/photo_thumbnail.html" (dict "Page" . "Width" 600 "Height" 600) -}}
|
||||
{{- $thumbnail := partial "photos/thumbnail.html" (dict "Page" . "Width" 600 "Height" 600) -}}
|
||||
{{- $thumbnail = $thumbnail.Crop "600x600" -}}
|
||||
{{- $altText := $thumbnail.Params.alt -}}
|
||||
<a href="{{ .RelPermalink }}" title="{{ .Title }}">
|
||||
<img src="{{ $thumbnail.RelPermalink }}" {{ with $altText }}alt="{{ . }}"{{ end }}>
|
||||
<img src="{{ $thumbnail.RelPermalink }}"{{ with $altText }} alt="{{ . }}"{{ end }}>
|
||||
</a>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
{{- $thumbnail := partial "images/photo_thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) -}}
|
||||
{{- $thumbnail := partial "photos/thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) -}}
|
||||
<item>
|
||||
{{ partial "rss_item_metadata.rss" . }}
|
||||
<description>{{ `<![CDATA[` | safeHTML }}
|
||||
<img src="{{ $thumbnail.Permalink }}">
|
||||
{{ .Content }}
|
||||
{{- range (partial "photos/list.html" .) -}}
|
||||
<img src="{{ .Permalink }}"{{ with .Params.alt }} alt="{{ . }}"{{ end }}>
|
||||
{{- end -}}
|
||||
{{- .Content -}}
|
||||
]]></description>
|
||||
</item>
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
{{ end }}
|
||||
|
||||
{{ define "main" }}
|
||||
{{- $photos := where (.Resources.ByType "image")
|
||||
"Name" "not in" (slice "thumbnail" "Thumbnail" "thumbnail.jpg" "Thumbnail.jpg") -}}
|
||||
|
||||
{{- if .Title -}}
|
||||
{{ partial "content_header.html" . }}
|
||||
{{- end -}}
|
||||
|
||||
{{- $photos := partial "photos/list.html" . -}}
|
||||
{{ if eq (len $photos) 0 }}
|
||||
{{ errorf "Missing photo from photos page %q" .Path }}
|
||||
{{ end }}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{- with $photoPage := $.Page.GetPage (printf "photos/%s" (.Get 0)) -}}
|
||||
{{- $thumbnail := partial "images/photo_thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) -}}
|
||||
{{- $thumbnail := partial "photos/thumbnail.html" (dict "Page" . "Width" 1280 "Height" 1280) -}}
|
||||
{{- $altText := $thumbnail.Params.alt | default .Title -}}
|
||||
<a href="{{ .RelPermalink }}" title="{{ .Title }}">
|
||||
<img src="{{ $thumbnail.RelPermalink }}"{{ with $altText }} alt="{{ . }}"{{ end }}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue