feat: seo optimizations + opengraph embeds

fix: nullable AuthorUUIDs; assign admins member & mod role
This commit is contained in:
2026-01-06 16:26:47 -05:00
parent a7185d6a3d
commit 3bbd64631a
13 changed files with 288 additions and 14 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ fetch }) => {
export const load: PageServerLoad = async ({ fetch,url }) => {
try {
const res = await fetch('/api/paste/create/options');
const options = await res.json();
return { options };
return { options, url: url.href };
} catch {
return { options: null };
return { options: null, url: url.href };
}
};
@@ -90,6 +90,15 @@
}
</script>
<svelte:head>
<title>Create a Paste - Sharpbin</title>
<meta property="og:title" content="Create a Paste - Sharpbin" />
<meta property="og:description" content="Create and share your pastes easily with Sharpbin." />
<meta property="og:type" content="website" />
<meta property="og:url" content="{data.url}" />
<meta property="og:site_name" content="Sharpbin" />
</svelte:head>
<main
class="flex min-h-screen w-full flex-col items-center justify-center bg-neutral-950 text-white"
>
@@ -1,7 +1,7 @@
import type { PageServerLoad } from './$types';
import type { Paste } from '$lib/types/paste';
export const load: PageServerLoad = async ({ params, fetch }) => {
export const load: PageServerLoad = async ({ params, fetch, url }) => {
const { id } = params;
const paste = await fetch(`/api/paste/${id}`);
@@ -17,5 +17,5 @@ export const load: PageServerLoad = async ({ params, fetch }) => {
const options = await pasteOptions.json();
const content = await pasteContent.text();
return { paste: pasteData, content, options };
return { paste: pasteData, content, options, url: url.href };
};
@@ -282,6 +282,31 @@
$: if (data?.paste && (data.paste.visibility !== 2 || decryptedContent !== null)) renderCode();
</script>
<svelte:head>
<title>{data.paste ? (data.paste.title || 'Untitled Paste') + ' - Sharpbin' : 'Paste Not Found - Sharpbin'}</title>
{#if data.paste}
<meta property="og:title" content={data.paste.title || 'Untitled Paste'} />
<meta
property="og:description"
content={`A paste on Sharpbin created by ${
data.paste.author ? data.paste.author.username : 'Anonymous'
}, created on ${
extractDateFromUUIDv7(data.paste.uuid)?.toLocaleDateString() ?? 'Unknown Date'
}.`}
/>
<meta property="og:type" content="article" />
<meta property="og:url" content={data.url} />
<meta property="og:site_name" content="Sharpbin" />
<meta property="og:article:published_time" content={extractDateFromUUIDv7(data.paste.uuid)?.toISOString() ?? ''} />
{#if data.paste.editedAt}
<meta property="og:article:modified_time" content={new Date(data.paste.editedAt).toISOString()} />
{/if}
{#if data.paste.author}
<meta property="og:article:author" content={data.paste.author.username} />
{/if}
{/if}
</svelte:head>
<main
class="flex min-h-screen w-full flex-col items-center justify-center bg-neutral-950 text-white"
>
@@ -2,7 +2,7 @@ import type { PageServerLoad } from './$types';
import { getServerToken } from '$lib/utils/auth';
import type { User } from '$lib/types/user';
export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
export const load: PageServerLoad = async ({ params, fetch, cookies, url }) => {
const { username } = params;
const token = getServerToken(cookies);
const res = await fetch(`/api/user/${username}`, {
@@ -12,5 +12,5 @@ export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
});
const user = (await res.json()) as User;
return { user };
return { user, url: url.href };
};
@@ -113,6 +113,17 @@
}
</script>
<svelte:head>
<title>{data.user.displayName || data.user.username} - User Profile</title>
<meta property="og:title" content="{data.user.displayName || data.user.username} - User Profile" />
<meta property="og:description" content="View the profile and {pagination.totalCount} paste{pagination.totalCount !== 1 ? 's' : ''} of {data.user.displayName || data.user.username} on Sharpbin." />
<meta property="og:type" content="profile" />
<meta property="og:url" content="{data.url}" />
<meta property="og:site_name" content="Sharpbin" />
<meta property="profile:username" content="{data.user.username}" />
</svelte:head>
<main
class="flex min-h-screen w-full flex-col items-center justify-center bg-neutral-950 text-white"
>