feat: dynamic media page og images

This commit is contained in:
Cory Dransfeldt 2024-05-20 09:10:37 -07:00
parent bc03c708a6
commit 00440c24d9
No known key found for this signature in database
29 changed files with 46 additions and 9 deletions

View file

@ -8,6 +8,21 @@
{{ meta.siteName }}
{% endif %}
{%- endcapture -%}
{%- capture ogImage -%}
{% if schema == 'blog' %}
{{ meta.url }}/assets/img/ogi/{{ title | slugifyString }}-preview.png
{% elsif schema == 'music' %}
{{ music.recent.artists[0].image }}
{% elsif schema == 'watching' %}
{%- assign featuredMovie = movies.recentlyWatched | first -%}
{{ featuredMovie.backdrop }}
{% elsif schema == 'books' %}
{%- assign featuredBook = books | bookStatus: 'started' | reverse | first -%}
{{ featuredBook.image }}
{% else %}
{{ meta.meta_data.opengraph_default }}
{% endif %}
{%- endcapture -%}
<!doctype html>
<html lang="en">
<head>
@ -23,10 +38,7 @@
<meta property="og:description" content="{% if description %}{{ description }}{% else %}{{ meta.siteDescription }}{% endif %}" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{{ fullUrl }}" />
<meta
property="og:image"
content="{%- if schema == 'blog' %}{{ meta.url }}/assets/img/ogi/{{ title | slugifyString }}-preview.png{%- else -%}{{ meta.meta_data.opengraph_default }}{% endif -%}"
/>
<meta property="og:image" content="{{ ogImage }}" />
<meta name="theme-color" content="{{ meta.themeColor }}" />
<meta name="generator" content="Eleventy">
<meta name="robots" content="noai, noimageai">
@ -111,4 +123,4 @@
</script>
{{ content }}
</body>
</html>
</html>