Dev Helpers
← Back

Desk word budget

Place this file at app/editorial/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// app/editorial/page.tsx

export default async function DeskWordBudget({
  searchParams,
}: {
  searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
  const posts = [
    { title: "Paper mills", day: "2028-04-01", desk: "News", words: 840 },
    { title: "At the kiln", day: "2028-04-03", desk: "Art", words: 1500 },
    { title: "City briefs", day: "2028-04-03", desk: "News", words: 540 },
  ];
  const { desk } = await searchParams;
  const selected = posts.filter((p) => p.desk === (desk ?? "News"));
  return (
    <output>{selected.reduce((n, p) => n + p.words, 0)} commissioned words</output>
  );
}