From 4c41e477e13d37e187c8de4225c7e8056bd9ed28 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 29 Sep 2025 19:17:13 +0200 Subject: Internalise theme --- layouts/shortcodes/alert.html | 73 +++++++++++++++++++++++++++++++++++++ layouts/shortcodes/details.html | 75 +++++++++++++++++++++++++++++++++++++++ layouts/shortcodes/img.html | 35 ++++++++---------- layouts/shortcodes/task-list.html | 1 + 4 files changed, 163 insertions(+), 21 deletions(-) create mode 100644 layouts/shortcodes/alert.html create mode 100644 layouts/shortcodes/details.html create mode 100644 layouts/shortcodes/task-list.html (limited to 'layouts/shortcodes') diff --git a/layouts/shortcodes/alert.html b/layouts/shortcodes/alert.html new file mode 100644 index 0000000..3a55964 --- /dev/null +++ b/layouts/shortcodes/alert.html @@ -0,0 +1,73 @@ +{{ $severity := .Get 0 }} +{{ $title := .Get 1 }} + +
+ {{ if $title }} +

{{ $title }}

+ {{ end }} +

+ {{ if eq $severity "info" }} + + + + {{ else if eq $severity "warning" }} + + + + {{ else if eq $severity "error" }} + + + + {{ else if eq $severity "success" }} + + + + + {{ end }} + {{.Inner}} +

+
diff --git a/layouts/shortcodes/details.html b/layouts/shortcodes/details.html new file mode 100644 index 0000000..ca524f7 --- /dev/null +++ b/layouts/shortcodes/details.html @@ -0,0 +1,75 @@ +{{- /* +Renders an HTML details element. + +@param {string} [class] The value of the element's class attribute. +@param {string} [name] The value of the element's name attribute. +@param {string} [summary] The content of the child summary element. +@param {string} [title] The value of the element's title attribute. +@param {bool} [open=false] Whether to initially display the content of the details element. + +@reference https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details + +@examples + + {{< details >}} + A basic collapsible section. + {{< /details >}} + + {{< details summary="Custom Summary Text" >}} + Showing custom `summary` text. + {{< /details >}} + + {{< details summary="Open Details" open=true >}} + Contents displayed initially by using `open`. + {{< /details >}} + + {{< details summary="Styled Content" class="my-custom-class" >}} + Content can be styled with CSS by specifying a `class`. + + Target details element: + + ```css + details.my-custom-class { } + ``` + + Target summary element: + + ```css + details.my-custom-class > summary > * { } + ``` + + Target inner content: + + ```css + details.my-custom-class > :not(summary) { } + ``` + {{< /details >}} + + {{< details summary="Grouped Details" name="my-details" >}} + Specifying a `name` allows elements to be connected, with only one able to be open at a time. + {{< /details >}} + +*/}} + +{{- /* Get arguments. */}} +{{- $class := or (.Get "class") "" }} +{{- $name := or (.Get "name") "" }} +{{- $summary := or (.Get "summary") "Details" }} +{{- $title := or (.Get "title") "" }} +{{- $open := false }} +{{- if in (slice "false" false 0) (.Get "open") }} + {{- $open = false }} +{{- else if in (slice "true" true 1) (.Get "open") }} + {{- $open = true }} +{{- end }} + +{{- /* Render. */}} +
+ {{ $summary | .Page.RenderString }} + {{ .Inner | .Page.RenderString (dict "display" "block") -}} +
\ No newline at end of file diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html index a0673a3..45ce3da 100644 --- a/layouts/shortcodes/img.html +++ b/layouts/shortcodes/img.html @@ -1,23 +1,16 @@ -{{/* Image Resources */}} -{{ $img := .Page.Resources.GetMatch (printf "%s" (.Get "src" | safeURL ))}} -{{ $alt := .Get "alt"}} +{{ $img := .Page.Resources.GetMatch (printf "%s" (.Get "src" | safeURL )) }} +{{ $alt := .Get "alt" }} +{{ $caption := .Get "caption" }} +{{ $captionPosition := .Get "caption-position" }} -{{/* Image Processing */}} -{{ $command := .Get "size-method" }} -{{ $options := .Get "size-format" }} -{{ if eq $command "Fit"}} - {{ $img = $img.Fit $options }} -{{ else if eq $command "Resize"}} - {{ $img = $img.Resize $options }} -{{ else if eq $command "Fill"}} - {{ $img = $img.Fill $options }} -{{ else if eq $command "Crop"}} - {{ $img = $img.Crop $options }} -{{ end }} - -{{/* Position */}} -{{ $position := .Get "position" }} - -
- +
+ {{ . }} + + {{ with $caption }} +
+ {{ . }} +
+ {{ end }}
\ No newline at end of file diff --git a/layouts/shortcodes/task-list.html b/layouts/shortcodes/task-list.html new file mode 100644 index 0000000..fe4ffe7 --- /dev/null +++ b/layouts/shortcodes/task-list.html @@ -0,0 +1 @@ + -- cgit v1.3