Pages -> App (#265)

* pages -> app

* add meta test

* fix gosuslugi
This commit is contained in:
tmshv authored and GitHub committed 2026-02-09 00:25:06 +07:00
1 parent 0c8d74b21d
commit a1e51e78f0
23 files changed
+522 -516

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
export default function Loading() {
return <div>loading...</div>
}
+71
View File
@@ -0,0 +1,71 @@
import type { Metadata } from "next"
import { notFound } from "next/navigation"
import { App } from "@/components/App"
import { PageContent } from "@/components/PageContent"
import { MetaBuilder, buildMetadata } from "@/lib/meta"
import { getMenu, getPageBySlug, getUrls } from "@/remote/api"
import { tail } from "@/lib/array"
export const revalidate = 30
export const dynamicParams = true
export async function generateStaticParams() {
const urls = await getUrls()
return urls.map(path => ({
slug: tail(path.split("/")),
}))
}
type Props = {
params: Promise<{ slug: string[] }>
}
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = await params
const slugPath = `/${slug.join("/")}`
const page = await getPageBySlug(slugPath)
if (!page) {
return {}
}
const m = new MetaBuilder()
.setImage(page.cover)
.setTitle(page.title)
.setDescription(page.description ?? undefined)
.build()
return buildMetadata(m)
}
export default async function SlugPage({ params }: Props) {
const { slug } = await params
const slugPath = `/${slug.join("/")}`
const page = await getPageBySlug(slugPath)
if (!page) {
notFound()
}
const breadcrumbSize = page.breadcrumb?.length ?? 0
const breadcrumbs = breadcrumbSize < 2 ? [] : page.breadcrumb ?? []
return (
<App
contentStyle={{
marginTop: "var(--size-l)",
marginBottom: "var(--size-xl)",
}}
breadcrumbs={breadcrumbs}
>
<PageContent
tags={page.tags}
date={page.date}
tokens={page.tokens}
documentSignature={{
date: "20.01.2021г.",
person: "Тимашева Марина Геннадьевна",
position: "Директор",
signature: "0ac4ea89753a4ba9893799442325fb41",
}}
/>
</App>
)
}
+81
View File
@@ -0,0 +1,81 @@
import "src/style/style.css"
import "src/style/content.css"
import "src/style/article.css"
import "src/style/marker/marker-table.css"
import "src/style/kazimir/video.css"
import type { Metadata, Viewport } from "next"
import Script from "next/script"
import { Roboto } from "next/font/google"
import { Providers } from "@/components/Providers"
import { YMetrika } from "@/components/YMetrika"
import { getMenu } from "@/remote/api"
const roboto = Roboto({
weight: ["300", "900"],
subsets: ["cyrillic", "latin"],
display: "swap",
})
export const metadata: Metadata = {
verification: {
google: [
"8BxOTw-Q02DS2KAdcGcnIMwiPZ58DVB18XpOfRibCcg",
"A-TEemUw4hHpULUDCd6xhxfHnyRbgKtss90JGKXnSpw",
],
other: {
"yandex-verification": "643c7dac144b9dac",
"msvalidate.01": "E878301FE3E3F12D233A6B1156889601",
"proculture-verification": "79110940fd847c3cfe52392ed68f3210",
},
},
icons: {
icon: { url: "/static/graphics/favicon-32.png", type: "image/png" },
apple: [
{ url: "/static/graphics/favicon-57.png", sizes: "57x57" },
{ url: "/static/graphics/favicon-72.png", sizes: "72x72" },
{ url: "/static/graphics/favicon-114.png", sizes: "114x114" },
{ url: "/static/graphics/favicon-144.png", sizes: "144x144" },
],
},
other: {
"apple-mobile-web-app-capable": "yes",
"referrer": "unsafe-url",
},
alternates: {
types: {
"application/feed+json": "/feed.json",
},
},
}
export const viewport: Viewport = {
width: "device-width",
maximumScale: 1,
themeColor: [
{ media: "(prefers-color-scheme: light)", color: "white" },
{ media: "(prefers-color-scheme: dark)", color: "hsl(240, 10%, 10%)" },
],
}
export const revalidate = 30
export default async function RootLayout({ children }: { children: React.ReactNode }) {
const menu = await getMenu()
return (
<html lang="ru" className={roboto.className}>
<head>
{process.env.NEXT_PUBLIC_YMETRIKA_ACCOUNT && (
<YMetrika account={Number(process.env.NEXT_PUBLIC_YMETRIKA_ACCOUNT)} />
)}
</head>
<body>
<Providers menu={menu}>
{children}
</Providers>
<Script src="https://culturaltracking.ru/static/js/spxl.js?pixelId=27154" data-pixel-id="27154" />
</body>
</html>
)
}
+10
View File
@@ -0,0 +1,10 @@
import { App } from "@/components/App"
import { NotFound } from "@/components/NotFound"
export default function NotFoundPage() {
return (
<App>
<NotFound />
</App>
)
}
+26
View File
@@ -0,0 +1,26 @@
import type { Metadata } from "next"
import { App } from "@/components/App"
import { HomeContent } from "@/components/HomeContent"
import { MetaBuilder, buildMetadata } from "@/lib/meta"
import { getHomeCards } from "@/remote/api"
export const revalidate = 30
export async function generateMetadata(): Promise<Metadata> {
const title = "Шлиссельбургская ДХШ"
const m = new MetaBuilder()
.setTitle(title)
.setData({ url: "/" })
.build()
return buildMetadata(m)
}
export default async function HomePage() {
const items = await getHomeCards()
return (
<App showAuthor>
<HomeContent items={items} />
</App>
)
}