First version of webring with simple landing page and control functions.

This commit is contained in:
DS 2024-09-27 16:34:11 -07:00
commit 554960fbef
22 changed files with 3621 additions and 0 deletions

8
functions/next.ts Normal file
View file

@ -0,0 +1,8 @@
import { next } from '../src/webring';
export const onRequestGet: PagesFunction = async (context) => {
const id = new URL(context.request.url).searchParams.get('id') ?? 'main';
const item = next(id);
const url = item?.url ?? new URL(context.request.url).origin;
return Response.redirect(url, 303);
};

8
functions/previous.ts Normal file
View file

@ -0,0 +1,8 @@
import { previous } from '../src/webring';
export const onRequestGet: PagesFunction = async (context) => {
const id = new URL(context.request.url).searchParams.get('id') ?? 'main';
const item = previous(id);
const url = item?.url ?? new URL(context.request.url).origin;
return Response.redirect(url, 303);
};

6
functions/random.ts Normal file
View file

@ -0,0 +1,6 @@
import { randomEntry } from '../src/webring';
export const onRequestGet: PagesFunction = async (context) => {
const url = randomEntry()?.url ?? new URL(context.request.url).origin;
return Response.redirect(url, 303);
};