From 9d9182e2680d0025432941017fe9f87dd620b852 Mon Sep 17 00:00:00 2001 From: Christian Wolf Date: Mon, 21 Oct 2024 19:03:23 +0200 Subject: [PATCH] Create basic scripts to generate JSONs from images --- archetypes/default.md | 10 +++++----- hugo.toml | 23 ----------------------- hugo.yaml | 28 ++++++++++++++++++++++++++++ layouts/albums/baseof.json | 3 +++ layouts/albums/list.json | 4 ++++ layouts/partials/albums/albums.json | 15 +++++++++++++++ layouts/partials/albums/images.json | 12 ++++++++++++ 7 files changed, 67 insertions(+), 28 deletions(-) delete mode 100644 hugo.toml create mode 100644 hugo.yaml create mode 100644 layouts/albums/baseof.json create mode 100644 layouts/albums/list.json create mode 100644 layouts/partials/albums/albums.json create mode 100644 layouts/partials/albums/images.json diff --git a/archetypes/default.md b/archetypes/default.md index c6f3fce..3de90ce 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -1,5 +1,5 @@ -+++ -title = '{{ replace .File.ContentBaseName "-" " " | title }}' -date = {{ .Date }} -draft = true -+++ +--- +title: '{{ replace .File.ContentBaseName "-" " " | title }}' +date: {{ .Date }} +draft: true +--- diff --git a/hugo.toml b/hugo.toml deleted file mode 100644 index 6c35bc4..0000000 --- a/hugo.toml +++ /dev/null @@ -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" diff --git a/hugo.yaml b/hugo.yaml new file mode 100644 index 0000000..fe381d4 --- /dev/null +++ b/hugo.yaml @@ -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 diff --git a/layouts/albums/baseof.json b/layouts/albums/baseof.json new file mode 100644 index 0000000..e11222a --- /dev/null +++ b/layouts/albums/baseof.json @@ -0,0 +1,3 @@ +{ + {{- block "main" . }}{{ end -}} +} diff --git a/layouts/albums/list.json b/layouts/albums/list.json new file mode 100644 index 0000000..b0b3ac8 --- /dev/null +++ b/layouts/albums/list.json @@ -0,0 +1,4 @@ +{ + "images": [{{ partial "albums/images.json" . }}], + "albums": [{{ partial "albums/albums.json" . }}] +} diff --git a/layouts/partials/albums/albums.json b/layouts/partials/albums/albums.json new file mode 100644 index 0000000..ad8bd67 --- /dev/null +++ b/layouts/partials/albums/albums.json @@ -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 -}} diff --git a/layouts/partials/albums/images.json b/layouts/partials/albums/images.json new file mode 100644 index 0000000..7622118 --- /dev/null +++ b/layouts/partials/albums/images.json @@ -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 -}}