diff options
Diffstat (limited to 'themes/danix-xyz-hacker/layouts')
6 files changed, 49 insertions, 67 deletions
diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/figure.html b/themes/danix-xyz-hacker/layouts/shortcodes/figure.html deleted file mode 100644 index 27d6cb2..0000000 --- a/themes/danix-xyz-hacker/layouts/shortcodes/figure.html +++ /dev/null @@ -1,8 +0,0 @@ -{{- $src := .Get "src" -}} -{{- $alt := .Get "alt" -}} -{{- $class := .Get "class" -}} -<figure class="my-6 {{ $class }}"> - {{- if $src -}}<img src="{{ $src }}" alt="{{ $alt }}" class="w-full" />{{ end -}} - {{- .Inner -}} - {{- if .Get "caption" -}}<figcaption class="text-sm text-text-dim mt-2">{{ .Get "caption" }}</figcaption>{{ end -}} -</figure> diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/gal-img.html b/themes/danix-xyz-hacker/layouts/shortcodes/gal-img.html deleted file mode 100644 index b9f8098..0000000 --- a/themes/danix-xyz-hacker/layouts/shortcodes/gal-img.html +++ /dev/null @@ -1,3 +0,0 @@ -<div class="{{ .Get "divClass" }}"> - <img src="{{ .Get "src" }}" alt="{{ .Get "alt" }}" class="image fit" /> -</div> diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/image.html b/themes/danix-xyz-hacker/layouts/shortcodes/image.html index 0209b7e..84dec3f 100644 --- a/themes/danix-xyz-hacker/layouts/shortcodes/image.html +++ b/themes/danix-xyz-hacker/layouts/shortcodes/image.html @@ -1,22 +1,23 @@ {{- $src := .Get "src" -}} {{- $alt := .Get "alt" | default "Image" -}} {{- $caption := .Get "caption" -}} -{{- $class := .Get "class" | default "w-full h-auto rounded-lg border border-border/30" -}} +{{- $class := .Get "class" | default "w-full h-auto rounded-lg border border-border" -}} +{{- $link := .Get "link" -}} +{{- $figureClass := .Get "figure-class" -}} -{{- if $src -}} - <figure class="my-8"> - <img - src="{{ $src }}" - alt="{{ $alt }}" - class="{{ $class }}" - loading="lazy" - /> +{{- if or $src .Inner -}} + <figure class="my-8{{- with $figureClass }} {{ . }}{{- end -}}"> + {{- if .Inner -}} + {{- .Inner -}} + {{- else -}} + {{- if $link -}}<a href="{{ $link }}">{{- end -}} + <img src="{{ $src }}" alt="{{ $alt }}" class="{{ $class }}" loading="lazy" /> + {{- if $link -}}</a>{{- end -}} + {{- end -}} {{- if $caption -}} - <figcaption class="mt-3 text-center text-sm text-text-dim italic"> - {{ $caption }} - </figcaption> + <figcaption class="mt-3 text-center text-sm text-text-dim italic">{{ $caption }}</figcaption> {{- end -}} </figure> {{- else -}} - {{- errorf "image shortcode: 'src' parameter is required" -}} + {{- errorf "image shortcode: 'src' parameter or inner content is required" -}} {{- end -}} diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/img.html b/themes/danix-xyz-hacker/layouts/shortcodes/img.html deleted file mode 100644 index 2393928..0000000 --- a/themes/danix-xyz-hacker/layouts/shortcodes/img.html +++ /dev/null @@ -1 +0,0 @@ -<img src="{{ .Get "src" }}" alt="{{ .Get "alt" }}" class="w-full my-4" /> diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/video.html b/themes/danix-xyz-hacker/layouts/shortcodes/video.html index a07500a..1e2645d 100644 --- a/themes/danix-xyz-hacker/layouts/shortcodes/video.html +++ b/themes/danix-xyz-hacker/layouts/shortcodes/video.html @@ -1,43 +1,37 @@ -{{/* - * The video shortcode: - * All arguments are optional, except for src which is where you define your video file - * This shortcode supports only webm video files. - * Args: - * class: [string] The class(es) to give to the video block. - * width: [int] The width of the video - * height: [int] The height of the video - * autoplay: [bool] true or false for autoplay - defaults to false - * loop: [bool] true or false for loop - defaults to false - * mute: [bool] true or false for mute - defaults to false - * - * Usage: - * {{< video src="my-awesome-video.mp4" width=600 height=600 autoplay=true loop=true mute=true class="some class" >}} - * - * Output: - * <video class="some class" controls preload="auto" width="600" height="600" autoplay loop muted> - <source src="my-awesome-video.mp4" type="video/webm"> - * </video> - * - */}} +{{- $src := .Get "src" -}} +{{- $id := .Get "id" -}} +{{- $title := .Get "title" | default "Video" -}} +{{- $class := .Get "class" | default "" -}} -{{ $srcParam := .Get "src" }} -{{ $ext := $srcParam | path.Ext }} -{{ $filetype := slicestr $ext 1 }} - -{{ $videoURL := $srcParam }} -{{ $resource := .Page.Resources.GetMatch $srcParam }} -{{ if $resource }} - {{ $videoURL = $resource.RelPermalink }} -{{ end }} - -<video{{ with .Get "class" }} class="{{ . }}"{{ end }} - controls - preload="auto" - {{ with .Get "width" }}width="{{.}}"{{ end }} - {{ with .Get "height" }}height="{{.}}"{{ end }} - {{ if eq (.Get "autoplay") "true" }}autoplay {{ end }} - {{ if eq (.Get "loop") "true" }}loop {{ end }} - {{ if eq (.Get "muted") "true" }}muted {{ end }} - playsinline > +{{- if $id -}} + <div class="my-6{{- with $class }} {{ . }}{{- end -}}"> + <iframe + class="w-full aspect-video" + src="https://www.youtube.com/embed/{{ $id }}" + title="{{ $title }}" + allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" + allowfullscreen + ></iframe> + </div> +{{- else if $src -}} + {{- $ext := $src | path.Ext -}} + {{- $filetype := slicestr $ext 1 -}} + {{- $videoURL := $src -}} + {{- $resource := .Page.Resources.GetMatch $src -}} + {{- if $resource -}}{{- $videoURL = $resource.RelPermalink -}}{{- end -}} + <video + {{- with $class }} class="{{ . }}"{{ end }} + controls + preload="auto" + playsinline + {{- with .Get "width" }} width="{{ . }}"{{ end }} + {{- with .Get "height" }} height="{{ . }}"{{ end }} + {{- if eq (.Get "autoplay") "true" }} autoplay{{ end }} + {{- if eq (.Get "loop") "true" }} loop{{ end }} + {{- if eq (.Get "muted") "true" }} muted{{ end }} + > <source src="{{ $videoURL }}" type="video/{{ $filetype }}"> -</video> + </video> +{{- else -}} + {{- errorf "video shortcode: either 'src' or 'id' parameter is required" -}} +{{- end -}} diff --git a/themes/danix-xyz-hacker/layouts/shortcodes/youtube.html b/themes/danix-xyz-hacker/layouts/shortcodes/youtube.html deleted file mode 100644 index 80cbb93..0000000 --- a/themes/danix-xyz-hacker/layouts/shortcodes/youtube.html +++ /dev/null @@ -1 +0,0 @@ -<iframe class="w-full aspect-video my-6" src="https://www.youtube.com/embed/{{ .Get "id" }}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> |
