CHANGE image handling, ADD partials to reuse structure, REFACTOR

This commit is contained in:
Hoernschen 2025-04-17 16:22:33 +02:00
parent 1265491dee
commit 01dcf04b8a
Signed by: hoernschen
GPG key ID: 37591FAF4E6D3462
36 changed files with 1181 additions and 864 deletions

View file

@ -0,0 +1 @@
{{- partial "components/image.html" (dict "url" .Destination "alt" .Text "caption" .Title) -}}

View file

@ -1,63 +1,52 @@
<!DOCTYPE html>
<!doctype html>
<html lang="{{ .Site.LanguageCode }}">
<head>
<meta name="description" content="{{ if .Params.summary }}{{ .Params.summary }}{{ else if .Site.Params.Description }}{{ .Site.Params.Description }}{{ else }}Hardcoded description; the author should update :){{ end }}" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>{{ if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }}</title>
{{ block "opengraph" . }}
<meta property="og:type" content="website" />
{{ with .Site.LanguageCode }}
<meta property="og:locale" content='{{ replace . "-" "_" }}' />
{{ end }}
<meta property="og:title" content="{{ if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:site_name" content="{{ .Site.Title }}" />
{{ if .Params.image }}
<meta property="og:image" content="{{ .Params.image | absURL }}" />
{{ else }}
<meta property="og:image" content="{{ .Site.Params.logo | absURL }}" />
{{ end }}
{{ if .Params.summary }}
<meta property="og:description" content="{{ .Params.summary }}" />
{{ else if .Content }}
<meta property="og:description" content="{{ .Content | safeHTML | truncate 100 }}" />
{{ else }}
<meta property="og:description" content="{{ .Site.Params.Description }}" />
{{ end }}
{{ end }}
{{- $favIcon := .Site.Params.favIcon }}
<link rel="icon" type="image/png" sizes="16x16" href="{{ if $favIcon.small }}{{ $favIcon.small }}{{ else }}/favIcon16x16.png{{ end }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ if $favIcon.big }}{{ $favIcon.big }}{{ else }}/favIcon32x32.png{{ end }}">
{{ with .Site.Params.tracking }}
<script src="{{ . }}"></script>
{{ end }}
<link rel="stylesheet" type="text/css" href="/icons/fontawesome.css">
{{ $template := resources.Get "scss/index.scss" }}
{{ if $template }}
{{ $index := $template | resources.ExecuteAsTemplate "css/index.scss" . | resources.ToCSS (dict "outputStyle" "compressed") | fingerprint }}
<link rel="stylesheet" type="text/css" href="{{ $index.RelPermalink }}">
{{ end }}
{{ block "styling" . }}
{{ end }}
{{ $template := resources.Get "scss/totop.scss" }}
{{ if $template }}
{{ $totop := $template | resources.ExecuteAsTemplate "css/totop.scss" . | resources.ToCSS (dict "outputStyle" "compressed") | fingerprint }}
<link rel="stylesheet" type="text/css" href="{{ $totop.RelPermalink }}">
{{ end }}
</head>
<body>
{{ block "header" . }}
{{- partial "header.html" . -}}
{{ end }}
{{ block "main" . }}
<!-- The part of the page that begins to differ between templates -->
{{ end }}
{{ block "footer" . }}
{{- partial "footer.html" . -}}
{{ end }}
</body>
</html>
<head>
<meta name="description"
content="{{ if .Params.summary }}{{ .Params.summary }}{{ else if .Site.Params.Description }}{{ .Site.Params.Description }}{{ else }}Hardcoded description; the author should update :){{ end }}" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="color-scheme" content="light">
{{ template "_internal/opengraph.html" . }}
<title>
{{ if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }}
</title>
{{ with .Site.Params.favIcon }}
{{ if .ico }}
<link rel="icon" type="image/x-icon" href="{{ .ico }}">
{{ end }}
{{ if .small }}
<link rel="icon" type="image/png" sizes="16x16" href="{{ .small }}">
{{ end }}
{{ if .big }}
<link rel="icon" type="image/png" sizes="32x32" href="{{ .big }}">
{{ end }}
{{ end }}
{{ with .Site.Params.tracking }}
<script src="{{ . }}"></script>
{{ end }}
<link rel="stylesheet" type="text/css" href="/icons/fontawesome.css" />
{{ $template := resources.Get "scss/index.scss" }} {{ if $template }} {{
$index := $template | resources.ExecuteAsTemplate "css/index.scss" . |
resources.ToCSS (dict "outputStyle" "compressed") | fingerprint }}
<link rel="stylesheet" type="text/css" href="{{ $index.RelPermalink }}" />
{{ end }} {{ block "styling" . }} {{ end }} {{ $template := resources.Get
"scss/totop.scss" }} {{ if $template }} {{ $totop := $template |
resources.ExecuteAsTemplate "css/totop.scss" . | resources.ToCSS (dict
"outputStyle" "compressed") | fingerprint }}
<link rel="stylesheet" type="text/css" href="{{ $totop.RelPermalink }}" />
{{ end }}
</head>
<body>
{{ block "header" . }} {{- partial "header.html" . -}} {{ end }}
<main>
{{ block "main" . }}
<!-- The part of the page that begins to differ between templates -->
{{ end }}
</main>
{{ block "footer" . }} {{- partial "footer.html" . -}} {{ end }}
</body>
</html>

