/** * Findings: P-01 (job pages had no description or Open Graph tags), A-04 (jobs from the DB) * * app/careers/[slug]/page.tsx * * The page is a server component: metadata is generated on the server and the job copy is in * the first HTML response. Only the form, which needs state, is a client component. * Postings are pre-rendered at build time and refreshed on demand when HR edits a role: * revalidateTag("jobs") // called from the admin "save posting" action */ import type { Metadata } from "next"; import { notFound } from "next/navigation"; import { unstable_cache } from "next/cache"; import { db } from "@/lib/db"; import { ApplicationForm } from "@/components/careers/application-form"; // "use client" type Props = { params: Promise<{ slug: string }> }; type JobView = { slug: string; title: string; summary: string; team: string; location: string; bodyMarkdown: string }; const getJob = unstable_cache( async (slug: string): Promise => db.jobPosting.findFirst({ where: { slug, isOpen: true }, // Explicit select = explicit public DTO. Nothing else can leak into the RSC payload. select: { slug: true, title: true, summary: true, team: true, location: true, bodyMarkdown: true }, }), ["job-by-slug"], { tags: ["jobs"], revalidate: 3600 }, ); export async function generateStaticParams() { const jobs: { slug: string }[] = await db.jobPosting.findMany({ where: { isOpen: true }, select: { slug: true } }); return jobs.map(({ slug }) => ({ slug })); } export const dynamicParams = true; // new roles render on first request, then cache export async function generateMetadata({ params }: Props): Promise { const { slug } = await params; const job = await getJob(slug); if (!job) return { title: "Role not found", robots: { index: false } }; const description = `${job.summary} ${job.location}. Apply to join the ${job.team} at Cynbit Technologies.`; return { title: `${job.title} | Careers`, // layout template appends "| Cynbit Technologies" once description, alternates: { canonical: `/careers/${slug}` }, openGraph: { url: `/careers/${slug}`, title: job.title, description }, // An opengraph-image.tsx next to this file supplies the preview image automatically. }; } export default async function JobPage({ params }: Props) { const { slug } = await params; const job = await getJob(slug); if (!job) notFound(); // Structured data lets Google show the role in job search results. const jobPostingLd = { "@context": "https://schema.org", "@type": "JobPosting", title: job.title, description: job.summary, hiringOrganization: { "@type": "Organization", name: "Cynbit Technologies", sameAs: "https://www.cynbit.in" }, jobLocationType: "TELECOMMUTE", applicantLocationRequirements: { "@type": "Country", name: "India" }, }; return (