0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-10 22:24:19 +01:00
Bootstrap/site/layouts/partials/social.html
XhmikosR b613cfb58b
docs: improve social image partial (#37717)
* Fix social image URL to be absolute

* Deduplicate social.html

* Get image dimensions with Hugo
2022-12-25 18:14:27 +02:00

28 lines
1.4 KiB
HTML

{{- $pageTitle := .Title | markdownify -}}
{{- $pageDescription := .Page.Params.description | default .Site.Params.description | markdownify -}}
{{- $socialImagePath := printf "/docs/%s/assets" .Site.Params.docs_version -}}
{{- if .Page.Params.thumbnail -}}
{{- $socialImagePath = path.Join $socialImagePath "img/" .Page.Params.thumbnail -}}
{{- else -}}
{{- $socialImagePath = path.Join $socialImagePath "brand/bootstrap-social.png" -}}
{{- end -}}
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@{{ .Site.Params.twitter }}">
<meta name="twitter:creator" content="@{{ .Site.Params.twitter }}">
<meta name="twitter:title" content="{{ $pageTitle }}">
<meta name="twitter:description" content="{{ $pageDescription }}">
<meta name="twitter:image" content="{{ $socialImagePath | absURL }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:title" content="{{ $pageTitle }}">
<meta property="og:description" content="{{ $pageDescription }}">
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
<meta property="og:image" content="{{ $socialImagePath | absURL }}">
<meta property="og:image:type" content="image/png">
{{ with (imageConfig (path.Join "site/static" $socialImagePath)) -}}
<meta property="og:image:width" content="{{ .Width }}">
<meta property="og:image:height" content="{{ .Height }}">
{{- end }}