Feature: OG Social media cards
Not Original Gangsta, but ObjectGraph Reason: images were showing on LinkedIn, but small.
This commit is contained in:
@@ -12,6 +12,27 @@ defmodule FirehoseWeb.Layouts do
|
||||
|
||||
embed_templates "layouts/*"
|
||||
|
||||
@doc """
|
||||
Stores content in the connection for later rendering in layouts.
|
||||
|
||||
Used to inject dynamic meta tags into the `<head>` section.
|
||||
"""
|
||||
def put_content_for(conn, key, content) do
|
||||
content_for = Map.get(conn.assigns, :content_for, %{})
|
||||
new_content_for = Map.update(content_for, key, [content], &(&1 ++ [content]))
|
||||
Plug.Conn.assign(conn, :content_for, new_content_for)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Retrieves content stored via `put_content_for/3`.
|
||||
|
||||
Can be called from HEEx templates with `get_content_for(assigns, :meta_tags)`.
|
||||
"""
|
||||
def get_content_for(assigns, key) do
|
||||
content_for = assigns[:content_for]
|
||||
if is_map(content_for), do: Map.get(content_for, key, []), else: []
|
||||
end
|
||||
|
||||
@doc """
|
||||
Shows the flash group with standard titles and content.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user