From 431d4b0990a5882d203dcf45388e628feb54c56f Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 25 Dec 2024 19:03:05 -0800 Subject: [PATCH] Add new internal ref shortcodes Signed-off-by: Danila Fedorin --- assets/scss/style.scss | 21 +++++++++++++++++++++ layouts/shortcodes/internal.html | 12 ++++++++++++ layouts/shortcodes/internalref.html | 7 +++++++ 3 files changed, 40 insertions(+) create mode 100644 layouts/shortcodes/internal.html create mode 100644 layouts/shortcodes/internalref.html diff --git a/assets/scss/style.scss b/assets/scss/style.scss index 2a98879..e1a9bc7 100755 --- a/assets/scss/style.scss +++ b/assets/scss/style.scss @@ -478,3 +478,24 @@ blockquote { .side-by-side-item { flex-basis: 0; } + +.internal-ref { + text-decoration: underline; + break-inside: avoid; + + &:target { + @include var(background-color, target-background-color); + border-radius: 1rem; + + .internal-ref-counter { + @include var(background-color, target-background-color); + } + } +} + +.internal-ref-counter { + display: inline-block; + border: $standard-border; + border-radius: 0.5rem; + padding: 0 0.25rem 0 0.25rem; +} diff --git a/layouts/shortcodes/internal.html b/layouts/shortcodes/internal.html new file mode 100644 index 0000000..356e5ec --- /dev/null +++ b/layouts/shortcodes/internal.html @@ -0,0 +1,12 @@ +{{- $name := .Get 0 -}} +{{- $number := 1 -}} +{{- with .Page.Scratch.Get "internal-ref-counter" -}} +{{- $number = add . 1 }} +{{- end -}} +{{- .Page.Scratch.Set "internal-ref-counter" $number -}} +{{- .Page.Scratch.SetInMap "internal-ref" $name $number -}} + + +{{ .Inner }} +{{ $number }} +{{- /* chomp whitespace at the end */ -}} diff --git a/layouts/shortcodes/internalref.html b/layouts/shortcodes/internalref.html new file mode 100644 index 0000000..9fa2a02 --- /dev/null +++ b/layouts/shortcodes/internalref.html @@ -0,0 +1,7 @@ +{{- $name := .Get 0 -}} +{{- $number := index (.Page.Scratch.Get "internal-ref") $name -}} + + +{{ .Inner }} +{{ $number }} +{{- /* chomp whitespace at the end */ -}}