mirror of
https://github.com/usememos/memos.git
synced 2025-02-21 05:40:57 +01:00
chore: update memo metadata
This commit is contained in:
parent
24672e0c5e
commit
56b55ad941
@ -80,9 +80,6 @@ func (s *FrontendService) registerRoutes(e *echo.Echo) {
|
|||||||
if memo == nil {
|
if memo == nil {
|
||||||
return c.HTML(http.StatusOK, rawIndexHTML)
|
return c.HTML(http.StatusOK, rawIndexHTML)
|
||||||
}
|
}
|
||||||
if memo.Visibility != store.Public {
|
|
||||||
return c.HTML(http.StatusOK, rawIndexHTML)
|
|
||||||
}
|
|
||||||
creator, err := s.Store.GetUser(ctx, &store.FindUser{
|
creator, err := s.Store.GetUser(ctx, &store.FindUser{
|
||||||
ID: &memo.CreatorID,
|
ID: &memo.CreatorID,
|
||||||
})
|
})
|
||||||
@ -97,15 +94,21 @@ func (s *FrontendService) registerRoutes(e *echo.Echo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateMemoMetadata(memo *store.Memo, creator *store.User) string {
|
func generateMemoMetadata(memo *store.Memo, creator *store.User) string {
|
||||||
|
description := memo.Content
|
||||||
|
if memo.Visibility == store.Private {
|
||||||
|
description = "This memo is private."
|
||||||
|
} else if memo.Visibility == store.Protected {
|
||||||
|
description = "This memo is protected."
|
||||||
|
}
|
||||||
metadataList := []string{
|
metadataList := []string{
|
||||||
fmt.Sprintf(`<meta name="description" content="%s" />`, memo.Content),
|
fmt.Sprintf(`<meta name="description" content="%s" />`, description),
|
||||||
fmt.Sprintf(`<meta property="og:title" content="%s" />`, fmt.Sprintf("%s(@%s) on Memos", creator.Nickname, creator.Username)),
|
fmt.Sprintf(`<meta property="og:title" content="%s" />`, fmt.Sprintf("%s(@%s) on Memos", creator.Nickname, creator.Username)),
|
||||||
fmt.Sprintf(`<meta property="og:description" content="%s" />`, memo.Content),
|
fmt.Sprintf(`<meta property="og:description" content="%s" />`, description),
|
||||||
fmt.Sprintf(`<meta property="og:image" content="%s" />`, "https://www.usememos.com/logo.png"),
|
fmt.Sprintf(`<meta property="og:image" content="%s" />`, "https://www.usememos.com/logo.png"),
|
||||||
`<meta property="og:type" content="website" />`,
|
`<meta property="og:type" content="website" />`,
|
||||||
// Twitter related metadata.
|
// Twitter related metadata.
|
||||||
fmt.Sprintf(`<meta name="twitter:title" content="%s" />`, fmt.Sprintf("%s(@%s) on Memos", creator.Nickname, creator.Username)),
|
fmt.Sprintf(`<meta name="twitter:title" content="%s" />`, fmt.Sprintf("%s(@%s) on Memos", creator.Nickname, creator.Username)),
|
||||||
fmt.Sprintf(`<meta name="twitter:description" content="%s" />`, memo.Content),
|
fmt.Sprintf(`<meta name="twitter:description" content="%s" />`, description),
|
||||||
fmt.Sprintf(`<meta name="twitter:image" content="%s" />`, "https://www.usememos.com/logo.png"),
|
fmt.Sprintf(`<meta name="twitter:image" content="%s" />`, "https://www.usememos.com/logo.png"),
|
||||||
`<meta name="twitter:card" content="summary" />`,
|
`<meta name="twitter:card" content="summary" />`,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user