From d63e695cf43f8e0f18a9e809a29dc0926e1d8f18 Mon Sep 17 00:00:00 2001 From: Wiktor Zykubek Date: Sat, 28 Dec 2024 01:25:12 +0100 Subject: [PATCH] chore: add basic layouts --- layouts/_default/article.html | 11 ++++++++ layouts/_default/baseof.html | 14 ++++++++++ layouts/_default/home.html | 14 ++++++++++ layouts/_default/list.html | 13 +++++++++ layouts/_default/single.html | 7 +++++ layouts/partials/footer.html | 13 +++++++++ layouts/partials/head.html | 8 ++++++ layouts/partials/head/css.html | 14 ++++++++++ layouts/partials/head/js.html | 12 ++++++++ layouts/partials/header.html | 20 +++++++++++++ layouts/partials/menu.html | 51 ++++++++++++++++++++++++++++++++++ layouts/partials/terms.html | 23 +++++++++++++++ 12 files changed, 200 insertions(+) create mode 100644 layouts/_default/article.html create mode 100644 layouts/_default/baseof.html create mode 100644 layouts/_default/home.html create mode 100644 layouts/_default/list.html create mode 100644 layouts/_default/single.html create mode 100644 layouts/partials/footer.html create mode 100644 layouts/partials/head.html create mode 100644 layouts/partials/head/css.html create mode 100644 layouts/partials/head/js.html create mode 100644 layouts/partials/header.html create mode 100644 layouts/partials/menu.html create mode 100644 layouts/partials/terms.html diff --git a/layouts/_default/article.html b/layouts/_default/article.html new file mode 100644 index 0000000..e1a53f3 --- /dev/null +++ b/layouts/_default/article.html @@ -0,0 +1,11 @@ +{{ define "main" }} +

{{ .Title }}

+ + {{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }} + {{ $dateHuman := .Date | time.Format ":date_medium" }} + + + {{ .Content }} + + {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} +{{ end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 0000000..87e76ae --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,14 @@ + + + + {{ partial "head.html" . }} + + +
{{ partial "header.html" . }}
+
{{ block "main" . }}{{ end }}
+ + + diff --git a/layouts/_default/home.html b/layouts/_default/home.html new file mode 100644 index 0000000..216d166 --- /dev/null +++ b/layouts/_default/home.html @@ -0,0 +1,14 @@ +{{ define "main" }} + {{ .Content }} + {{ range site.Sections.ByWeight.Reverse }} +

{{ .LinkTitle }}

+ {{ range first 3 .Pages }} + + {{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }} + {{ $dateHuman := .Date | time.Format ":date_long" }} + + +

{{ .LinkTitle }}

+ {{ end }} + {{ end }} +{{ end }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html new file mode 100644 index 0000000..4d1ce99 --- /dev/null +++ b/layouts/_default/list.html @@ -0,0 +1,13 @@ +{{ define "main" }} +

{{ .Title }}

+ {{ .Content }} + {{ range .Pages }} +

{{ .LinkTitle }}

+ + {{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }} + {{ $dateHuman := .Date | time.Format ":date_long" }} + + + {{ .Summary }} + {{ end }} +{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html new file mode 100644 index 0000000..bad430e --- /dev/null +++ b/layouts/_default/single.html @@ -0,0 +1,7 @@ +{{ define "main" }} +

{{ .Title }}

+ + {{ .Content }} + + {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} +{{ end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html new file mode 100644 index 0000000..0d78a77 --- /dev/null +++ b/layouts/partials/footer.html @@ -0,0 +1,13 @@ +

+ {{ .Site.Copyright }} + {{ if eq .Site.Language.LanguageCode "en" }} + Used Rosé Pine palette + {{ else if eq .Site.Language.LanguageCode "pl" }} + Wykorzystano paletę kolorów + Rosé Pine + {{ end }} +

diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 0000000..d3df3a4 --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1,8 @@ + + +{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }} +{{ partialCached "head/css.html" . }} +{{ partialCached "head/js.html" . }} +{{ with .OutputFormats.Get "rss" -}} + {{ printf `` .Rel .MediaType.Type .Permalink site.Title | safeHTML }} +{{ end }} diff --git a/layouts/partials/head/css.html b/layouts/partials/head/css.html new file mode 100644 index 0000000..2dbfc7c --- /dev/null +++ b/layouts/partials/head/css.html @@ -0,0 +1,14 @@ +{{- with resources.Get "css/main.css" }} + {{- if eq hugo.Environment "development" }} + + {{- else }} + {{- with . | minify | fingerprint }} + + {{- end }} + {{- end }} +{{- end }} + + +{{- with resources.Get "css/rose-pine-main.css" }} + +{{- end }} diff --git a/layouts/partials/head/js.html b/layouts/partials/head/js.html new file mode 100644 index 0000000..18fe842 --- /dev/null +++ b/layouts/partials/head/js.html @@ -0,0 +1,12 @@ +{{- with resources.Get "js/main.js" }} + {{- if eq hugo.Environment "development" }} + {{- with . | js.Build }} + + {{- end }} + {{- else }} + {{- $opts := dict "minify" true }} + {{- with . | js.Build $opts | fingerprint }} + + {{- end }} + {{- end }} +{{- end }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html new file mode 100644 index 0000000..efcd316 --- /dev/null +++ b/layouts/partials/header.html @@ -0,0 +1,20 @@ +

{{ site.Title }}

+
+ + {{ partial "menu.html" (dict "menuID" "main" "page" .) }} + + + {{ if .IsTranslated }} + {{ range .Translations }} + + {{ .Site.Language.LanguageCode }} + {{ if eq .Site.Language.LanguageCode "en" }} + {{ ":gb:" | .RenderString }} + {{ else if eq .Site.Language.LanguageCode "pl" }} + {{ ":poland:" | .RenderString }} + {{ end }} + + {{ end }} + {{ end }} + +
diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html new file mode 100644 index 0000000..7183180 --- /dev/null +++ b/layouts/partials/menu.html @@ -0,0 +1,51 @@ +{{- /* +Renders a menu for the given menu ID. + +@context {page} page The current page. +@context {string} menuID The menu ID. + +@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }} +*/}} + +{{- $page := .page }} +{{- $menuID := .menuID }} + +{{- with index site.Menus $menuID }} + +{{- end }} + +{{- define "partials/inline/menu/walk.html" }} + {{- $page := .page }} + {{- range .menuEntries }} + {{- $attrs := dict "href" .URL }} + {{- if $page.IsMenuCurrent .Menu . }} + {{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }} + {{- else if $page.HasMenuCurrent .Menu .}} + {{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }} + {{- end }} + {{- $name := .Name }} + {{- with .Identifier }} + {{- with T . }} + {{- $name = . }} + {{- end }} + {{- end }} +
  • + {{ $name }} + {{- with .Children }} + + {{- end }} +
  • + {{- end }} +{{- end }} diff --git a/layouts/partials/terms.html b/layouts/partials/terms.html new file mode 100644 index 0000000..8a6ebec --- /dev/null +++ b/layouts/partials/terms.html @@ -0,0 +1,23 @@ +{{- /* +For a given taxonomy, renders a list of terms assigned to the page. + +@context {page} page The current page. +@context {string} taxonomy The taxonomy. + +@example: {{ partial "terms.html" (dict "taxonomy" "tags" "page" .) }} +*/}} + +{{- $page := .page }} +{{- $taxonomy := .taxonomy }} + +{{- with $page.GetTerms $taxonomy }} + {{- $label := (index . 0).Parent.LinkTitle }} +
    +
    {{ $label }}:
    + +
    +{{- end }}