{% 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 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 '
', 1)[0] %}
{% set image_reference = first_image_tag.split('src="', 1)[1].split('"', 1)[0]|replace('&', '&')|trim %}
{% if 'alt="' in first_image_tag %}
{% set referenced_alt = first_image_tag.split('alt="', 1)[1].split('"', 1)[0]|replace('&', '&')|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 ~ image_reference %}
{% endif %}
{% endif %}
{% set social_title = record.title|default('Labyricorn', true)|striptags|trim %}
{% set base_description = record.summary|default('Labyricorn developer devlog and project hub', true)|striptags|trim %}
{% set social_description = base_description|truncate(220, true, '…') %}
{% if schema_type == 'TechArticle' and project %}
{% set social_title = record.title ~ ' — ' ~ project.title ~ ' Devlog' %}
{% set social_description = (project.title ~ ' devlog — ' ~ base_description)|truncate(220, true, '…') %}
{% elif schema_type == 'SoftwareSourceCode' and record.status %}
{% set social_description = (base_description ~ ' Status: ' ~ (record.status|capitalize) ~ '.')|truncate(220, true, '…') %}
{% endif %}
{% if image_is_fallback %}
{% endif %}
{% if record.author %}{% endif %}
{% if og_type == 'article' and record.date %}{% endif %}
{% if og_type == 'article' and record.updated %}{% endif %}
{%- endmacro %}
{% macro share_controls(record, content_kind='page', project=none) -%}
{% set canonical_url = 'https://www.labyricorn.com' ~ record.url_path %}
{% set share_title = record.title|striptags|trim %}
{% if project %}{% set share_title = project.title ~ ' devlog: ' ~ record.title %}{% endif %}
{% set share_description = record.summary|default('', true)|striptags|trim|truncate(180, true, '…') %}
{% set bluesky_text = (share_title|truncate(210, true, '…')) ~ ' ' ~ canonical_url %}
{%- endmacro %}