diff options
author | Daniel Baumann <daniel@debian.org> | 2024-10-18 20:33:49 +0200 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2024-12-12 23:57:56 +0100 |
commit | e68b9d00a6e05b3a941f63ffb696f91e554ac5ec (patch) | |
tree | 97775d6c13b0f416af55314eb6a89ef792474615 /templates/base/head_opengraph.tmpl | |
parent | Initial commit. (diff) | |
download | forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.tar.xz forgejo-e68b9d00a6e05b3a941f63ffb696f91e554ac5ec.zip |
Adding upstream version 9.0.3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'templates/base/head_opengraph.tmpl')
-rw-r--r-- | templates/base/head_opengraph.tmpl | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/templates/base/head_opengraph.tmpl b/templates/base/head_opengraph.tmpl new file mode 100644 index 0000000..292c3bd --- /dev/null +++ b/templates/base/head_opengraph.tmpl @@ -0,0 +1,53 @@ +{{- /* og:description - a one to two sentence description of your object, maybe it only needs at most 300 bytes */ -}} +{{if .PageIsUserProfile}} + <meta property="og:title" content="{{.ContextUser.DisplayName}}"> + <meta property="og:type" content="profile"> + <meta property="og:image" content="{{.ContextUser.AvatarLink ctx}}"> + <meta property="og:url" content="{{.ContextUser.HTMLURL}}"> + {{if .ContextUser.Description}} + <meta property="og:description" content="{{StringUtils.EllipsisString .ContextUser.Description 300}}"> + {{end}} +{{else if .Repository}} + {{if .Issue}} + <meta property="og:title" content="{{.Issue.Title}}"> + <meta property="og:url" content="{{.Issue.HTMLURL}}"> + {{if .Issue.Content}} + <meta property="og:description" content="{{StringUtils.EllipsisString .Issue.Content 300}}"> + {{end}} + {{else if or .PageIsDiff .IsViewFile}} + <meta property="og:title" content="{{.Title}}"> + <meta property="og:url" content="{{AppUrl}}{{.Link}}"> + {{if and .PageIsDiff .Commit}} + {{- $commitMessageParts := StringUtils.Cut .Commit.Message "\n" -}} + {{- $commitMessageBody := index $commitMessageParts 1 -}} + {{- if $commitMessageBody -}} + <meta property="og:description" content="{{StringUtils.EllipsisString $commitMessageBody 300}}"> + {{- end -}} + {{end}} + {{else if .Pages}} + <meta property="og:title" content="{{.Title}}"> + <meta property="og:url" content="{{AppUrl}}{{.Link}}"> + {{if .Repository.Description}} + <meta property="og:description" content="{{StringUtils.EllipsisString .Repository.Description 300}}"> + {{end}} + {{else}} + <meta property="og:title" content="{{.Repository.Name}}"> + <meta property="og:url" content="{{.Repository.HTMLURL}}"> + {{if .Repository.Description}} + <meta property="og:description" content="{{StringUtils.EllipsisString .Repository.Description 300}}"> + {{end}} + {{end}} + <meta property="og:type" content="object"> + {{if (.Repository.AvatarLink ctx)}} + <meta property="og:image" content="{{.Repository.AvatarLink ctx}}"> + {{else}} + <meta property="og:image" content="{{.Repository.Owner.AvatarLink ctx}}"> + {{end}} +{{else}} + <meta property="og:title" content="{{AppDisplayName}}"> + <meta property="og:type" content="website"> + <meta property="og:image" content="{{AssetUrlPrefix}}/img/logo.png"> + <meta property="og:url" content="{{AppUrl}}"> + <meta property="og:description" content="{{MetaDescription}}"> +{{end}} +<meta property="og:site_name" content="{{AppDisplayName}}"> |