diff --git a/modules/templates/util_string.go b/modules/templates/util_string.go
index 459380aee53..18a0d5cacc9 100644
--- a/modules/templates/util_string.go
+++ b/modules/templates/util_string.go
@@ -33,6 +33,11 @@ func (su *StringUtils) Join(a []string, sep string) string {
return strings.Join(a, sep)
}
+func (su *StringUtils) Cut(s, sep string) []any {
+ before, after, found := strings.Cut(s, sep)
+ return []any{before, after, found}
+}
+
func (su *StringUtils) EllipsisString(s string, max int) string {
return base.EllipsisString(s, max)
}
diff --git a/templates/base/head_opengraph.tmpl b/templates/base/head_opengraph.tmpl
index fc3958b6b6d..19d924610cd 100644
--- a/templates/base/head_opengraph.tmpl
+++ b/templates/base/head_opengraph.tmpl
@@ -1,29 +1,34 @@
+{{- /* og:description - a one to two sentence description of your object, maybe it only needs at most 300 bytes */ -}}
{{if .PageIsUserProfile}}
{{if .ContextUser.Description}}
-
+
{{end}}
{{else if .Repository}}
{{if .Issue}}
{{if .Issue.Content}}
-
+
{{end}}
{{else if or .PageIsDiff .IsViewFile}}
- {{if and .PageIsDiff (IsMultilineCommitMessage .Commit.Message)}}
-
+ {{if .PageIsDiff}}
+ {{- $commitMessageParts := StringUtils.Cut .Commit.Message "\n" -}}
+ {{- $commitMessageBody := index $commitMessageParts 1 -}}
+ {{- if $commitMessageBody -}}
+
+ {{- end -}}
{{end}}
{{else}}
{{if .Repository.Description}}
-
+
{{end}}
{{end}}