Skip to content

Commit 4d623df

Browse files
committed
Set default OG image
1 parent f0add1f commit 4d623df

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/app.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ declare global {
1212
seo?: {
1313
title: string;
1414
description: string;
15+
ogImageUrl?: string;
1516
};
1617
}
1718
// interface PageState {}

src/routes/+layout.server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ import type { LayoutServerLoad } from './$types';
44
export const load: LayoutServerLoad = ({ url }) => {
55
// Make `urlOrigin` for `ResponsiveImage` component available to support prerendering.
66
const urlOrigin = PUBLIC_URL_ORIGIN || url.origin;
7-
return { urlOrigin };
7+
return {
8+
urlOrigin,
9+
defaultOgImageUrl:
10+
'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'
11+
};
812
};

src/routes/+layout.svelte

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
import '@maiertech/sveltekit-helpers/themes/default.css'; // First import the theme, then the styles.
88
import '../app.css';
99
10-
let { children }: LayoutProps = $props();
10+
let { data, children }: LayoutProps = $props();
1111
</script>
1212

1313
{#if page.data.seo}
1414
<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-
/>
15+
{#if page.data.seo.ogImageUrl}
16+
<SeoOgImage ogImageUrl={page.data.seo.ogImageUrl} />
17+
{:else}
18+
<SeoOgImage ogImageUrl={data.defaultOgImageUrl} />
19+
{/if}
1820
{/if}
1921

2022
<Favicon />

0 commit comments

Comments
 (0)