|
| 1 | +{{- /* og:description - a one to two sentence description of your object, maybe it only needs at most 300 bytes */ -}} |
1 | 2 | {{if .PageIsUserProfile}}
|
2 | 3 | <meta property="og:title" content="{{.ContextUser.DisplayName}}">
|
3 | 4 | <meta property="og:type" content="profile">
|
4 | 5 | <meta property="og:image" content="{{.ContextUser.AvatarLink ctx}}">
|
5 | 6 | <meta property="og:url" content="{{.ContextUser.HTMLURL}}">
|
6 | 7 | {{if .ContextUser.Description}}
|
7 |
| - <meta property="og:description" content="{{.ContextUser.Description}}"> |
| 8 | + <meta property="og:description" content="{{StringUtils.EllipsisString .ContextUser.Description 300}}"> |
8 | 9 | {{end}}
|
9 | 10 | {{else if .Repository}}
|
10 | 11 | {{if .Issue}}
|
11 | 12 | <meta property="og:title" content="{{.Issue.Title}}">
|
12 | 13 | <meta property="og:url" content="{{.Issue.HTMLURL}}">
|
13 | 14 | {{if .Issue.Content}}
|
14 |
| - <meta property="og:description" content="{{.Issue.Content}}"> |
| 15 | + <meta property="og:description" content="{{StringUtils.EllipsisString .Issue.Content 300}}"> |
15 | 16 | {{end}}
|
16 | 17 | {{else if or .PageIsDiff .IsViewFile}}
|
17 | 18 | <meta property="og:title" content="{{.Title}}">
|
18 | 19 | <meta property="og:url" content="{{AppUrl}}{{.Link}}">
|
19 |
| - {{if and .PageIsDiff (IsMultilineCommitMessage .Commit.Message)}} |
20 |
| - <meta property="og:description" content="{{RenderCommitBody $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}"> |
| 20 | + {{if .PageIsDiff}} |
| 21 | + {{- $commitMessageParts := StringUtils.Cut .Commit.Message "\n" -}} |
| 22 | + {{- $commitMessageBody := index $commitMessageParts 1 -}} |
| 23 | + {{- if $commitMessageBody -}} |
| 24 | + <meta property="og:description" content="{{StringUtils.EllipsisString $commitMessageBody 300}}"> |
| 25 | + {{- end -}} |
21 | 26 | {{end}}
|
22 | 27 | {{else}}
|
23 | 28 | <meta property="og:title" content="{{.Repository.Name}}">
|
24 | 29 | <meta property="og:url" content="{{.Repository.HTMLURL}}">
|
25 | 30 | {{if .Repository.Description}}
|
26 |
| - <meta property="og:description" content="{{.Repository.Description}}"> |
| 31 | + <meta property="og:description" content="{{StringUtils.EllipsisString .Repository.Description 300}}"> |
27 | 32 | {{end}}
|
28 | 33 | {{end}}
|
29 | 34 | <meta property="og:type" content="object">
|
|
0 commit comments