Add model-specific social cards
Deploy production / deploy (push) Successful in 22s

This commit is contained in:
2026-08-22 22:56:05 -07:00
parent 02fbccf5bd
commit b12030aeb0
5 changed files with 47 additions and 11 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 KiB

+47 -11
View File
@@ -1,15 +1,48 @@
{% macro social_metadata(record, schema_type='WebPage', og_type='website', project=none) -%}
{% set site_url = 'https://www.labyricorn.com' %}
{% set canonical_url = site_url ~ record.url_path %}
{% set default_image_url = site_url ~ '/static/labyricorn-social-card.png' %}
{% set image_url = default_image_url %}
{% if record.social_image %}
{% if record.social_image.startswith('https://') %}
{% set image_url = record.social_image %}
{% elif record.social_image.startswith('/') %}
{% set image_url = site_url ~ record.social_image %}
{% set fallback_image_path = '/static/labyricorn-social-card.png' %}
{% set image_alt = 'Labyricorn — systems, ideas, infrastructure, built to evolve.' %}
{% if schema_type == 'Article' %}
{% set fallback_image_path = '/static/labyricorn-social-article.png' %}
{% set image_alt = 'Labyricorn Article // Analysis social card.' %}
{% elif schema_type == 'BlogPosting' %}
{% set fallback_image_path = '/static/labyricorn-social-blog.png' %}
{% set image_alt = 'Labyricorn Blog // Signal social card.' %}
{% elif schema_type == 'SoftwareSourceCode' %}
{% set fallback_image_path = '/static/labyricorn-social-project.png' %}
{% set image_alt = 'Labyricorn Project // System social card.' %}
{% elif schema_type == 'TechArticle' %}
{% set fallback_image_path = '/static/labyricorn-social-devlog.png' %}
{% set image_alt = 'Labyricorn Devlog // Build Log social card.' %}
{% endif %}
{% set image_url = site_url ~ fallback_image_path %}
{% set image_is_fallback = true %}
{% set image_reference = '' %}
{% if record.logo %}
{% set image_reference = record.logo|string %}
{% set image_alt = record.title ~ ' logo' %}
{% else %}
{% set rendered_body = record.body|string %}
{% if '<img ' in rendered_body and 'src="' in rendered_body.split('<img ', 1)[1] %}
{% set first_image_tag = rendered_body.split('<img ', 1)[1].split('>', 1)[0] %}
{% set image_reference = first_image_tag.split('src="', 1)[1].split('"', 1)[0]|replace('&amp;', '&')|trim %}
{% if 'alt="' in first_image_tag %}
{% set referenced_alt = first_image_tag.split('alt="', 1)[1].split('"', 1)[0]|replace('&amp;', '&')|striptags|trim %}
{% if referenced_alt %}{% set image_alt = referenced_alt %}{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if image_reference %}
{% set image_is_fallback = false %}
{% if image_reference.startswith('https://') or image_reference.startswith('http://') %}
{% set image_url = image_reference %}
{% elif image_reference.startswith('//') %}
{% set image_url = 'https:' ~ image_reference %}
{% elif image_reference.startswith('/') %}
{% set image_url = site_url ~ image_reference %}
{% else %}
{% set image_url = site_url ~ record.url_path ~ record.social_image %}
{% set image_url = site_url ~ record.url_path ~ image_reference %}
{% endif %}
{% endif %}
{% set social_title = record.title|default('Labyricorn', true)|striptags|trim %}
@@ -30,15 +63,17 @@
<meta property="og:site_name" content="Labyricorn">
<meta property="og:image" content="{{ image_url }}">
<meta property="og:image:secure_url" content="{{ image_url }}">
{% if image_is_fallback %}
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Labyricorn — systems, ideas, infrastructure, built to evolve.">
{% endif %}
<meta property="og:image:alt" content="{{ image_alt }}">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{{ social_title }}">
<meta name="twitter:description" content="{{ social_description }}">
<meta name="twitter:image" content="{{ image_url }}">
<meta name="twitter:image:alt" content="Labyricorn — systems, ideas, infrastructure, built to evolve.">
<meta name="twitter:image:alt" content="{{ image_alt }}">
{% if record.author %}<meta name="author" content="{{ record.author }}">{% endif %}
{% if og_type == 'article' and record.date %}<meta property="article:published_time" content="{{ record.date|dateformat('YYYY-MM-dd') }}">{% endif %}
{% if og_type == 'article' and record.updated %}<meta property="article:modified_time" content="{{ record.updated|dateformat('YYYY-MM-dd') }}">{% endif %}
@@ -56,9 +91,10 @@
},
"image": {
"@type": "ImageObject",
"url": {{ image_url|tojson }},
"url": {{ image_url|tojson }}{% if image_is_fallback %},
"width": 1200,
"height": 630
{% endif %}
},
"publisher": {
"@type": "Organization",