View file

@ -1,27 +1,24 @@
{{ define "main" }}
{{ with .Params.image }}
{{ if .url }}
<img class="coverimage" src="{{ .url }}" alt="{{ .alt }}" />
{{- partial "components/image.html" (dict "style" "coverimage" "url" .url "alt" .alt) -}}
{{ else }}
<img class="coverimage" src="{{ . }}" />
{{- partial "components/image.html" (dict "style" "coverimage" "url" .) -}}
{{ end }}
{{ end }}
{{ if .Content }}
<div class="content">
{{ with .Title }}
<div class="title">
<h1 class="content-title">{{ . }}</h1>
<div class="divider"></div>
</div>
{{ partial "components/title.html" . }}
{{ end }}
{{.Content}}
</div>
{{ else }}
{{ else if .Params.header.enabled }}
<div class="header-blocker"></div>
{{ end }}
{{- range $index, $page := .Pages }}
{{ $odd := mod $index 2 }}
{{ $id := .Params.id | default $page.File.ContentBaseName }}
{{ $id := .Params.id | default $page.Name }}
{{ if eq .Params.type "slider" }}
{{- partial "slider.html" (dict "id" $id "slider" .Params "color" $.Site.Params.color "odd" $odd) -}}
{{ else if eq .Params.type "hero" }}

View file

@ -1,18 +1,15 @@
{{ define "main" }}
{{ with .Params.image }}
{{ if .url }}
<img class="coverimage" src="{{ .url }}" alt="{{ .alt }}" />
{{ else }}
<img class="coverimage" src="{{ . }}" />
{{ end }}
{{ with .Params.image }}
{{ if .url }}
{{- partial "components/image.html" (dict "style" "coverimage" "url" .url "alt" .alt) -}}
{{ else }}
{{- partial "components/image.html" (dict "style" "coverimage" "url" . "alt" "Cover") -}}
{{ end }}
<div class="content">
{{ with .Title }}
<div class="title">
<h1 class="content-title">{{ . }}</h1>
<div class="divider"></div>
</div>
{{ end }}
{{ .Content }}
</div>
{{ end }}
<div class="content">
{{ with .Title }}
{{ partial "components/title.html" . }}
{{ end }}
{{ .Content }}
</div>
{{ end }}

View file

@ -1,10 +1,7 @@
{{ define "main" }}
<div class="content">
<article>
<div class="title">
<h1 class="content-title">{{ .Title }}</h1>
<div class="divider"></div>
</div>
{{ partial "components/title.html" .Title }}
{{.Content}}
</article>
<div class="cardList">
@ -13,9 +10,9 @@
<a href="{{.Permalink}}">
<div class="cardContent">
{{ if .Params.image }}
<img class="cardImage {{ if eq .Params.image.cover false }} noCover {{ end }}" alt="{{ .Params.image.alt }}" src="{{ .Params.image.url }}" />
{{- partial "components/image.html" (dict "style" "cardImage" "url" .Params.image.url "alt" .Params.image.alt) -}}
{{ else }}
<img class="cardImage" src="{{ .Site.Params.defaultimage }}" alt="Default Image" />
{{- partial "components/image.html" (dict "style" "cardImage" "url" .Site.Params.defaultimage "alt" "Placeholder") -}}
{{ end }}
<div class="cardTitle">{{.Title}}</div>
<div class="cardDescription">{{ .Summary | safeHTML | truncate 320 }}</div>
@ -26,4 +23,4 @@
{{ end }}
</div>
</div>
{{ end }}
{{ end }}

View file

@ -1,20 +1,17 @@
{{ define "main" }}
<div class="content">
<article>
<div class="title">
<h1 class="content-title">{{ .Title }}</h1>
<div class="divider"></div>
</div>
</article>
<!-- Ranges through content/posts/*.md -->
<div class="cardList">
<article>
{{ partial "components/title.html" .Title }}
</article>
<!-- Ranges through content/posts/*.md -->
<div class="cardList">
{{ range .Pages }}
<a href="{{.Permalink}}">
<div class="smallCard">
<div class="cardTitle">{{.Title}}</div>
</div>
</a>
<a href="{{.Permalink}}">
<div class="smallCard">
<div class="cardTitle">{{.Title}}</div>
</div>
</a>
{{ end }}
</div>
</div>
</div>
{{ end }}
{{ end }}