Skip to content

layouts: use new try function #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-pigs-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thulite/doks-core": patch
---

layouts: use new try function (Hugo 0.141.0 and above)
10 changes: 5 additions & 5 deletions layouts/_default/_markup/render-codeblock-kroki.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{{- $renderHookName := "kroki" }}

{{- /* Verify minimum required version. */}}
{{- $minHugoVersion := "0.114.0" }}
{{- $minHugoVersion := "0.141.0" }}
{{- if lt hugo.Version $minHugoVersion }}
{{- errorf "The %q code block render hook requires Hugo v%s or later." $renderHookName $minHugoVersion }}
{{- end }}
Expand Down Expand Up @@ -86,14 +86,14 @@
{{- /* Get diagram. */}}
{{- $body := dict "diagram_source" $inner "diagram_type" $diagramType "output_format" "SVG" | jsonify }}
{{- $opts := dict "method" "post" "body" $body }}
{{- with resources.GetRemote $apiEndpoint $opts }}
{{- with try (resources.GetRemote $apiEndpoint $opts) }}
{{- with .Err }}
{{- errorf "The %q code block render hook was unable to get the remote diagram. See %s. %s" $renderHookName $position . }}
{{- else }}
{{- else with .Value }}
{{- $attrs = merge $attrs (dict "src" .RelPermalink) }}
{{- else }}
{{- errorf "The %q code block render hook was unable to get the remote diagram. See %s" $renderHookName $position }}
{{- end }}
{{- else }}
{{- errorf "The %q code block render hook was unable to get the remote diagram. See %s" $renderHookName $position }}
{{- end }}

{{- /* Render. */}}
Expand Down
10 changes: 5 additions & 5 deletions layouts/_default/_markup/render-codeblock-math.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{{- $renderHookName := "math" }}

{{- /* Verify minimum required version. */}}
{{- $minHugoVersion := "0.114.0" }}
{{- $minHugoVersion := "0.141.0" }}
{{- if lt hugo.Version $minHugoVersion }}
{{- errorf "The %q code block render hook requires Hugo v%s or later." $renderHookName $minHugoVersion }}
{{- end }}
Expand Down Expand Up @@ -102,14 +102,14 @@

{{- /* Get image. */}}
{{- $url := printf "%s?%s" $apiEndpoint $qs }}
{{- with resources.GetRemote $url }}
{{- with try (resources.GetRemote $url) }}
{{- with .Err }}
{{- errorf "The %q code block render hook was unable to get the remote image. See %s. %s" $renderHookName $position . }}
{{- else }}
{{- else with .Value }}
{{- $url = .RelPermalink }}
{{- else }}
{{- errorf "The %q code block render hook was unable to get the remote image. See %s" $renderHookName $position }}
{{- end }}
{{- else }}
{{- errorf "The %q code block render hook was unable to get the remote image. See %s" $renderHookName $position }}
{{- end }}

{{- /* Render. */}}
Expand Down
10 changes: 5 additions & 5 deletions layouts/shortcodes/math.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*/}}

{{- /* Verify minimum required version. */}}
{{- $minHugoVersion := "0.114.0" }}
{{- $minHugoVersion := "0.141.0" }}
{{- if lt hugo.Version $minHugoVersion }}
{{- errorf "The %s shortcode requires Hugo v%s or later." .Name $minHugoVersion }}
{{- end }}
Expand Down Expand Up @@ -102,14 +102,14 @@

{{- /* Get image. */}}
{{- $url := printf "%s?%s" $apiEndpoint $qs }}
{{- with resources.GetRemote $url }}
{{- with try (resources.GetRemote $url) }}
{{- with .Err }}
{{- errorf "The %q shortcode was unable to get the remote image. See %s. %s" $name $position . }}
{{- else }}
{{- else with .Value }}
{{- $url = .RelPermalink }}
{{- else }}
{{- errorf "The %q shortcode was unable to get the remote image. See %s" $name $position }}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode was unable to get the remote image. See %s" $name $position }}
{{- end }}

{{- /* Render. */}}
Expand Down