38 lines
1.9 KiB
HTML
38 lines
1.9 KiB
HTML
{{- $text_link := .Text -}}
|
||
{{- $sup := "" -}} <!-- prefix for links -->
|
||
|
||
{{ $_ := newScratch }} <!-- Get triads -->
|
||
{{- range $k, $v := .Page.Site.Data.sandpointsnamegraph -}}
|
||
{{ $_.Add "triads" $k }}
|
||
{{- end -}}
|
||
<!-- TODO add URLs to scratch -->
|
||
|
||
<!-- Internal links to MD files (.md suffix) -->
|
||
{{ if strings.HasSuffix .Destination ".md" }}
|
||
{{ if in ($_.Get "triads") (index (split .Destination "/") 0) }}
|
||
<!-- Obsidian replaces filename spaces with '%20'. For Hugo we replace that with "-" -->
|
||
{{ $destNoSpaces := strings.Replace .Destination "%20" "-" }}
|
||
<!-- if page exists -->
|
||
<!--TODO check for links to subheadings #-->
|
||
{{ if $.Page.Site.GetPage $destNoSpaces }}
|
||
{{ $session := $.Page.Site.GetPage $destNoSpaces }}
|
||
{{ .Page.Scratch.Add "links" (slice $session) }}
|
||
<a class="triadlink" repoid="{{- $session.File.UniqueID -}}" printhref="#ph-{{- $session.File.UniqueID -}}" href="{{- $session.RelPermalink -}}{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}"{{- with .Title}} title="{{- . -}}"{{- end -}}><span class="sup">{{- index (split $destNoSpaces "/") 0 -}}⁄</span>{{- $text_link -}}</a>
|
||
{{ else }}
|
||
<highlight>MD ENTRY DOES NOT EXIST: {{ .Destination }}</highlight>
|
||
{{ end }}
|
||
{{ else }}
|
||
<highlight>TRIAD DOES NOT EXIST: {{ .Destination }}</highlight>
|
||
{{ end }}<!-- END is in Triads -->
|
||
{{ else }} <!-- END MD suffix -->
|
||
<!-- HTTP LINKS -->
|
||
{{ if strings.HasPrefix .Destination "http" }}
|
||
{{ $sup = "www" }}
|
||
<!-- TODO add classes -->
|
||
<!-- Subheadings LINKS (starting with #) -->
|
||
{{ else if strings.HasPrefix .Destination "#" }}
|
||
{{ $sup = "§" }}
|
||
<!-- TODO add CLASSES -->
|
||
{{ end }}
|
||
<a href="{{ .Destination | safeURL }}"{{ with .Title }} title="{{ . }}"{{ end }}><span class="sup">{{ $sup }}⁄</span>LINK</a>
|
||
{{ end }}
|