import { h } from "../jsx.ts"; import watt, { Story, watt as originalWatt } from "../wattpad.ts"; import wattpad, { User } from "../wattpad.ts"; import { Context } from "../oak.ts"; import Base from "../templates/Base.tsx"; import FourOhFour from "./404.tsx"; export default async (params: URLSearchParams, ctx: Context) => { const name = params.get("name"); const chapterNumber = Number(params.get("page")) ?? 0; if (!name) { throw "deez"; } const user = new User(originalWatt.session, name); try { await user.init(); await user.updateStories(chapterNumber); } catch { return FourOhFour(undefined, ctx); } const res: Story[] = []; for (let i = 0; i < user.stories.length; i++) { const rizz = await watt.getStory(user.stories[i].id, false); res.push(

{rizz.name}

{rizz.storyJSON.description}

); } return (

{user.displayName === "" ? user.username : user.displayName}

{user.displayName === "" ? undefined : user.username}
Followers: {user.userJSON.numFollowers ?? 0}
Following: {user.userJSON.numFollowing ?? 0}

{user.description ? user.description.replaceAll("\n", "
") : undefined}

{res.join("")}
); };