diff --git a/assets/static/labyricorn-social-article.png b/assets/static/labyricorn-social-article.png
new file mode 100644
index 0000000..190bb2f
Binary files /dev/null and b/assets/static/labyricorn-social-article.png differ
diff --git a/assets/static/labyricorn-social-blog.png b/assets/static/labyricorn-social-blog.png
new file mode 100644
index 0000000..78920b0
Binary files /dev/null and b/assets/static/labyricorn-social-blog.png differ
diff --git a/assets/static/labyricorn-social-devlog.png b/assets/static/labyricorn-social-devlog.png
new file mode 100644
index 0000000..cae01cd
Binary files /dev/null and b/assets/static/labyricorn-social-devlog.png differ
diff --git a/assets/static/labyricorn-social-project.png b/assets/static/labyricorn-social-project.png
new file mode 100644
index 0000000..2472b05
Binary files /dev/null and b/assets/static/labyricorn-social-project.png differ
diff --git a/templates/macros/social-sharing.html b/templates/macros/social-sharing.html
index 2f59818..b591e34 100644
--- a/templates/macros/social-sharing.html
+++ b/templates/macros/social-sharing.html
@@ -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 '
', 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 ~ 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 @@
+ {% 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 %}
@@ -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",