Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API. Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
2.4 KiB
TypeScript
68 lines
2.4 KiB
TypeScript
import { AntdRegistry } from "@ant-design/nextjs-registry";
|
|
import { Providers } from "@ebook/components/Providers";
|
|
import { getSiteConfig } from "@ebook/lib/site-config.server";
|
|
import { getServerFeatures } from "@ebook/lib/features.server";
|
|
import { getLocale } from "@ebook/lib/i18n/server";
|
|
import { BookRoutesProvider } from "@ebook/components/BookRoutes";
|
|
import { ModuleBoundary } from "~/components/module-boundary";
|
|
import "@ebook/app/globals.css";
|
|
|
|
export default async function BookLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const locale = await getLocale();
|
|
const site = getSiteConfig();
|
|
const f = getServerFeatures();
|
|
|
|
return (
|
|
<ModuleBoundary moduleKey="book">
|
|
<div className="ebook-root" data-locale={locale}>
|
|
<AntdRegistry>
|
|
<Providers locale={locale}>
|
|
<BookRoutesProvider cover="/book" home="/">
|
|
{f.analytics.enabled ? <AnalyticsLazy /> : null}
|
|
{f.ads.enabled && f.ads.clientId ? <AdSenseLazy /> : null}
|
|
{children}
|
|
{f.feedback.enabled ? (
|
|
<FeedbackLazy
|
|
title={f.feedback.title}
|
|
subtitle={f.feedback.subtitle}
|
|
contactEmail={site.brand.contactEmail}
|
|
xHandle={site.brand.xHandle}
|
|
/>
|
|
) : null}
|
|
</BookRoutesProvider>
|
|
</Providers>
|
|
</AntdRegistry>
|
|
<script
|
|
dangerouslySetInnerHTML={{
|
|
__html: `window.__EBOOK_FEATURES__=${JSON.stringify(f).replace(/</g, "\\u003c")};window.__LOCALE__=${JSON.stringify(locale)};(function(){try{var t=localStorage.getItem("nomadro-theme")||localStorage.getItem("ebook-theme");if(t==="light"||t==="sepia"||t==="dark"){document.documentElement.classList.remove("light","dark","sepia");document.documentElement.classList.add(t);}else{document.documentElement.classList.add("dark");}}catch(e){document.documentElement.classList.add("dark");}})();`,
|
|
}}
|
|
/>
|
|
</div>
|
|
</ModuleBoundary>
|
|
);
|
|
}
|
|
|
|
function AnalyticsLazy() {
|
|
const { AnalyticsProvider } = require("@ebook/components/AnalyticsProvider");
|
|
return <AnalyticsProvider />;
|
|
}
|
|
|
|
function AdSenseLazy() {
|
|
const { AdSenseScript } = require("@ebook/components/AdSlot");
|
|
return <AdSenseScript />;
|
|
}
|
|
|
|
function FeedbackLazy(props: {
|
|
title: string;
|
|
subtitle: string;
|
|
contactEmail: string;
|
|
xHandle: string;
|
|
}) {
|
|
const { FeedbackPanel } = require("@ebook/components/FeedbackPanel");
|
|
return <FeedbackPanel {...props} />;
|
|
}
|