More site code improvements. Better imgproc, better caption CSS, make post archetype assume we'll have images.

This commit is contained in:
Anna Rose 2023-11-07 02:16:54 +00:00
parent 3c80fa1214
commit 33a57f0373
5 changed files with 46 additions and 23 deletions

View File

@ -1,8 +1,5 @@
--- ---
title: "{{ replace (replace .Name "draft-" "") "-" " " | title }}" title: "{{ replace .Name "-" " " | title }}"
date: {{ dateFormat (.Site.Params.dateformat) .Date }} date: {{ dateFormat (.Site.Params.dateformat) .Date }}
draft: true draft: true
tags:
- tag1
--- ---
<!--more-->

View File

10
archetypes/posts/index.md Normal file
View File

@ -0,0 +1,10 @@
---
title: "{{ replace (replace .Name "draft-" "") "-" " " | title }}"
date: {{ dateFormat (.Site.Params.dateformat) .Date }}
draft: true
tags:
- tag1
---
<!--more-->

View File

@ -1,20 +1,32 @@
{{ $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }} {{- $original := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) -}}
{{ $imgdata := imageConfig (printf "/content/%s" $original.RelPermalink) }} {{- $image := $original -}}
{{ if (gt $imgdata.Width 1500) }} {{- $align := "none" -}}
{{ .Scratch.Set "image" ($original.Resize "1500x") }} {{- $alttext := "" -}}
{{ else if (gt $imgdata.Height 1500) }} {{- with (.Get 1) -}}
{{ .Scratch.Set "image" ($original.Resize "x1500") }} {{- if not (eq . "auto") -}}
{{ else }} {{- if or (hasSuffix . "x") (hasPrefix . "x") -}}
{{ .Scratch.Set "image" $original }} {{ $image = ($image.Resize .) }}
{{ end }} {{- else -}}
{{ $image = ($image.Fit .) }}
{{ $image := .Scratch.Get "image" }} {{- end -}}
{{- end -}}
<figure style="padding: 0.25rem; margin: 2rem 0;"> {{- end -}}
<a href="{{ $original.RelPermalink }}"> {{- with (.Get 2) -}}
<img style="max-width: 100%; width: auto; height: auto;" src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}"> {{- $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 -}}
<figure style="float: {{ $align }};">
<a href="{{- $original.RelPermalink -}}">
<img style="max-width: 100%; width: auto; height: auto;" src="{{- $image.RelPermalink -}}" width="{{- $image.Width -}}" height="{{- $image.Height -}}" alt="{{ $alttext }}"/>
</a> </a>
<figcaption> <figcaption>
{{ .Inner | markdownify }} {{ .Inner | markdownify }}
</figcaption> </figcaption>
</figure> </figure>

View File

@ -2,6 +2,10 @@ body {
color: #000000; color: #000000;
} }
figcaption {
text-align: center;
}
.c-article__summary p { .c-article__summary p {
color: #000000; color: #000000;
margin: 16px; margin: 16px;