Create basic scripts to generate JSONs from images

This commit is contained in:
Christian Wolf 2024-10-21 19:03:23 +02:00
parent 2782838276
commit 9d9182e268
7 changed files with 67 additions and 28 deletions

View File

@ -1,5 +1,5 @@
+++ ---
title = '{{ replace .File.ContentBaseName "-" " " | title }}' title: '{{ replace .File.ContentBaseName "-" " " | title }}'
date = {{ .Date }} date: {{ .Date }}
draft = true draft: true
+++ ---

View File

@ -1,23 +0,0 @@
baseURL = 'https://example.org/'
languageCode = 'en-US'
title = 'My New Hugo Site'
[[menus.main]]
name = 'Home'
pageRef = '/'
weight = 10
[[menus.main]]
name = 'Posts'
pageRef = '/posts'
weight = 20
[[menus.main]]
name = 'Tags'
pageRef = '/tags'
weight = 30
[module]
[module.hugoVersion]
extended = false
min = "0.116.0"

28
hugo.yaml Normal file
View File

@ -0,0 +1,28 @@
# baseURL = 'https://example.org/'
# languageCode = 'en-US'
# title = 'My New Hugo Site'
# [[menus.main]]
# name = 'Home'
# pageRef = '/'
# weight = 10
# [[menus.main]]
# name = 'Posts'
# pageRef = '/posts'
# weight = 20
# [[menus.main]]
# name = 'Tags'
# pageRef = '/tags'
# weight = 30
module:
hugoVersion:
extended: false
min: "0.116.0"
outputs:
section:
- html
- json

View File

@ -0,0 +1,3 @@
{
{{- block "main" . }}{{ end -}}
}

4
layouts/albums/list.json Normal file
View File

@ -0,0 +1,4 @@
{
"images": [{{ partial "albums/images.json" . }}],
"albums": [{{ partial "albums/albums.json" . }}]
}

View File

@ -0,0 +1,15 @@
{{- $first := true -}}
{{- range .Pages.ByTitle -}}
{{- if not $first }}, {{ end }}
{{ $first = false -}}
{
"title": "{{ .Title }}",
{{- with .Resources.GetMatch "album.zip" }}
"albumDownload": "{{ .RelPermalink }}",
{{ else -}}
{{ warnf "Could not find album.zip for %s" .RelPermalink -}}
{{ end -}}
"images": [{{ partial "albums/images.json" . }}],
"albums": [{{ partial "albums/albums.json" . }}]
}
{{ end -}}

View File

@ -0,0 +1,12 @@
{{- $first := true -}}
{{- range .Resources.ByType "image" -}}
{{- if not $first }}, {{ end }}
{{ $first = false -}}
{
"title": "{{ .Title }}",
"url": "{{ .RelPermalink }}",
"width": "{{ .Width }}",
"height": "{{ .Height }}",
"thumbnail": "{{ (.Fit "200x200").RelPermalink }}"
}
{{ end -}}