From ce6a11b2940c83c5135dcd40f2760f42f5607e16 Mon Sep 17 00:00:00 2001 From: Nicolas MASSE Date: Mon, 22 Nov 2021 11:50:23 +0100 Subject: [PATCH] two more shortcodes --- layouts/shortcodes/highlightWithTitle.html | 7 +++++++ layouts/shortcodes/internalLink.html | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 layouts/shortcodes/highlightWithTitle.html create mode 100644 layouts/shortcodes/internalLink.html diff --git a/layouts/shortcodes/highlightWithTitle.html b/layouts/shortcodes/highlightWithTitle.html new file mode 100644 index 0000000..5cf49e9 --- /dev/null +++ b/layouts/shortcodes/highlightWithTitle.html @@ -0,0 +1,7 @@ + +
+{{- with .Get 0 -}} +
{{ . | safeHTML }}
+{{- end -}} +{{- highlight (trim .Inner "\n") (.Get 1) (.Get 2) -}} +
\ No newline at end of file diff --git a/layouts/shortcodes/internalLink.html b/layouts/shortcodes/internalLink.html new file mode 100644 index 0000000..2d60bea --- /dev/null +++ b/layouts/shortcodes/internalLink.html @@ -0,0 +1,18 @@ + +{{ $path := .Get "path" }} +{{ $lang := .Get "lang" }} +{{ $currentLang := .Page.Lang }} +{{ range .Page.Sites }} +{{ if eq .Language.Lang $lang }} +{{ with .GetPage $path }} + +{{ .Title }} + +{{ if ne $currentLang $lang }} +{{- partial "icons/en.svg" . -}} +{{ end }} +{{ else }} +{{ errorf "shortcode internalLink: Cannot find page %q with lang %q" $path $lang }} +{{ end }} +{{ end }} +{{ end }}