From 33a57f03737d797c3c716c2cae1a12aacc2f27a3 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Tue, 7 Nov 2023 02:16:54 +0000 Subject: [PATCH] More site code improvements. Better imgproc, better caption CSS, make post archetype assume we'll have images. --- archetypes/default.md | 5 +--- archetypes/posts/images/.gitkeep | 0 archetypes/posts/index.md | 10 +++++++ layouts/shortcodes/imgproc.html | 50 ++++++++++++++++++++------------ static/css/custom.css | 4 +++ 5 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 archetypes/posts/images/.gitkeep create mode 100644 archetypes/posts/index.md diff --git a/archetypes/default.md b/archetypes/default.md index 3694abb..9e8c417 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -1,8 +1,5 @@ --- -title: "{{ replace (replace .Name "draft-" "") "-" " " | title }}" +title: "{{ replace .Name "-" " " | title }}" date: {{ dateFormat (.Site.Params.dateformat) .Date }} draft: true -tags: - - tag1 --- - diff --git a/archetypes/posts/images/.gitkeep b/archetypes/posts/images/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/archetypes/posts/index.md b/archetypes/posts/index.md new file mode 100644 index 0000000..4105614 --- /dev/null +++ b/archetypes/posts/index.md @@ -0,0 +1,10 @@ +--- +title: "{{ replace (replace .Name "draft-" "") "-" " " | title }}" +date: {{ dateFormat (.Site.Params.dateformat) .Date }} +draft: true +tags: + - tag1 +--- + + + diff --git a/layouts/shortcodes/imgproc.html b/layouts/shortcodes/imgproc.html index 1c4b154..0a9f65c 100644 --- a/layouts/shortcodes/imgproc.html +++ b/layouts/shortcodes/imgproc.html @@ -1,20 +1,32 @@ -{{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }} -{{ $imgdata := imageConfig (printf "/content/%s" $original.RelPermalink) }} -{{ if (gt $imgdata.Width 1500) }} - {{ .Scratch.Set "image" ($original.Resize "1500x") }} -{{ else if (gt $imgdata.Height 1500) }} - {{ .Scratch.Set "image" ($original.Resize "x1500") }} -{{ else }} - {{ .Scratch.Set "image" $original }} -{{ end }} - -{{ $image := .Scratch.Get "image" }} - -
- - +{{- $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) -}} +{{- $image := $original -}} +{{- $align := "none" -}} +{{- $alttext := "" -}} +{{- with (.Get 1) -}} + {{- if not (eq . "auto") -}} + {{- if or (hasSuffix . "x") (hasPrefix . "x") -}} + {{ $image = ($image.Resize .) }} + {{- else -}} + {{ $image = ($image.Fit .) }} + {{- end -}} + {{- end -}} +{{- end -}} +{{- with (.Get 2) -}} + {{- $align = . -}} +{{- end -}} +{{- with (.Get 3) -}} + {{ $alttext = . -}} +{{- end -}} +{{- if (gt $image.Width 1500) -}} + {{- $image = ($image.Resize "1500x") -}} +{{- else if (gt $image.Height 1500) -}} + {{- $image = ($image.Resize "x1500") -}} +{{- end -}} +
+ + {{ $alttext }} -
- {{ .Inner | markdownify }} -
-
+
+ {{ .Inner | markdownify }} +
+
diff --git a/static/css/custom.css b/static/css/custom.css index 4fde611..b692d37 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -2,6 +2,10 @@ body { color: #000000; } +figcaption { + text-align: center; +} + .c-article__summary p { color: #000000; margin: 16px;