mirror of
https://github.com/HERDAC/Cours-programmation.git
synced 2024-11-24 18:43:28 +00:00
17 lines
767 B
HTML
17 lines
767 B
HTML
{{$trimmed := strings.TrimSuffix ".md" (.Destination | safeURL)}}
|
|
{{$dashedurl := replace $trimmed "%20" "-" }}
|
|
{{$external := strings.HasPrefix $dashedurl "http" }}
|
|
{{- if $external -}}
|
|
<a href="{{ $dashedurl }}" rel="noopener">{{ .Text | safeHTML }}</a>
|
|
{{- else -}}
|
|
{{$spacedurl := replace $trimmed "%20" " " }}
|
|
{{$fixedUrl := (cond (hasPrefix $spacedurl "/") $spacedurl (print "/" $spacedurl)) | urlize}}
|
|
{{$nonexistent := eq (.Page.GetPage $spacedurl).RelPermalink ""}}
|
|
{{$rooted := default $spacedurl (strings.TrimRight "/" (.Page.GetPage $spacedurl).RelPermalink) }}
|
|
<a
|
|
{{if not $nonexistent}}href="{{$rooted}}"{{end}}
|
|
rel="noopener" class="internal-link{{if $nonexistent}} broken{{end}}"
|
|
data-src="{{$rooted}}">{{- .Text | safeHTML -}}
|
|
</a>
|
|
{{- end -}}
|