feat: improve recent page; improve SEO for pages

This commit is contained in:
2026-01-20 17:10:09 -05:00
parent 3895bd9681
commit 3a5738b531
3 changed files with 106 additions and 12 deletions
@@ -81,6 +81,11 @@
} }
</script> </script>
<svelte:head>
<title>Login - Sharpbin</title>
<meta name="description" content="Login to your Sharpbin account to manage your pastes and settings." />
</svelte:head>
<main <main
class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white" class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
> >
@@ -1,10 +1,35 @@
<script lang="ts"> <script lang="ts">
import type { PageData } from './$types'; import type { PageData } from './$types';
import { extractDateFromUUIDv7, dateToRelativeString } from '$lib/utils/misc'; import {
extractDateFromUUIDv7,
dateToRelativeString,
tooltip,
formatNumber,
formatBytes
} from '$lib/utils/misc';
import { resolve } from '$app/paths'; import { resolve } from '$app/paths';
import { Eye, FileBox, Code, User, History, Calendar, Timer } from '@lucide/svelte';
import { onMount } from 'svelte';
import { syntaxes } from '$lib/consts';
export let data: PageData; export let data: PageData;
$: now = new Date();
onMount(() => {
const interval = setInterval(() => {
now = new Date();
}, 1000);
return () => clearInterval(interval);
});
</script> </script>
<svelte:head>
<title>Recent Pastes - Sharpbin</title>
<meta name="description" content="Browse the most recent pastes shared on Sharpbin." />
</svelte:head>
<main <main
class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white" class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
> >
@@ -16,24 +41,80 @@
<div class="grid grid-cols-1 gap-4"> <div class="grid grid-cols-1 gap-4">
{#each data.recentPastes as paste} {#each data.recentPastes as paste}
{@const createdAt = extractDateFromUUIDv7(paste.uuid)} {@const createdAt = extractDateFromUUIDv7(paste.uuid)}
{@const isExpired = paste.expiresAt > 0 && paste.expiresAt < Date.now()}
{@const syntax = syntaxes[paste.syntax] ?? syntaxes['plaintext']}
<a <a
href={resolve(`/${paste.id}`)} href={resolve(`/${paste.id}`)}
class="flex flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none" class="flex flex-col gap-2 rounded border border-neutral-700 bg-neutral-800 px-5 py-4 transition-colors duration-200 hover:bg-neutral-700 focus:ring-2 focus:ring-neutral-600 focus:outline-none"
> >
<span class="truncate text-lg font-semibold text-neutral-100 hover:text-white"> <span
class="w-fit truncate text-lg font-semibold text-neutral-100 hover:text-white"
use:tooltip={paste.title || 'Untitled Paste'}
>
{paste.title || 'Untitled Paste'} {paste.title || 'Untitled Paste'}
</span> </span>
<p class="text-sm text-neutral-400"> <div class="flex flex-row justify-between">
{#if createdAt} <div>
{#if createdAt.getTime() > Date.now() - 86_400_000} <div
Created {dateToRelativeString(createdAt)} class="flex items-center gap-2 text-sm text-neutral-400"
{:else} use:tooltip={`${createdAt?.toLocaleString()}\n${dateToRelativeString(createdAt ?? new Date(), true, false, now)}`}
Created on {createdAt.toLocaleDateString()} >
<Calendar class="h-4 w-4" />
<span>
{#if createdAt}
{#if createdAt.getTime() > Date.now() - 86_400_000}
Created {dateToRelativeString(createdAt, true, false, now)}
{:else}
Created on {createdAt.toLocaleDateString()}
{/if}
{:else}
Creation date unknown
{/if}
</span>
</div>
{#if paste.expiresAt > 0}
<div
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
use:tooltip={new Date(paste.expiresAt).toLocaleString()}
>
<Timer class="h-4 w-4" />
<span>
{isExpired
? `Expired ${dateToRelativeString(new Date(paste.expiresAt), true, false, now)}`
: `Expires in ${dateToRelativeString(new Date(paste.expiresAt), true, false, now)}`}
</span>
</div>
{/if} {/if}
{:else} <div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
Creation date unknown <User class="h-4 w-4" />
{/if} <span>{paste.author?.username ?? 'Anonymous'}</span>
</p> </div>
{#if paste.editedAt}
<div
class="mt-1 flex items-center gap-2 text-sm text-neutral-400"
use:tooltip={new Date(paste.editedAt).toLocaleString()}
>
<History class="h-4 w-4" />
<span>Edited {dateToRelativeString(new Date(paste.editedAt), true, false, now)}</span>
</div>
{/if}
</div>
<div>
<div class="flex items-center gap-2 text-sm text-neutral-400">
<Eye class="h-4 w-4" />
<span>{formatNumber(paste.views)} View{paste.views !== 1 ? 's' : ''}</span>
</div>
<div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
<FileBox class="h-4 w-4" />
<span>{formatBytes(paste.size)}</span>
</div>
<div class="mt-1 flex items-center gap-2 text-sm text-neutral-400">
<Code class="h-4 w-4" />
<span>{syntax.name}</span>
</div>
</div>
</div>
</a> </a>
{/each} {/each}
</div> </div>
@@ -116,6 +116,14 @@
} }
</script> </script>
<svelte:head>
<title>Register - Sharpbin</title>
<meta
name="description"
content="Create a new Sharpbin account to manage your pastes and settings."
/>
</svelte:head>
<main <main
class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white" class="flex min-h-[calc(100vh-120px)] w-full flex-col items-center justify-center pt-5 pb-5 text-white"
> >