2024-03-28 08:32:51 +01:00
|
|
|
{{ $filename := .filename | default "" -}}
|
2024-12-28 19:41:23 +07:00
|
|
|
{{ $base_url := .base_url | default "" -}}
|
2024-03-28 08:32:51 +01:00
|
|
|
{{ $lang := .lang | default "" }}
|
|
|
|
{{ $content := .content }}
|
|
|
|
{{ $options := .options | default (dict) }}
|
|
|
|
|
|
|
|
{{- if $filename -}}
|
2024-12-28 19:41:23 +07:00
|
|
|
<div class="filename not-prose" dir="auto">
|
|
|
|
{{- if $base_url -}}
|
|
|
|
|
|
|
|
{{- $base_url = strings.TrimSuffix "/" $base_url -}}
|
|
|
|
{{- $filename = strings.TrimPrefix "/" $filename -}}
|
|
|
|
{{- $file_url := urls.JoinPath $base_url $filename -}}
|
|
|
|
|
|
|
|
<a class="hx-no-underline hx-inline-flex hx-items-center hx-gap-1" href="{{ $file_url }}" target="_blank" rel="noopener noreferrer">
|
|
|
|
<span>{{- $filename -}}</span>
|
|
|
|
{{- partial "utils/icon" (dict "name" "external-link" "attributes" "height=1em") -}}
|
|
|
|
</a>
|
|
|
|
{{- else -}}
|
|
|
|
{{- $filename -}}
|
|
|
|
{{- end -}}
|
|
|
|
</div>
|
2024-03-28 08:32:51 +01:00
|
|
|
{{- end -}}
|
2024-12-28 19:41:23 +07:00
|
|
|
|
2024-03-28 08:32:51 +01:00
|
|
|
{{- if transform.CanHighlight $lang -}}
|
|
|
|
<div>{{- highlight $content $lang $options -}}</div>
|
|
|
|
{{- else -}}
|
2025-03-10 20:12:30 +01:00
|
|
|
<div><pre><code>{{ $content }}</code></pre></div>
|
2024-03-28 08:32:51 +01:00
|
|
|
{{- end -}}
|