attachments = build_attachments(id, object)
scrubbed_content = Utils.scrub_html_and_truncate(object)
# Zero width space
attachments = build_attachments(id, object)
scrubbed_content = Utils.scrub_html_and_truncate(object)
# Zero width space
- {:meta,
- [
- property: "twitter:title",
- content: Utils.user_name_string(user)
- ], []},
- {:meta,
- [
- property: "twitter:description",
- content: content
- ], []}
+ title_tag(user),
+ {:meta, [property: "twitter:description", content: content], []}
- {:meta,
- [property: "twitter:image", content: Utils.attachment_url(User.avatar_url(user))], []},
- {:meta, [property: "twitter:card", content: "summary_large_image"], []}
+ image_tag(user),
+ {:meta, [property: "twitter:card", content: "summary"], []}
def build_tags(%{user: user}) do
with truncated_bio = Utils.scrub_html_and_truncate(user.bio || "") do
[
def build_tags(%{user: user}) do
with truncated_bio = Utils.scrub_html_and_truncate(user.bio || "") do
[
{:meta, [property: "twitter:description", content: truncated_bio], []},
{:meta, [property: "twitter:description", content: truncated_bio], []},
{:meta, [property: "twitter:card", content: "summary"], []}
]
end
end
{:meta, [property: "twitter:card", content: "summary"], []}
]
end
end
+ defp title_tag(user) do
+ {:meta, [property: "twitter:title", content: Utils.user_name_string(user)], []}
+ end
+
+ def image_tag(user) do
+ {:meta, [property: "twitter:image", content: Utils.attachment_url(User.avatar_url(user))], []}
+ end
+
defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
Enum.reduce(attachments, [], fn attachment, acc ->
rendered_tags =
Enum.reduce(attachment["url"], [], fn url, acc ->
defp build_attachments(id, %{data: %{"attachment" => attachments}}) do
Enum.reduce(attachments, [], fn attachment, acc ->
rendered_tags =
Enum.reduce(attachment["url"], [], fn url, acc ->
"audio" ->
[
{:meta, [property: "twitter:card", content: "player"], []},
"audio" ->
[
{:meta, [property: "twitter:card", content: "player"], []},
"video" ->
[
{:meta, [property: "twitter:card", content: "player"], []},
"video" ->
[
{:meta, [property: "twitter:card", content: "player"], []},