Use same gallery previews as current website
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2023-04-01 16:36:54 +02:00
parent e7fda468b7
commit ec8a75e1e1
4 changed files with 22 additions and 22 deletions

View File

@ -85,18 +85,20 @@ def download_gallery(path):
md = MarkdownConverter() md = MarkdownConverter()
content = '\n\n'.join(md.convert_soup(p) for p in soup.select('.field-type-text-with-summary > .field-items > .field-item > p')) content = '\n\n'.join(md.convert_soup(p) for p in soup.select('.field-type-text-with-summary > .field-items > .field-item > p'))
picture = soup.find(class_='picture')
preview = search('https?://kontakt-bamberg.de[-./\w]+', picture.get('style'))
index = target / 'index.md' index = target / 'index.md'
index.write_text(f'''--- index.write_text(f'''---
slug: "{slug}" slug: "{slug}"
title: {dump(title, Dumper=CDumper).rstrip()} title: {dump(title, Dumper=CDumper).rstrip()}
date: {date} date: {date}
preview: "{unquote(preview[0].rsplit('/', 1)[-1])}"
--- ---
{content} {content}
''') ''')
picture = soup.find(class_='picture')
preview = search('https?://kontakt-bamberg.de[-./\w]+', picture.get('style'))
download_image(preview[0], target) download_image(preview[0], target)
for a in soup.select('.field-name-field-pictures > .field-items > .field-item > a'): for a in soup.select('.field-name-field-pictures > .field-items > .field-item > a'):

View File

@ -1,14 +1,5 @@
{{ define "main" }} {{ define "main" }}
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
{{ .Content }} {{ .Content }}
<section class="gallery"> {{ partial "gallery/gallery.html" .Pages }}
{{ range .Pages }}
<a class="blur-on-hover" href="{{ .RelPermalink }}">
{{ with index (.Resources.ByType "image") 0 }}
<img alt="{{ .Title }}" src="{{ (.Fill "560x560").RelPermalink }}">
{{ end }}
<p>{{ .Title }}</p>
</a>
{{ end }}
</section>
{{ end }} {{ end }}

View File

@ -27,14 +27,5 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
<h1 id="galerie">Galerie</h1> <h1 id="galerie">Galerie</h1>
<section class="gallery"> {{ partial "gallery/gallery.html" (first 4 (.Site.GetPage "/galerie").Pages) }}
{{ range first 4 (.Site.GetPage "/galerie").Pages }}
<a class="blur-on-hover" href="{{ .RelPermalink }}">
{{ with index (.Resources.ByType "image") 0 }}
<img alt="{{ .Title }}" src="{{ (.Fill "560x560").RelPermalink }}">
{{ end }}
<p>{{ .Title }}</p>
</a>
{{ end }}
</section>
{{ end }} {{ end }}

View File

@ -0,0 +1,16 @@
<section class="gallery">
{{ range . }}
<a class="blur-on-hover" href="{{ .RelPermalink }}">
{{ $page := . }}
{{ with .Params.preview }}
{{ $image := $page.Resources.GetMatch . }}
<img alt="{{ $image.Title }}" src="{{ ($image.Fill "560x560").RelPermalink }}">
{{ else }}
{{ with index (.Resources.ByType "image") 0 }}
<img alt="{{ .Title }}" src="{{ (.Fill "560x560").RelPermalink }}">
{{ end }}
{{ end }}
<p>{{ .Title }}</p>
</a>
{{ end }}
</section>