Skip to content

Commit e3c57d2

Browse files
committed
add open graph support, twitter cards, update source link in footer
1 parent a992d24 commit e3c57d2

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/content.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const blog = defineCollection({
99
date: z.coerce.date(),
1010
tags: z.array(z.string()).optional().default([]),
1111
draft: z.boolean().optional().default(false),
12+
image: z.string().optional(),
1213
}),
1314
});
1415

src/layouts/Base.astro

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import '../styles/global.css';
44
interface Props {
55
title?: string;
66
description?: string;
7+
image?: string;
78
}
89
9-
const { title, description } = Astro.props;
10+
const { title, description, image } = Astro.props;
1011
1112
const siteName = 'beparano.id';
1213
const siteDescription = 'Personal website of Ryodari — Berlin.';
1314
const pageTitle = title ? `${title} — ${siteName}` : siteName;
1415
const pageDescription = description ?? siteDescription;
16+
const ogImage = new URL(image ?? '/images/avatar.JPEG', Astro.site).toString();
1517
1618
const navItems = [
1719
{ label: 'Blog', href: '/blog' },
@@ -41,6 +43,20 @@ const currentPath = Astro.url.pathname;
4143
<link rel="manifest" href="/site.webmanifest" />
4244

4345
<link rel="alternate" type="application/rss+xml" title="beparano.id" href="/rss.xml" />
46+
47+
<!-- Open Graph -->
48+
<meta property="og:title" content={pageTitle} />
49+
<meta property="og:description" content={pageDescription} />
50+
<meta property="og:url" content={`https://beparano.id${currentPath}`} />
51+
<meta property="og:site_name" content={siteName} />
52+
<meta property="og:image" content={ogImage} />
53+
<meta property="og:type" content="website" />
54+
55+
<!-- Twitter/X -->
56+
<meta name="twitter:card" content="summary" />
57+
<meta name="twitter:title" content={pageTitle} />
58+
<meta name="twitter:description" content={pageDescription} />
59+
<meta name="twitter:image" content={ogImage} />
4460
</head>
4561

4662
<body class="bg-paper text-ink flex flex-col min-h-screen">
@@ -82,7 +98,7 @@ const currentPath = Astro.url.pathname;
8298
<span{new Date().getFullYear()} Ryodari</span>
8399
<div class="flex gap-4">
84100
<a
85-
href="https://github.com/ryodari/beparano.id"
101+
href="https://github.com/ryodari/ryodari.github.io"
86102
target="_blank"
87103
rel="noopener noreferrer"
88104
class="hover:text-ink transition-colors no-underline"

src/layouts/BlogPost.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Props {
77
}
88
99
const { post } = Astro.props;
10-
const { title, description, date, tags } = post.data;
10+
const { title, description, date, tags, image } = post.data;
1111
1212
const formattedDate = new Intl.DateTimeFormat('en-US', {
1313
year: 'numeric',
@@ -16,7 +16,7 @@ const formattedDate = new Intl.DateTimeFormat('en-US', {
1616
}).format(date);
1717
---
1818

19-
<Base title={title} description={description}>
19+
<Base title={title} description={description} image={image}>
2020
<article>
2121
<header class="mb-10">
2222
<div class="flex items-center gap-2 text-sm text-ink-tertiary mb-3 font-mono">

0 commit comments

Comments
 (0)