refactor: internal and external links

This commit is contained in:
Ben Goldsworthy 2025-05-08 13:48:23 +02:00
parent 5aec4874b6
commit f1c9fa5622
No known key found for this signature in database
14 changed files with 388 additions and 125 deletions

View file

@ -0,0 +1,46 @@
{{- /*
Displays a list of internal links
@params pc Page context
@params sc Site context
*/
-}}
<!-- Variable assignment -->
{{- $params := . -}}
<!-- Validation -->
{{- if ( not ( isset $params "sc" ) ) -}}
{{- errorf "No site context received" -}}
{{- end -}}
{{- if ( not ( isset $params "pc" ) ) -}}
{{- errorf "No page context received (%q)" $params.sc.Page.File.Dir -}}
{{- end -}}
<!-- Rendering -->
<h3>Internal Links</h3>
<ul>
{{- range $params.pc.Params.internal_links -}}
{{ if eq ( printf "%T" . ) "map[string]interface {}" }}
{{ if ( isset . "name" ) }}
{{- errorf "Name is set (%q)" $params.sc.Page.File.Dir -}}
{{ end }}
{{- if ( isset . "src" ) -}}
{{- partial "single/main-body/links/link/page-resource-link.html" ( $params | merge ( dict "title" .title "src" .src ) ) }}
{{- else if ( isset . "ref" ) -}}
{{- partial "single/main-body/links/link/page-link.html" ( $params | merge ( dict "title" .title "ref" .ref ) ) }}
{{- else -}}
{{- partial "single/main-body/links/link/title-link.html" ( $params | merge ( dict "title" .title "link" .link ) ) }}
{{- end -}}
{{ else }}
{{- partial "single/main-body/links/link/basic-link.html" $params }}
{{ end }}
{{- end -}}
</ul>