~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/knotless

git that lives in your Atmosphere account

Forked from chadtmiller.com/knotless

0
0
24 lines · 1.0 KB Raw History
import type * as listSteps from '#lib/lexicons/dev/knotless/listSteps.ts';
import type { PageLoad } from './$types';
import { xrpc } from '#lib/data.ts';
import { repoUri } from '#lib/steps.ts';

/**
 * The shared steps the index has found, by name: everyone's, or one
 * repository's (`repo`, as `handle/name`), those whose name starts with
 * `q` if given; none, without an index.
 */
export const load: PageLoad = async (event) => {
	const params = event.url.searchParams;
	const q = (params.get('q') ?? '').trim();
	const [owner, name] = (params.get('repo') ?? '').split('/');
	const repo = owner && name ? { owner, name } : undefined;
	const asked = {
		q: q || undefined,
		repo: repo ? repoUri(repo.owner, repo.name) : undefined,
		cursor: params.get('cursor') ?? undefined
	};
	const found = await xrpc<typeof listSteps.main>(event, 'dev.knotless.listSteps', asked, true);
	// One repository not found has none, as one with none does.
	return { q, repo, steps: found ?? { steps: [] }, indexed: found !== null || repo !== undefined };
};