johnandersen777.bsky.social/knotless
git that lives in your Atmosphere account
Forked from chadtmiller.com/knotless
0
0
import type * as getFeed from '#lib/lexicons/dev/knotless/getFeed.ts';
import type { Kind } from '#lib/feed.ts';
import type { PageLoad } from './$types';
import { redirect } from '@sveltejs/kit';
import { KINDS } from '#lib/feed.ts';
import { xrpc } from '#lib/data.ts';
/**
* What happened: to someone logged in, what those they follow did, unless
* they ask for everyone's; only the kind asked for, if one is; none,
* without an index. A search asked of the front page, as it once took
* them, is on its own page now.
*/
export const load: PageLoad = async (event) => {
if (event.url.searchParams.has('q')) redirect(308, `/search${event.url.search}`);
const { viewer } = await event.parent();
const asked = event.url.searchParams;
const following = !!viewer?.actor && asked.get('feed') !== 'everyone';
const kind = KINDS.find(([k]) => k === asked.get('kind'))?.[0] ?? null;
const params = {
...(following ? ({ filter: 'following' } as const) : {}),
...(kind ? { kind } : {})
};
const feed = await xrpc<typeof getFeed.main>(event, 'dev.knotless.getFeed', params, true);
return { feed, following, kind: kind as Kind | null, signedIn: !!viewer?.actor };
};