Extract opengraph code into partial
All checks were successful
/ deploy (push) Successful in 31s
/ test (push) Successful in 1m17s

This commit is contained in:
Ral 2024-06-16 19:06:33 +02:00
parent 4bef75a8fc
commit 852c06e55b
2 changed files with 15 additions and 17 deletions

View file

@ -9,23 +9,7 @@
{{ $style := resources.Get "/sass/custom.css" | resources.ToCSS $options | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}"/>
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="{{ .Site.Title }}"/>
<meta property="og:title" content="{{ .Title }}"/>
<meta property="og:url" content="{{ .Permalink | absURL }}"/>
{{ $logoFile := printf "images/ogp/cosin_icon_%s.png" (string .Site.Data.cosin.date_year) }}
{{ $logo := "" }}
{{ with resources.Get $logoFile }}
{{ $logo = . }}
{{ else }}
{{ $logo = resources.Get "images/ogp/cosin_icon_generic.png" }}
{{ end }}
<meta property="og:image" content="{{ $logo.Permalink }}"/>
<meta property="og:image:type" content="{{ $logo.MediaType }}"/>
<meta property="og:image:width" content="{{ $logo.Width }}"/>
<meta property="og:image:height" content="{{ $logo.Height }}"/>
<meta property="og:image:alt" content="CoSin Icon {{ string .Site.Data.cosin.date_year }}"/>
{{ partial "opengraph.html" .}}
</head>
<body>

View file

@ -0,0 +1,14 @@
{{ $fileName := printf "images/ogp/cosin_icon_%s.png" (string .Site.Data.cosin.date_year) }}
{{ $logo := or (resources.Get $fileName) (resources.Get "images/ogp/cosin_icon_generic.png") }}
<meta property="og:type" content="website"/>
<meta property="og:site_name" content="{{ .Site.Title }}"/>
<meta property="og:title" content="{{ .Title }}"/>
<meta property="og:url" content="{{ .Permalink | absURL }}"/>
{{ with $logo }}
<meta property="og:image" content="{{ .Permalink }}"/>
<meta property="og:image:type" content="{{ .MediaType }}"/>
<meta property="og:image:width" content="{{ .Width }}"/>
<meta property="og:image:height" content="{{ .Height }}"/>
<meta property="og:image:alt" content="CoSin Icon {{ string $.Site.Data.cosin.date_year }}"/>
{{ end }}