fix: scope og tag variables inside try/catch block
This commit is contained in:
parent
e0be582dd0
commit
36c4dab00d
1 changed files with 20 additions and 16 deletions
|
|
@ -1,23 +1,27 @@
|
|||
{{ define "title" }}
|
||||
{{ $title := "Where Am I? :: adriano.fyi" }}
|
||||
{{ $desc := "" }}
|
||||
{{ try }}
|
||||
{{ with resources.GetRemote "https://jellybee.bison-lizard.ts.net/whereami" | transform.Unmarshal }}
|
||||
{{ with .location.name }}{{ $title = printf "Adriano is in %s :: adriano.fyi" . }}{{ end }}
|
||||
{{ with .weather }}
|
||||
{{ $parts := slice }}
|
||||
{{ with .tempf }}{{ $parts = $parts | append (printf "%.0f°F" .) }}{{ end }}
|
||||
{{ with .humidity }}{{ $parts = $parts | append (printf "%.0f%% humidity" .) }}{{ end }}
|
||||
{{ with .windspeedmph }}{{ $parts = $parts | append (printf "wind %.1f mph" .) }}{{ end }}
|
||||
{{ $desc = delimit $parts ", " }}
|
||||
{{ end }}
|
||||
{{ $d := resources.GetRemote "https://jellybee.bison-lizard.ts.net/whereami" | transform.Unmarshal }}
|
||||
{{ $title := "Where Am I? :: adriano.fyi" }}
|
||||
{{ $desc := "" }}
|
||||
{{ with $d.location.name }}{{ $title = printf "Adriano is in %s :: adriano.fyi" . }}{{ end }}
|
||||
{{ with $d.weather }}
|
||||
{{ $parts := slice }}
|
||||
{{ with .tempf }}{{ $parts = $parts | append (printf "%.0f°F" .) }}{{ end }}
|
||||
{{ with .humidity }}{{ $parts = $parts | append (printf "%.0f%% humidity" .) }}{{ end }}
|
||||
{{ with .windspeedmph }}{{ $parts = $parts | append (printf "wind %.1f mph" .) }}{{ end }}
|
||||
{{ $desc = delimit $parts ", " }}
|
||||
{{ end }}
|
||||
<title>{{ $title }}</title>
|
||||
<meta property="og:title" content="{{ $title }}">
|
||||
{{ with $desc }}<meta property="og:description" content="{{ . }}">{{ end }}
|
||||
<meta property="og:url" content="https://adriano.fyi/whereami">
|
||||
<meta property="og:type" content="website">
|
||||
{{ catch }}
|
||||
<title>Where Am I? :: adriano.fyi</title>
|
||||
<meta property="og:title" content="Where Am I? :: adriano.fyi">
|
||||
<meta property="og:url" content="https://adriano.fyi/whereami">
|
||||
<meta property="og:type" content="website">
|
||||
{{ end }}
|
||||
<title>{{ $title }}</title>
|
||||
<meta property="og:title" content="{{ $title }}">
|
||||
{{ with $desc }}<meta property="og:description" content="{{ . }}">{{ end }}
|
||||
<meta property="og:url" content="https://adriano.fyi/whereami">
|
||||
<meta property="og:type" content="website">
|
||||
{{ end }}
|
||||
|
||||
{{ define "main" }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue