Skip to content

Commit f0add1f

Browse files
committed
Add OG image to root layout
1 parent de7accc commit f0add1f

4 files changed

Lines changed: 56 additions & 10 deletions

File tree

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Run `npx vercel env pull .env` to pull env variables from Vercel.
2-
# The project needs to be linked with `npx vercel link`.
3-
41
# Bluesky DID.
52
BLUESKY_DID=did
63

@@ -23,3 +20,6 @@ GITHUB_TOKEN=token
2320
# On Railway: `https://${{RAILWAY_PUBLIC_DOMAIN}}`.
2421
PUBLIC_URL_ORIGIN=origin
2522

23+
# API key to generate OG image links.
24+
VIRALCARDS_API_KEY=key
25+

src/lib/templates/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as ogImage } from './ogImage';

src/lib/templates/ogImage.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
export default {
2+
template: 'maiertechPost',
3+
title: 'Post title',
4+
avatarName: 'Thilo Maier',
5+
avatarImageUrl: 'https://www.maier.tech/assets/portrait-thilo-maier.jpg',
6+
height: 630,
7+
width: 1200,
8+
colors: {
9+
ink: '#020617',
10+
surface: '#f8fafc',
11+
primary: '#1e40af',
12+
accent: '#f97316'
13+
},
14+
fonts: [
15+
{
16+
name: 'Roboto',
17+
style: 'normal',
18+
weight: 300
19+
},
20+
{
21+
name: 'Roboto',
22+
style: 'normal',
23+
weight: 400
24+
},
25+
{
26+
name: 'Roboto',
27+
style: 'normal',
28+
weight: 500
29+
},
30+
{
31+
name: 'Roboto',
32+
style: 'normal',
33+
weight: 600
34+
},
35+
{
36+
name: 'Roboto',
37+
style: 'normal',
38+
weight: 700
39+
},
40+
{
41+
name: 'Roboto',
42+
style: 'normal',
43+
weight: 800
44+
}
45+
]
46+
};

src/routes/+layout.svelte

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<script lang="ts">
22
import { page } from '$app/state';
33
import { Favicon, Footer, Header } from '$lib/components';
4-
import { Container, PageLayout, SeoBasic } from '@maiertech/sveltekit-helpers';
5-
import type { Snippet } from 'svelte';
4+
import { Container, PageLayout, SeoBasic, SeoOgImage } from '@maiertech/sveltekit-helpers';
5+
import type { LayoutProps } from './$types';
66
77
import '@maiertech/sveltekit-helpers/themes/default.css'; // First import the theme, then the styles.
88
import '../app.css';
99
10-
interface Props {
11-
children: Snippet;
12-
}
13-
14-
let { children }: Props = $props();
10+
let { children }: LayoutProps = $props();
1511
</script>
1612

1713
{#if page.data.seo}
1814
<SeoBasic title={page.data.seo.title} description={page.data.seo.description} />
15+
<SeoOgImage
16+
ogImageUrl="https://create.viral.cards/api/v1/satori?meta=%7B%22template%22%3A%22maiertech%22%2C%22title%22%3A%22Notes+and+posts+about+web+development%22%2C%22avatarName%22%3A%22Thilo+Maier%22%2C%22avatarImageUrl%22%3A%22https%3A%2F%2Fwww.maier.tech%2Fassets%2Fportrait-thilo-maier.jpg%22%2C%22height%22%3A630%2C%22width%22%3A1200%2C%22colors%22%3A%7B%22ink%22%3A%22%23020617%22%2C%22surface%22%3A%22%23f8fafc%22%2C%22primary%22%3A%22%231e40af%22%2C%22accent%22%3A%22%23f97316%22%7D%2C%22fonts%22%3A%5B%7B%22name%22%3A%22Roboto%22%2C%22style%22%3A%22normal%22%2C%22weight%22%3A300%7D%2C%7B%22name%22%3A%22Roboto%22%2C%22style%22%3A%22normal%22%2C%22weight%22%3A400%7D%2C%7B%22name%22%3A%22Roboto%22%2C%22style%22%3A%22normal%22%2C%22weight%22%3A500%7D%2C%7B%22name%22%3A%22Roboto%22%2C%22style%22%3A%22normal%22%2C%22weight%22%3A600%7D%2C%7B%22name%22%3A%22Roboto%22%2C%22style%22%3A%22normal%22%2C%22weight%22%3A700%7D%2C%7B%22name%22%3A%22Roboto%22%2C%22style%22%3A%22normal%22%2C%22weight%22%3A800%7D%5D%7D&sig=da35c48eae40b4c66c48694f82384ed834f45ff76216c941ea42f7a5f8e8e865"
17+
/>
1918
{/if}
2019

2120
<Favicon />

0 commit comments

Comments
 (0)