Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/(main)/(author)/author/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
AuthorQueryWithRelatedResult,
} from "@/sanity/types";
import { sanityFetch } from "@/sanity/lib/live";
import { client } from "@/sanity/lib/client";
import { authorQuery, authorQueryWithRelated } from "@/sanity/lib/queries";
import { resolveOpenGraphImage } from "@/sanity/lib/utils";
import CoverMedia from "@/components/cover-media";
Expand All @@ -19,6 +20,8 @@ import UserRelated from "@/components/user-related";

type Params = Promise<{ slug: string }>;

export const revalidate = 3600;

export async function generateMetadata(
{ params }: { params: Params },
parent: ResolvingMetadata,
Expand All @@ -45,6 +48,13 @@ export async function generateMetadata(
} satisfies Metadata;
}

export async function generateStaticParams() {
const slugs = await client.fetch<string[]>(
groq`*[_type == "author" && defined(slug.current)].slug.current`,
);
return slugs.map((slug) => ({ slug }));
}

export default async function AuthorPage({ params }: { params: Params }) {
const { slug } = await params;

Expand Down
13 changes: 13 additions & 0 deletions app/(main)/(author)/authors/page/[num]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import MoreContent from "@/components/more-content";
import type { DocCountResult } from "@/sanity/types";
import { sanityFetch } from "@/sanity/lib/live";
import { client } from "@/sanity/lib/client";

import PaginateList from "@/components/paginate-list";
import { docCount } from "@/sanity/lib/queries";
import { groq } from "next-sanity";

const LIMIT = 10;

type Params = Promise<{ num: string }>;

export const revalidate = 60;

export async function generateStaticParams() {
const count = await client.fetch<number>(
groq`count(*[_type == "author" && defined(slug.current)])`,
);
const perPage = LIMIT;
const pages = Math.ceil(count / perPage);
return Array.from({ length: pages }, (_, i) => ({ num: String(i + 1) }));
}

export default async function Page({ params }: { params: Params }) {
const { num } = await params;

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading