2020-07-09 17:24:28 +02:00
|
|
|
defimpl Mobilizon.Service.Metadata, for: Mobilizon.Discussions.Comment do
|
2019-03-04 17:20:18 +01:00
|
|
|
alias Phoenix.HTML.Tag
|
2022-10-31 13:00:45 +01:00
|
|
|
alias Mobilizon.Actors.Actor
|
2020-07-09 17:24:28 +02:00
|
|
|
alias Mobilizon.Discussions.Comment
|
2022-10-31 13:00:45 +01:00
|
|
|
import Mobilizon.Service.Metadata.Utils, only: [escape_text: 1]
|
2019-03-04 17:20:18 +01:00
|
|
|
|
2021-09-10 11:30:12 +02:00
|
|
|
@spec build_tags(Comment.t(), String.t()) :: list(Phoenix.HTML.safe())
|
|
|
|
def build_tags(%Comment{deleted_at: nil} = comment, _locale) do
|
2019-03-04 17:20:18 +01:00
|
|
|
[
|
2023-08-17 13:18:01 +02:00
|
|
|
Tag.tag(:meta,
|
|
|
|
property: "og:title",
|
|
|
|
content: escape_text(Actor.display_name(comment.actor))
|
|
|
|
),
|
2019-03-04 17:20:18 +01:00
|
|
|
Tag.tag(:meta, property: "og:url", content: comment.url),
|
|
|
|
Tag.tag(:meta, property: "og:description", content: comment.text),
|
|
|
|
Tag.tag(:meta, property: "og:type", content: "website"),
|
|
|
|
Tag.tag(:meta, property: "twitter:card", content: "summary")
|
|
|
|
]
|
|
|
|
end
|
2021-09-10 11:30:12 +02:00
|
|
|
|
|
|
|
def build_tags(%Comment{} = _comment, _locale), do: []
|
2019-03-04 17:20:18 +01:00
|
|
|
end
|