Skip to content

Commit

Permalink
Fix formatting issues when rendering links
Browse files Browse the repository at this point in the history
  • Loading branch information
neobrain committed Dec 14, 2024
1 parent ec70f06 commit a1e6c4d
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
{{ $rootPath := "/"}}
{{ $isExternal := (strings.HasPrefix .Destination "http") }}
{{- $rootPath := "/"}}
{{- $isExternal := (strings.HasPrefix .Destination "http") }}
{{- if (not (or $isExternal (strings.HasPrefix .Destination "#"))) }}
{{ $style := "" }}
{{ $desiredPage := (index (strings.Split .Destination "#") 0) }}
{{ with $.PageInner.GetPage $desiredPage }}
{{- $style := "" }}
{{- $desiredPage := (index (strings.Split .Destination "#") 0) }}
{{- with $.PageInner.GetPage $desiredPage }}
<!-- GetPage isn't case sensitive, so double-check the page name is spelled correctly -->
{{ with .File }}
{{ if (ne .Path (print $desiredPage "." .Ext)) }}
{{ $style = "color:#ba0000" }}
{{ end }}
{{ end }}
{{ else }}
{{ $style = "color:#ba0000" }}
{{ end }}
{{- with .File }}
{{- if (ne .Path (print $desiredPage "." .Ext)) }}
{{- $style = "color:#ba0000" }}
{{- end }}
{{- end }}
{{- else }}
{{- $style = "color:#ba0000" }}
{{- end -}}

<a href="{{ $rootPath }}{{ strings.Replace .Destination ":" "" }}"
{{- with .Title }} title="{{ . }}"{{ end -}}
style={{ $style }}
>
{{- with .Title }} title="{{ . }}" {{ end -}}
style={{ $style }}>
{{- with .Text }}{{ . }}{{ end -}}
</a>{{ else }}<a href="{{ .Destination | safeURL }}"
{{- with .Title }} title="{{ . }}"{{ end -}}
Expand Down

0 comments on commit a1e6c4d

Please sign in to comment.