forgejo/templates/base/head_opengraph.tmpl
2025-01-01 20:43:20 +01:00

37 lines
1.4 KiB
Go HTML Template

{{- /* See https://ogp.me for specification */ -}}
{{if .OpenGraphTitle}}
<meta property="og:title" content="{{.OpenGraphTitle}}">
{{else if .Title}}
<meta property="og:title" content="{{.Title}}">
{{else}}
<meta property="og:title" content="{{AppDisplayName}}">
{{end}}
{{- /* og:description - a one to two sentence description of your object, maybe it only needs at most 300 bytes */ -}}
{{if and .OpenGraphDescription (not .OpenGraphNoDescription)}}
<meta property="og:description" content="{{StringUtils.EllipsisString .OpenGraphDescription 300}}">
{{end}}
{{if .OpenGraphURL}}
<meta property="og:url" content="{{.OpenGraphURL}}">
{{else}}
<meta property="og:url" content="{{AppUrl}}{{.Link}}">
{{end}}
{{if .OpenGraphType}}
<meta property="og:type" content="{{.OpenGraphType}}">
{{else}}
<meta property="og:type" content="website">
{{end}}
{{if .OpenGraphImageURL}}
<meta property="og:image" content="{{.OpenGraphImageURL}}">
{{if .OpenGraphImageWidth}}
<meta property="og:image:width" content="{{.OpenGraphImageWidth}}">
{{end}}
{{if .OpenGraphImageHeight}}
<meta property="og:image:height" content="{{.OpenGraphImageHeight}}">
{{end}}
{{if .OpenGraphImageAltText}}
<meta property="og:image:alt" content="{{.OpenGraphImageAltText}}">
{{end}}
{{else}}
<meta property="og:image" content="{{AssetUrlPrefix}}/img/logo.png">
{{end}}
<meta property="og:site_name" content="{{AppDisplayName}}">