refactor: ♻️ move data up in the data cascade
In order for og-image generation to not generate broken previews the flow of data needs to be handled differently. This also makes metadata generation more predictable.
This commit is contained in:
parent
ddbad1d1a2
commit
d2a9ec7936
6 changed files with 26 additions and 40 deletions
4
src/data/eleventyComputed.js
Normal file
4
src/data/eleventyComputed.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
export default {
|
||||
page_title: (data) => (data.title ? `${data.title} - ${data.site_name}` : data.site_name),
|
||||
og_title: (data) => (data.title ? data.title : data.site_name)
|
||||
};
|
|
@ -1,18 +1,5 @@
|
|||
{
|
||||
"layout": "blogpost.njk",
|
||||
"permalink": "/drafts/{{ title | slugify }}/",
|
||||
"date": "git Created",
|
||||
"type": "article",
|
||||
"author": {
|
||||
"name": "Sebin Nyshkim",
|
||||
"href": "https://blog.sebin-nyshkim.net",
|
||||
"image": "https://img.sebin-nyshkim.net/i/b6629b72-ab77-4a6c-bf97-b1a615cc2454"
|
||||
},
|
||||
"twitter": {
|
||||
"cardType": "summary_large_image",
|
||||
"account": "SebinNyshkim"
|
||||
},
|
||||
"mastodon": {
|
||||
"fediverseCreator": "@SebinNyshkim@meow.social"
|
||||
}
|
||||
"date": "git Created"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
title: Home
|
||||
layout: page.njk
|
||||
eleventyNavigation:
|
||||
key: home
|
||||
|
|
|
@ -2,16 +2,17 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
{% metagen
|
||||
title = title + ' - Sebin\'s Blog',
|
||||
title = page_title,
|
||||
desc = page.excerpt | toPlain,
|
||||
url = 'https://blog.sebin-nyshkim.net' + page.url,
|
||||
type = type,
|
||||
site_name = 'Sebin\'s Blog',
|
||||
og_title = title,
|
||||
site_name = site_name,
|
||||
og_title = og_title,
|
||||
og_image_width = image.width,
|
||||
og_image_height = image.height,
|
||||
og_image_alt = image.alt,
|
||||
og_image_type = 'image/webp',
|
||||
twitter_title = og_title,
|
||||
twitter_card_type = twitter.cardType,
|
||||
name = author.name,
|
||||
generator = eleventy.generator,
|
||||
|
@ -23,7 +24,7 @@
|
|||
'/css/style.css',
|
||||
'/css/prism.css']
|
||||
%}
|
||||
{% ogImage "og-image.og.njk", { title: title, author: author, image: image } %}
|
||||
{% ogImage "og-image.og.njk", { title: title or site_name, author: author, image: image } %}
|
||||
{% if mastodon.fediverseCreator and mastodon.fediverseCreator != '' %}
|
||||
<meta name="fediverse:creator" content="{{ mastodon.fediverseCreator }}" />
|
||||
{% endif %}
|
||||
|
@ -36,7 +37,7 @@
|
|||
<div class="flex min-h-16 max-w-(--breakpoint-xl) items-center justify-center bg-sky-600 shadow-xl sm:m-4 sm:mx-auto sm:justify-between sm:rounded-xl dark:bg-sky-950">
|
||||
<div class="hidden sm:flex sm:items-center">
|
||||
<img src="https://img.sebin-nyshkim.net/i/b6629b72-ab77-4a6c-bf97-b1a615cc2454" alt="" class="m-4 max-w-12 rounded-full border-4 border-white shadow-2xl lg:m-5 lg:max-w-14">
|
||||
<h1 class="text-2xl text-white lg:text-3xl">Sebin's Blog</h1>
|
||||
<h1 class="text-2xl text-white lg:text-3xl">{{ site_name }}</h1>
|
||||
</div>
|
||||
<nav class="eleventy-navigation" aria-label="Main">
|
||||
{{
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
{
|
||||
"layout": "blogpost.njk",
|
||||
"permalink": "/posts/{{ title | slugify }}/",
|
||||
"date": "git Created",
|
||||
"type": "article",
|
||||
"image": {
|
||||
"width": 1200,
|
||||
"height": 630
|
||||
},
|
||||
"author": {
|
||||
"name": "Sebin Nyshkim",
|
||||
"href": "https://blog.sebin-nyshkim.net",
|
||||
"image": "https://img.sebin-nyshkim.net/i/b6629b72-ab77-4a6c-bf97-b1a615cc2454"
|
||||
},
|
||||
"twitter": {
|
||||
"cardType": "summary_large_image"
|
||||
},
|
||||
"mastodon": {
|
||||
"fediverseCreator": "@SebinNyshkim@meow.social"
|
||||
}
|
||||
"date": "git Created"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue