Add CYD browser flasher with Next.js, i18n, and Web Serial install.
Replace the starter app with a public/local flasher that discovers sibling firmwares, supports en/zh, and documents HTTPS deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
113
app/[locale]/layout.tsx
Normal file
113
app/[locale]/layout.tsx
Normal file
@@ -0,0 +1,113 @@
|
||||
import type { Metadata } from "next";
|
||||
import { notFound } from "next/navigation";
|
||||
import { NextIntlClientProvider, hasLocale } from "next-intl";
|
||||
import { getMessages, getTranslations, setRequestLocale } from "next-intl/server";
|
||||
import { DM_Sans, Syne } from "next/font/google";
|
||||
import { routing } from "@/i18n/routing";
|
||||
import { LanguageSwitcher } from "@/components/language-switcher";
|
||||
|
||||
const dmSans = DM_Sans({
|
||||
subsets: ["latin"],
|
||||
variable: "--font-body",
|
||||
display: "swap",
|
||||
});
|
||||
|
||||
const syne = Syne({
|
||||
subsets: ["latin"],
|
||||
variable: "--font-display",
|
||||
weight: ["600", "700", "800"],
|
||||
display: "swap",
|
||||
});
|
||||
|
||||
type Props = {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ locale: string }>;
|
||||
};
|
||||
|
||||
export function generateStaticParams() {
|
||||
return routing.locales.map((locale) => ({ locale }));
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
const t = await getTranslations({ locale, namespace: "meta" });
|
||||
const languages = Object.fromEntries(
|
||||
routing.locales.map((l) => [l, `/${l}`])
|
||||
);
|
||||
|
||||
return {
|
||||
title: t("title"),
|
||||
description: t("description"),
|
||||
metadataBase: new URL(
|
||||
process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000"
|
||||
),
|
||||
alternates: {
|
||||
canonical: `/${locale}`,
|
||||
languages,
|
||||
},
|
||||
openGraph: {
|
||||
title: t("title"),
|
||||
description: t("description"),
|
||||
locale: locale === "zh" ? "zh_CN" : "en_US",
|
||||
type: "website",
|
||||
siteName: "CYD Flasher",
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title: t("title"),
|
||||
description: t("description"),
|
||||
},
|
||||
robots: {
|
||||
index: true,
|
||||
follow: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default async function LocaleLayout({ children, params }: Props) {
|
||||
const { locale } = await params;
|
||||
if (!hasLocale(routing.locales, locale)) notFound();
|
||||
|
||||
setRequestLocale(locale);
|
||||
const messages = await getMessages();
|
||||
const t = await getTranslations("brand");
|
||||
const tf = await getTranslations("footer");
|
||||
|
||||
return (
|
||||
<html lang={locale} className={`${dmSans.variable} ${syne.variable}`}>
|
||||
<body className="antialiased">
|
||||
<NextIntlClientProvider messages={messages}>
|
||||
<div className="bg-grid" aria-hidden />
|
||||
<div className="bg-glow" aria-hidden />
|
||||
|
||||
<header className="animate-rise relative z-10 mx-auto flex max-w-[920px] flex-wrap items-center justify-between gap-4 px-[clamp(1.25rem,4vw,3rem)] pt-6">
|
||||
<div>
|
||||
<div className="flex items-center gap-2.5">
|
||||
<span
|
||||
className="size-[1.15rem] rounded-[3px] bg-[linear-gradient(145deg,var(--accent-hot),#c98900)] shadow-[0_0_0_3px_rgba(240,197,10,0.2)]"
|
||||
aria-hidden
|
||||
/>
|
||||
<span className="font-[family-name:var(--font-display)] text-[clamp(1.6rem,4vw,2.1rem)] font-extrabold leading-none tracking-tight">
|
||||
{t("name")}
|
||||
</span>
|
||||
</div>
|
||||
<p className="mt-1.5 text-[0.95rem] text-[var(--muted)]">
|
||||
{t("tagline")}
|
||||
</p>
|
||||
</div>
|
||||
<LanguageSwitcher />
|
||||
</header>
|
||||
|
||||
<main className="relative z-10 mx-auto max-w-[920px] px-[clamp(1.25rem,4vw,3rem)] py-7 pb-12">
|
||||
{children}
|
||||
</main>
|
||||
|
||||
<footer className="relative z-10 mx-auto flex max-w-[920px] flex-wrap gap-x-6 gap-y-2 px-[clamp(1.25rem,4vw,3rem)] pb-10 text-xs text-[var(--muted)] opacity-85">
|
||||
<span>{tf("offsets")}</span>
|
||||
<span>{tf("stack")}</span>
|
||||
</footer>
|
||||
</NextIntlClientProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
10
app/[locale]/not-found.tsx
Normal file
10
app/[locale]/not-found.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
export default function NotFound() {
|
||||
return (
|
||||
<div className="py-16 text-center">
|
||||
<h1 className="font-[family-name:var(--font-display)] text-2xl font-bold">
|
||||
404
|
||||
</h1>
|
||||
<p className="mt-2 text-[var(--muted)]">Page not found</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
23
app/[locale]/page.tsx
Normal file
23
app/[locale]/page.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { getTranslations, setRequestLocale } from "next-intl/server";
|
||||
import { FlasherPanel } from "@/components/flasher-panel";
|
||||
|
||||
type Props = { params: Promise<{ locale: string }> };
|
||||
|
||||
export default async function HomePage({ params }: Props) {
|
||||
const { locale } = await params;
|
||||
setRequestLocale(locale);
|
||||
const t = await getTranslations("hero");
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<section className="animate-rise">
|
||||
<h1 className="m-0 max-w-[18ch] font-[family-name:var(--font-display)] text-[clamp(1.45rem,3.5vw,1.85rem)] font-bold tracking-tight">
|
||||
{t("title")}
|
||||
</h1>
|
||||
<p className="mt-2 max-w-[42rem] text-[var(--muted)]">{t("lede")}</p>
|
||||
</section>
|
||||
|
||||
<FlasherPanel />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user