mirror of
https://github.com/writeas/writefreely
synced 2025-02-03 10:57:32 +01:00
Use avatar as blog link social media image
This commit is contained in:
parent
c996ae1cad
commit
561568343a
@ -264,12 +264,11 @@ func (c *Collection) PersonObject(ids ...int64) *activitystreams.Person {
|
||||
p.Name = c.DisplayTitle()
|
||||
p.Summary = c.Description
|
||||
if p.Name != "" {
|
||||
fl := string(unicode.ToLower([]rune(p.Name)[0]))
|
||||
if isLowerLetter(fl) {
|
||||
if av := c.AvatarURL(); av != "" {
|
||||
p.Icon = activitystreams.Image{
|
||||
Type: "Image",
|
||||
MediaType: "image/png",
|
||||
URL: hostName + "/img/avatars/" + fl + ".png",
|
||||
URL: av,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -287,6 +286,14 @@ func (c *Collection) PersonObject(ids ...int64) *activitystreams.Person {
|
||||
return p
|
||||
}
|
||||
|
||||
func (c *Collection) AvatarURL() string {
|
||||
fl := string(unicode.ToLower([]rune(c.DisplayTitle())[0]))
|
||||
if !isLowerLetter(fl) {
|
||||
return ""
|
||||
}
|
||||
return hostName + "/img/avatars/" + fl + ".png"
|
||||
}
|
||||
|
||||
func (c *Collection) FederatedAPIBase() string {
|
||||
return hostName + "/"
|
||||
}
|
||||
|
@ -20,14 +20,14 @@
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:description" content="{{.Summary}}">
|
||||
<meta name="twitter:title" content="{{.PlainDisplayTitle}} — {{if .Collection.Title}}{{.Collection.Title}}{{else}}{{.Collection.Alias}}{{end}}">
|
||||
{{if gt (len .Images) 0}}<meta name="twitter:image" content="{{index .Images 0}}">{{else}}<meta name="twitter:image" content="https://write.as/img/w-sq-light.png">{{end}}
|
||||
{{if gt (len .Images) 0}}<meta name="twitter:image" content="{{index .Images 0}}">{{else}}<meta name="twitter:image" content="{{.Collection.AvatarURL}}">{{end}}
|
||||
<meta property="og:title" content="{{.PlainDisplayTitle}}" />
|
||||
<meta property="og:description" content="{{.Summary}}" />
|
||||
<meta property="og:site_name" content="{{.Collection.DisplayTitle}}" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content="{{.CanonicalURL}}" />
|
||||
<meta property="og:updated_time" content="{{.Created8601}}" />
|
||||
{{range .Images}}<meta property="og:image" content="{{.}}" />{{else}}<meta property="og:image" content="https://write.as/img/w-sq-light.png">{{end}}
|
||||
{{range .Images}}<meta property="og:image" content="{{.}}" />{{else}}<meta property="og:image" content="{{.Collection.AvatarURL}}">{{end}}
|
||||
<meta property="article:published_time" content="{{.Created8601}}">
|
||||
{{if .Collection.StyleSheet}}<style type="text/css">{{.Collection.StyleSheetDisplay}}</style>{{end}}
|
||||
{{if .Collection.RenderMathJax}}
|
||||
|
@ -23,10 +23,12 @@
|
||||
<meta name="twitter:site" content="@writeas__">
|
||||
<meta name="twitter:description" content="{{.Tag}} posts on {{.Collection.DisplayTitle}}">
|
||||
<meta name="twitter:title" content="{{.Tag}} — {{.Collection.DisplayTitle}}">
|
||||
<meta name="twitter:image" content="{{.Collection.AvatarURL}}">
|
||||
<meta property="og:title" content="{{.Tag}} — {{.Collection.DisplayTitle}}" />
|
||||
<meta property="og:site_name" content="{{.DisplayTitle}}" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content="{{.CanonicalURL}}tag:{{.Tag}}" />
|
||||
<meta property="og:image" content="{{.Collection.AvatarURL}}">
|
||||
{{if .Collection.StyleSheet}}<style type="text/css">{{.Collection.StyleSheetDisplay}}</style>{{end}}
|
||||
{{if .Collection.RenderMathJax}}
|
||||
<script type="text/x-mathjax-config">
|
||||
|
@ -19,12 +19,14 @@
|
||||
<meta itemprop="description" content="{{.Description}}">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="{{.DisplayTitle}}">
|
||||
<meta name="twitter:image" content="{{.AvatarURL}}">
|
||||
<meta name="twitter:description" content="{{.Description}}">
|
||||
<meta property="og:title" content="{{.DisplayTitle}}" />
|
||||
<meta property="og:site_name" content="{{.DisplayTitle}}" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content="{{.CanonicalURL}}" />
|
||||
<meta property="og:description" content="{{.Description}}" />
|
||||
<meta property="og:image" content="{{.AvatarURL}}">
|
||||
{{if .StyleSheet}}<style type="text/css">{{.StyleSheetDisplay}}</style>{{end}}
|
||||
{{if .RenderMathJax}}
|
||||
<script type="text/x-mathjax-config">
|
||||
|
Loading…
x
Reference in New Issue
Block a user