Skip to content

Open source CapCut alternative.

TypeScript
2.4 KB
Raw Blame
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { getTranslations } from "next-intl/server";

import { CutLanding } from "@/app/[locale]/cut/_components/landing/CutLanding";
import { DONKEYCUT_CANONICAL } from "@/cut/lib/hosts";
import { CURRENCIES, isCurrency } from "@/lib/billing/currencies";

type Params = { params: Promise<{ currency: string }> };

// The landing prices its plans in its visitor's currency, so it is
// prerendered once per currency; the proxy picks the one for the visitor's
// country (src/proxy.ts), and the segment never shows in a URL.
export function generateStaticParams() {
  return CURRENCIES.map((currency) => ({ currency }));
}

export async function generateMetadata(): Promise<Metadata> {
  const t = await getTranslations("landing.meta");
  const title = t("title");
  const description = t("description");
  return {
    title,
    description,
    alternates: {
      canonical: `${DONKEYCUT_CANONICAL}/`,
    },
    openGraph: {
      title,
      description,
      url: `${DONKEYCUT_CANONICAL}/`,
      siteName: "Donkey Cut",
      type: "website",
      images: [{ url: "/cut/landing/og.png", width: 1200, height: 630 }],
    },
    twitter: {
      card: "summary_large_image",
      title,
      description,
      images: ["/cut/landing/og.png"],
    },
  };
}

// The public pages are the ones a visitor lands on cold, so they are the ones
// that have to be instant. Nothing here reads request data; declaring it makes
// Next check that in dev and at build, and the check is what keeps a server
// read added later from quietly turning a link click into a wait.
export const instant = true;

// The WebSite record Google reads for the site name above a result. The
// alternate name ties brand searches to the editor; "donkey cut" alone ranks
// cut-out crafts and template sites.
const WEBSITE_LD = {
  "@context": "https://schema.org",
  "@type": "WebSite",
  name: "Donkey Cut",
  alternateName: "Donkey Cut Video Editor",
  url: `${DONKEYCUT_CANONICAL}/`,
};

// The Cut marketing landing, served at "/" on every host by the proxy's
// "/…" → "/cut/…" rewrite.
export default async function CutLandingPage({ params }: Params) {
  const { currency } = await params;
  if (!isCurrency(currency)) {
    notFound();
  }
  return (
    <>
      <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(WEBSITE_LD) }} />
      <CutLanding currency={currency} />
    </>
  );
}