diff --git a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/_lib/page-data.tsx b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/_lib/page-data.tsx index 04347167..783f7834 100644 --- a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/_lib/page-data.tsx +++ b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/_lib/page-data.tsx @@ -7,12 +7,9 @@ import { import { getPost } from "@/lib/data/db/post"; import { notFound } from "next/navigation"; -export type CommentPageParams = { - commentRkey: string; - postRkey: string; - postAuthor: string; - commentAuthor: string; -}; +export type CommentPageParams = Awaited< + PageProps<"/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]">["params"] +>; export async function getCommentPageData(params: CommentPageParams) { const [postAuthorDid, commentAuthorDid] = await Promise.all([ diff --git a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/og-image/route.tsx b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/og-image/route.tsx index 86f86150..bf4bc88c 100644 --- a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/og-image/route.tsx +++ b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/og-image/route.tsx @@ -8,7 +8,7 @@ import { OgWrapper, frontpageOgImageResponse, } from "@/lib/og"; -import { type CommentPageParams, getCommentPageData } from "../_lib/page-data"; +import { getCommentPageData } from "../_lib/page-data"; import { getBlueskyProfile } from "@/lib/data/user"; import { shouldHideComment } from "@/lib/data/db/comment"; import { notFound } from "next/navigation"; @@ -19,7 +19,9 @@ export const revalidate = 3600; // 1 hour export async function GET( _req: Request, - { params }: { params: Promise }, + { + params, + }: RouteContext<"/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/og-image">, ) { const { comment } = await getCommentPageData(await params); if ((await shouldHideComment(comment)) || comment.status !== "live") { diff --git a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/page.tsx b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/page.tsx index 13ed167f..3934bb26 100644 --- a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/page.tsx +++ b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]/page.tsx @@ -17,9 +17,9 @@ function getPagePath(params: CommentPageParams) { return `/post/${params.postAuthor}/${params.postRkey}/${params.commentAuthor}/${params.commentRkey}`; } -export async function generateMetadata(props: { - params: Promise; -}): Promise { +export async function generateMetadata( + props: PageProps<"/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]">, +): Promise { const params = await props.params; const { comment, post } = await getCommentPageData(params); @@ -56,9 +56,9 @@ export async function generateMetadata(props: { }; } -export default async function CommentPage(props: { - params: Promise; -}) { +export default async function CommentPage( + props: PageProps<"/post/[postAuthor]/[postRkey]/[commentAuthor]/[commentRkey]">, +) { const params = await props.params; const { comment, post } = await getCommentPageData(params); diff --git a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/_lib/page-data.tsx b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/_lib/page-data.tsx index 55feb38c..1ed61c10 100644 --- a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/_lib/page-data.tsx +++ b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/_lib/page-data.tsx @@ -3,10 +3,9 @@ import { getDidFromHandleOrDid } from "@/lib/data/atproto/identity"; import { getPost } from "@/lib/data/db/post"; import { notFound } from "next/navigation"; -export type PostPageParams = { - postAuthor: string; - postRkey: string; -}; +export type PostPageParams = Awaited< + PageProps<"/post/[postAuthor]/[postRkey]">["params"] +>; export async function getPostPageData(params: PostPageParams) { const authorDid = await getDidFromHandleOrDid(params.postAuthor); diff --git a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/layout.tsx b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/layout.tsx index 556d00e3..297ef6cd 100644 --- a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/layout.tsx +++ b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/layout.tsx @@ -8,15 +8,9 @@ import { Spinner } from "@/lib/components/ui/spinner"; import { NewComment } from "./_lib/comment-client"; import { SuperHackyScrollToTop } from "./scroller"; -type Params = { - postRkey: string; - postAuthor: string; -}; - -export default async function PostLayout(props: { - children: React.ReactNode; - params: Promise; -}) { +export default async function PostLayout( + props: LayoutProps<"/post/[postAuthor]/[postRkey]">, +) { const params = await props.params; const { children } = props; diff --git a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/og-image/route.tsx b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/og-image/route.tsx index b8948d13..aa62acb2 100644 --- a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/og-image/route.tsx +++ b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/og-image/route.tsx @@ -12,17 +12,12 @@ import { } from "@/lib/og"; import { getPostPageData } from "../_lib/page-data"; -type Params = { - postRkey: string; - postAuthor: string; -}; - export const dynamic = "force-static"; export const revalidate = 3600; // 1 hour export async function GET( _req: Request, - { params }: { params: Promise }, + { params }: RouteContext<"/post/[postAuthor]/[postRkey]/og-image">, ) { const { post } = await getPostPageData(await params); const profile = await getBlueskyProfile(post.authorDid); diff --git a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/page.tsx b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/page.tsx index 8ad5694e..0a8efe16 100644 --- a/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/page.tsx +++ b/packages/frontpage/app/(app)/post/[postAuthor]/[postRkey]/page.tsx @@ -10,9 +10,9 @@ function getPagePath(params: PostPageParams) { return `/post/${params.postAuthor}/${params.postRkey}`; } -export async function generateMetadata(props: { - params: Promise; -}): Promise { +export async function generateMetadata( + props: PageProps<"/post/[postAuthor]/[postRkey]">, +): Promise { const params = await props.params; const { post } = await getPostPageData(params); @@ -41,9 +41,9 @@ export async function generateMetadata(props: { }; } -export default async function PostPage(props: { - params: Promise; -}) { +export default async function PostPage( + props: PageProps<"/post/[postAuthor]/[postRkey]">, +) { const params = await props.params; const { post, authorDid } = await getPostPageData(params); const comments = await getCommentsForPost(post.id); diff --git a/packages/frontpage/app/(app)/post/new/page.tsx b/packages/frontpage/app/(app)/post/new/page.tsx index 4ff07dc6..0492f152 100644 --- a/packages/frontpage/app/(app)/post/new/page.tsx +++ b/packages/frontpage/app/(app)/post/new/page.tsx @@ -6,19 +6,23 @@ export const metadata: Metadata = { robots: "noindex, nofollow", }; -export default async function NewPost(props: { - searchParams: Promise>; -}) { +export default async function NewPost(props: PageProps<"/post/new">) { const searchParams = await props.searchParams; + const defaultTitle = + typeof searchParams.title === "string" + ? searchParams.title + : searchParams.title?.[0]; + + const defaultUrl = + typeof searchParams.url === "string" + ? searchParams.url + : searchParams.url?.[0]; return (

New post

- +
); } diff --git a/packages/frontpage/app/(app)/profile/[user]/page.tsx b/packages/frontpage/app/(app)/profile/[user]/page.tsx index 47212094..95799163 100644 --- a/packages/frontpage/app/(app)/profile/[user]/page.tsx +++ b/packages/frontpage/app/(app)/profile/[user]/page.tsx @@ -24,13 +24,9 @@ import { reportUserAction } from "@/lib/components/user-hover-card"; import { type Metadata } from "next"; import { LinkAlternateAtUri } from "@/lib/components/link-alternate-at"; -type Params = { - user: string; -}; - -export async function generateMetadata(props: { - params: Promise; -}): Promise { +export async function generateMetadata( + props: PageProps<"/profile/[user]">, +): Promise { const params = await props.params; const did = await getDidFromHandleOrDid(params.user); if (!did) { @@ -57,7 +53,7 @@ export async function generateMetadata(props: { }; } -export default async function Profile(props: { params: Promise }) { +export default async function Profile(props: PageProps<"/profile/[user]">) { await connection(); const params = await props.params; const did = await getDidFromHandleOrDid(params.user); diff --git a/packages/frontpage/app/(auth)/login/page.tsx b/packages/frontpage/app/(auth)/login/page.tsx index f8c39e00..2e816484 100644 --- a/packages/frontpage/app/(auth)/login/page.tsx +++ b/packages/frontpage/app/(auth)/login/page.tsx @@ -4,11 +4,7 @@ import { getUser } from "@/lib/data/user"; import { Alert, AlertDescription, AlertTitle } from "@/lib/components/ui/alert"; import { CrossCircledIcon } from "@radix-ui/react-icons"; -export default async function LoginPage({ - searchParams, -}: { - searchParams: Promise<{ error?: string }>; -}) { +export default async function LoginPage({ searchParams }: PageProps<"/login">) { const user = await getUser(); if (user !== null) { diff --git a/packages/frontpage/package.json b/packages/frontpage/package.json index 1286fade..66f869c7 100644 --- a/packages/frontpage/package.json +++ b/packages/frontpage/package.json @@ -8,6 +8,7 @@ "build-1pw": "NODE_OPTIONS=--use-openssl-ca op run --env-file=\"./.env.1pw\" -- next build", "build": "NODE_OPTIONS=--use-openssl-ca next build --turbopack", "start": "NODE_OPTIONS=--use-openssl-ca next start", + "typegen": "next typegen", "lint": "eslint .", "db:generate": "NODE_OPTIONS=--use-openssl-ca drizzle-kit generate", "db:migrate": "NODE_OPTIONS=--use-openssl-ca drizzle-kit migrate", diff --git a/turbo.json b/turbo.json index c5adbe13..1c04a258 100644 --- a/turbo.json +++ b/turbo.json @@ -10,10 +10,14 @@ "dependsOn": ["^build"] }, "type-check": { - "dependsOn": ["^build"] + "dependsOn": ["^build", "typegen"] }, - "lint": { + "typegen": { "dependsOn": ["^build"], + "outputs": [".next/types/**"] + }, + "lint": { + "dependsOn": ["^build", "typegen"], "outputs": ["eslint_report.json"] }, "test": {