diff --git a/assets/scss/style.scss b/assets/scss/style.scss index b92f722..3132c5f 100755 --- a/assets/scss/style.scss +++ b/assets/scss/style.scss @@ -150,7 +150,7 @@ a { transition: color 0.25s; } - &.external-link { + &.external-link, &.same-page-link { .feather { fill: none; margin-left: 0.25rem; diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html new file mode 100644 index 0000000..385fbc7 --- /dev/null +++ b/layouts/_default/_markup/render-heading.html @@ -0,0 +1,4 @@ +{{- .Page.Scratch.SetInMap "definedSections" (printf "#%s" .Anchor) true -}} + + {{- .Text | safeHTML -}} + diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 00f82fa..156e363 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,13 +1,30 @@ +{{- $scratch := newScratch -}} {{- $absoluteDest := absLangURL .Destination -}} {{- $siteRootUrl := absLangURL "" -}} {{- $isExternal := not (hasPrefix $absoluteDest $siteRootUrl) -}} +{{- $isSamePage := hasPrefix .Destination "#" -}} + +{{- if $isSamePage -}} + {{- $scratch.Set "class" "same-page-link" -}} + {{- if index (.Page.Scratch.Get "definedSections") .Destination -}} + {{- $scratch.Set "icon" "arrow-up" -}} + {{- else -}} + {{- $scratch.Set "icon" "arrow-down" -}} + {{- end -}} +{{- else if $isExternal -}} + {{- $scratch.Set "class" "external-link" -}} + {{- $scratch.Set "icon" "external-link" -}} +{{- end -}} {{- with .Text | safeHTML }}{{ . }}{{ end -}} - {{- if $isExternal -}}{{- partial "icon.html" "external-link" -}}{{- end -}} + {{- with $scratch.Get "icon" -}}{{- partial "icon.html" . -}}{{- end -}} {{- /* chomp trailing newline */ -}}