mirror of
https://github.com/andwati/andwati.com.git
synced 2026-11-30 04:08:46 +00:00
Auto-generate per-post OG images
Renders a 1200x630 social card per post (satori + resvg-js, using the site's own self-hosted fonts) instead of reusing one generic og-image.png for every post. Wired into npm run build via a new generate:og step; templates/page.html falls back to the per-slug image unless extra.image is set, and non-post pages keep the generic fallback.
This commit is contained in:
+3
-3
@@ -9,7 +9,7 @@
|
||||
{% block og_description %}{{ page.description | default(value=config.description) }}{% endblock og_description %}
|
||||
{% block og_url %}{{ page.permalink }}{% endblock og_url %}
|
||||
{% block og_type %}{% if "posts/_index.md" in page.ancestors %}article{% else %}website{% endif %}{% endblock og_type %}
|
||||
{% block og_image %}{{ config.base_url }}{{ page.extra.image | default(value="/images/og-image.png") }}{% endblock og_image %}
|
||||
{% block og_image %}{{ config.base_url }}{% if page.extra.image %}{{ page.extra.image }}{% elif "posts/_index.md" in page.ancestors %}/images/og/{{ page.slug }}.png{% else %}/images/og-image.png{% endif %}{% endblock og_image %}
|
||||
{% block og_extra %}
|
||||
{% if "posts/_index.md" in page.ancestors %}
|
||||
{% if page.date %}<meta property="article:published_time" content="{{ page.date | date(format="%Y-%m-%dT%H:%M:%S%:z") }}">{% endif %}
|
||||
@@ -26,7 +26,7 @@
|
||||
{# Twitter Card overrides #}
|
||||
{% block twitter_title %}{{ page.title }}{% endblock twitter_title %}
|
||||
{% block twitter_description %}{{ page.description | default(value=config.description) }}{% endblock twitter_description %}
|
||||
{% block twitter_image %}{{ config.base_url }}{{ page.extra.image | default(value="/images/og-image.png") }}{% endblock twitter_image %}
|
||||
{% block twitter_image %}{{ config.base_url }}{% if page.extra.image %}{{ page.extra.image }}{% elif "posts/_index.md" in page.ancestors %}/images/og/{{ page.slug }}.png{% else %}/images/og-image.png{% endif %}{% endblock twitter_image %}
|
||||
|
||||
{% block head %}
|
||||
{% if "posts/_index.md" in page.ancestors %}
|
||||
@@ -42,7 +42,7 @@
|
||||
},
|
||||
"headline": {{ page.title | json_encode | safe }},
|
||||
"description": {% if page.description %}{{ page.description | json_encode | safe }}{% else %}{{ config.description | json_encode | safe }}{% endif %},
|
||||
"image": "{{ config.base_url | safe }}{% if page.extra.image %}{{ page.extra.image | safe }}{% else %}/images/og-image.png{% endif %}",
|
||||
"image": "{{ config.base_url | safe }}{% if page.extra.image %}{{ page.extra.image | safe }}{% elif "posts/_index.md" in page.ancestors %}/images/og/{{ page.slug | safe }}.png{% else %}/images/og-image.png{% endif %}",
|
||||
"url": "{{ page.permalink | safe }}",
|
||||
"inLanguage": "en-US",
|
||||
{% if page.date %}"datePublished": "{{ page.date | date(format="%Y-%m-%dT%H:%M:%S%:z") }}",{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user