Add rich social sharing support
Deploy production / deploy (push) Successful in 22s

This commit is contained in:
2026-08-22 20:29:40 -07:00
parent feff0577ad
commit 1d9dd212bf
8 changed files with 277 additions and 4 deletions
+4 -2
View File
@@ -1,19 +1,21 @@
<!doctype html>
{% from "macros/social-sharing.html" import social_metadata with context %}
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="{{ this.summary|default('Labyricorn developer devlog and project hub')|striptags }}">
<title>{% if this._path != '/' %}{{ this.title }} — {% endif %}Labyricorn</title>
{% block social_head %}{{ social_metadata(this) }}{% endblock %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@400;500&family=Playfair+Display:ital,wght@0,600;0,700;1,500;1,600&display=swap" rel="stylesheet">
<link rel="icon" href="{{ '/static/favicon.svg'|url }}" type="image/svg+xml">
<link rel="stylesheet" href="{{ '/static/style.css'|url }}?v=15">
<link rel="stylesheet" href="{{ '/static/style.css'|url }}?v=16">
<script src="{{ '/static/tags.js'|url }}?v=1" defer></script>
<script src="{{ '/static/activity.js'|url }}?v=1" defer></script>
<script src="{{ '/static/hero-circuit.js'|url }}?v=2" defer></script>
<script src="{{ '/static/narration.js'|url }}?v=1" defer></script>
<script src="{{ '/static/social-share.js'|url }}?v=1" defer></script>
</head>
<body>
<header class="site-header">
+7
View File
@@ -1,5 +1,10 @@
{% extends "base.html" %}
{% from "macros/tag-links.html" import taxonomy_labels with context %}
{% from "macros/social-sharing.html" import social_metadata, share_controls with context %}
{% block social_head %}
{% set social_project = this.parent.parent %}
{{ social_metadata(this, 'TechArticle', 'article', social_project) }}
{% endblock %}
{% block body %}
{% set project = this.parent.parent %}
{% set siblings = this.get_siblings() %}
@@ -28,6 +33,8 @@
{{ this.body }}
</div>
{{ share_controls(this, 'development note', project) }}
<nav class="devlog-navigation" aria-label="Development log chronology">
{% if siblings.prev_page %}
<a class="devlog-navigation-link" href="{{ siblings.prev_page|url }}"><span>← Older entry</span><strong>{{ siblings.prev_page.title }}</strong></a>
+7
View File
@@ -1,6 +1,10 @@
{% extends "base.html" %}
{% from "macros/tag-links.html" import tag_links with context %}
{% from "macros/narration-player.html" import narration_player with context %}
{% from "macros/social-sharing.html" import social_metadata, share_controls with context %}
{% block social_head %}
{% if this.parent._id == 'blog' %}{{ social_metadata(this, 'BlogPosting', 'article') }}{% else %}{{ social_metadata(this, 'Article', 'article') }}{% endif %}
{% endblock %}
{% block body %}
{% if this.parent._id == 'blog' %}
<article class="blog-post-layout shell">
@@ -37,6 +41,7 @@
{{ this.body }}
{% if this.external_url %}<p><a class="button-link" href="{{ this.external_url }}">Visit project →</a></p>{% endif %}
</div>
{{ share_controls(this, 'post') }}
</article>
{% elif this.parent._id == 'articles' %}
{% set article_word_count = this.body|striptags|wordcount %}
@@ -105,6 +110,7 @@
{{ this.body }}
{% if this.external_url %}<p><a class="button-link" href="{{ this.external_url }}">Visit project →</a></p>{% endif %}
</div>
{{ share_controls(this, 'article') }}
</article>
{% else %}
<article>
@@ -119,6 +125,7 @@
<div class="shell prose">
{{ this.body }}
{% if this.external_url %}<p><a class="button-link" href="{{ this.external_url }}">Visit project →</a></p>{% endif %}
{{ share_controls(this, 'page') }}
</div>
</section>
</article>
+145
View File
@@ -0,0 +1,145 @@
{% 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 %}
{% else %}
{% set image_url = site_url ~ record.url_path ~ record.social_image %}
{% 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 %}
<meta name="description" content="{{ social_description }}">
<link rel="canonical" href="{{ canonical_url }}">
<meta property="og:title" content="{{ social_title }}">
<meta property="og:description" content="{{ social_description }}">
<meta property="og:url" content="{{ canonical_url }}">
<meta property="og:type" content="{{ og_type }}">
<meta property="og:site_name" content="Labyricorn">
<meta property="og:image" content="{{ image_url }}">
<meta property="og:image:secure_url" content="{{ image_url }}">
<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.">
<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.">
{% 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 %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": {{ schema_type|tojson }},
"name": {{ social_title|tojson }},
"headline": {{ social_title|tojson }},
"description": {{ social_description|tojson }},
"url": {{ canonical_url|tojson }},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": {{ canonical_url|tojson }}
},
"image": {
"@type": "ImageObject",
"url": {{ image_url|tojson }},
"width": 1200,
"height": 630
},
"publisher": {
"@type": "Organization",
"name": "Labyricorn",
"url": "https://www.labyricorn.com/"
},
"isAccessibleForFree": true
{% if record.author %},
"author": {
"@type": "Person",
"name": {{ record.author|tojson }}
}
{% endif %}
{% if schema_type in ['Article', 'BlogPosting', 'TechArticle'] and record.date %},
"datePublished": {{ record.date|dateformat('YYYY-MM-dd')|tojson }}
{% endif %}
{% if schema_type in ['Article', 'BlogPosting'] and record.updated %},
"dateModified": {{ record.updated|dateformat('YYYY-MM-dd')|tojson }}
{% endif %}
{% if schema_type in ['Article', 'BlogPosting'] and record.tags %},
"keywords": {{ record.tags|join(', ')|tojson }}
{% endif %}
{% if schema_type == 'TechArticle' and project %},
"articleSection": {{ (project.title ~ ' development log')|tojson }},
"isPartOf": {
"@type": "CreativeWork",
"name": {{ project.title|tojson }},
"url": {{ (site_url ~ project.url_path)|tojson }}
},
"about": {
"@type": "SoftwareSourceCode",
"name": {{ project.title|tojson }},
"url": {{ (site_url ~ project.url_path)|tojson }},
"codeRepository": {{ project.repository_url|string|tojson }}
}
{% if record.topic_tags %},
"keywords": {{ record.topic_tags|join(', ')|tojson }}
{% endif %}
{% endif %}
{% if schema_type == 'SoftwareSourceCode' %},
"codeRepository": {{ record.repository_url|string|tojson }},
"sameAs": {{ record.repository_url|string|tojson }},
"creativeWorkStatus": {{ record.status|capitalize|tojson }}
{% if record.started %},
"dateCreated": {{ record.started|dateformat('YYYY-MM-dd')|tojson }}
{% endif %}
{% if record.repository_languages %},
"programmingLanguage": [
{% for language in record.repository_languages %}{{ language|tojson }}{% if not loop.last %},{% endif %}{% endfor %}
]
{% endif %}
{% if record.repository_latest_release %},
"version": {{ record.repository_latest_release|tojson }}
{% endif %}
{% if record.repository_license %},
"license": {{ record.repository_license|tojson }}
{% endif %}
{% endif %}
}
</script>
{%- 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 %}
<aside class="share-panel" aria-labelledby="share-heading" data-share-component data-share-url="{{ canonical_url }}" data-share-title="{{ share_title }}" data-share-description="{{ share_description }}">
<div class="share-panel-heading">
<p class="share-kicker">Share</p>
<h2 id="share-heading">Send this {{ content_kind }}</h2>
</div>
<div class="share-actions">
<a class="share-action share-action-primary" href="{{ canonical_url }}" data-share-native aria-label="Share {{ share_title }}">Share</a>
<a class="share-action" href="https://www.facebook.com/sharer/sharer.php?u={{ canonical_url|urlencode }}" target="_blank" rel="noopener noreferrer" aria-label="Share {{ share_title }} on Facebook">Facebook</a>
<a class="share-action" href="https://www.linkedin.com/sharing/share-offsite/?url={{ canonical_url|urlencode }}" target="_blank" rel="noopener noreferrer" aria-label="Share {{ share_title }} on LinkedIn">LinkedIn</a>
<a class="share-action" href="https://www.reddit.com/submit?url={{ canonical_url|urlencode }}&amp;title={{ share_title|urlencode }}" target="_blank" rel="noopener noreferrer" aria-label="Share {{ share_title }} on Reddit">Reddit</a>
<a class="share-action" href="https://bsky.app/intent/compose?text={{ bluesky_text|urlencode }}" target="_blank" rel="noopener noreferrer" aria-label="Share {{ share_title }} on Bluesky">Bluesky</a>
<a class="share-action" href="{{ canonical_url }}" data-share-copy aria-label="Copy the link to {{ share_title }}">Copy Link</a>
</div>
<p class="share-status" data-share-status role="status" aria-live="polite"></p>
</aside>
{%- endmacro %}
+3
View File
@@ -1,5 +1,7 @@
{% extends "base.html" %}
{% from "macros/tag-links.html" import tag_links, taxonomy_labels with context %}
{% from "macros/social-sharing.html" import social_metadata, share_controls with context %}
{% block social_head %}{{ social_metadata(this, 'SoftwareSourceCode', 'website') }}{% endblock %}
{% block body %}
{% set devlog = site.get(this.path ~ '/devlog') %}
<article class="project-page">
@@ -70,6 +72,7 @@
</div>
</dl>
</aside>
{{ share_controls(this, 'project') }}
</div>
{% if this.technology_labels %}