Feature: OG Social media cards

Not Original Gangsta, but ObjectGraph

Reason: images were showing on LinkedIn, but small.
This commit is contained in:
2026-05-10 21:34:07 +01:00
parent 764585c642
commit 061787e897
13 changed files with 300 additions and 105 deletions
+2
View File
@@ -28,6 +28,7 @@ defmodule Blogex.Post do
:description,
:date,
:blog,
:image,
tags: [],
published: true
]
@@ -39,6 +40,7 @@ defmodule Blogex.Post do
body: String.t(),
description: String.t(),
date: Date.t(),
image: String.t() | nil,
tags: [String.t()],
blog: atom(),
published: boolean()
+23
View File
@@ -3,11 +3,33 @@ defmodule Blogex.SEO do
SEO helpers for generating meta tags and sitemaps.
"""
@doc """
Returns a map of meta tag attributes for a blog listing page.
Useful for setting OpenGraph and Twitter card tags on blog index pages.
<meta property="og:title" content={@meta.og_title} />
"""
def meta_tags_for_blog(blog_module, base_url) do
url = "#{base_url}#{blog_module.base_path()}"
%{
title: blog_module.title(),
description: blog_module.description(),
og_title: blog_module.title(),
og_description: blog_module.description(),
og_type: "website",
og_url: url,
og_image: nil,
twitter_card: "summary"
}
end
@doc """
Returns a map of meta tag attributes for a post.
Useful for setting OpenGraph and Twitter card tags in your layout.
<meta property="og:title" content={@meta.og_title} />
<meta property="og:image" content={@meta.og_image} />
"""
def meta_tags(post, base_url, blog_module) do
url = "#{base_url}#{blog_module.base_path()}/#{post.id}"
@@ -19,6 +41,7 @@ defmodule Blogex.SEO do
og_description: post.description,
og_type: "article",
og_url: url,
og_image: if(post.image, do: "#{base_url}#{post.image}", else: nil),
article_published_time: Date.to_iso8601(post.date),
article_author: post.author,
article_tags: post.tags,