Skip to content

Commit a1c87d4

Browse files
committed
fix: test for page context in download asset
1 parent 598b10b commit a1c87d4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

layouts/_partials/assets/download.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@
1919
{{ $error = $args.err }}
2020
{{ end }}
2121

22+
{{ $download := "" }}
2223
{{ if not $error }}
23-
{{/* Initialize local arguments */}}
24-
{{- $title := $args.title -}}
25-
{{- $download := partial "utilities/GetTargetPath.html" (dict "path" $args.download "page" page) -}}
24+
{{- $download = partial "utilities/GetTargetPath.html" (dict "path" $args.download "page" page) -}}
2625
{{- if and $download (not (fileExists (path.Join "static" $download))) -}}
27-
{{- errorf "Cannot find download file for page '%s': %s" page.File.Path $download -}}
26+
{{ if page }}
27+
{{- errorf "Cannot find download file for page '%s': %s" page.File.Path $download -}}
28+
{{ else }}
29+
{{- errorf "Cannot find download file: %s" $download -}}
30+
{{ end }}
2831
{{- $error = true }}
2932
{{- end -}}
33+
{{- end -}}
3034

35+
{{ if not $error }}
36+
{{- $title := $args.title -}}
3137
{{ if not $title }}
3238
{{ if not $args.minimal }}{{ $title = (T "download" ) }}{{ end }}
3339
{{ $lang := strings.TrimPrefix "." (path.Ext (path.BaseName $download)) }}

0 commit comments

Comments
 (0)