menu moved to const

This commit is contained in:
tmshv committed 2026-04-13 02:14:31 +03:00
1 parent ccca4237ac
commit 3172e9c91e
9 files changed
+30 -69

No files matched your search

-3
View File
@@ -2,9 +2,7 @@
import s from "./app.module.css"
import { useContext } from "react"
import { Wrapper } from "../Wrapper"
import { MenuContext } from "@/context/MenuContext"
import { Footer } from "../Footer"
import { Content } from "../Content"
import { Breadcrumbs } from "../Breadcrumbs"
@@ -42,7 +40,6 @@ export function App({ showAuthor = false, ...props }: AppProps) {
const hideBreadcrumbs = useMobile()
const accessibility = useAccessibility()
const pathname = usePathname()
const menu = useContext(MenuContext)
return (
<Wrapper
@@ -1,11 +1,10 @@
import { Menu } from "../Menu"
import { useContext } from "react"
import { MenuContext } from "@/context/MenuContext"
import { Box } from "@/ui/Box"
import HudozkaLogo from "../HudozkaLogo"
import Link from "next/link"
import { AccessibilityButton } from "../AccessibilityButton"
import { Spacer } from "../Spacer"
import { menu } from "@/const"
export type DesktopNavigationProps = {
className?: string
@@ -13,8 +12,6 @@ export type DesktopNavigationProps = {
}
export function DesktopNavigation({ style, className }: DesktopNavigationProps) {
const menu = useContext(MenuContext)
return (
<Box wrap className={className} gap={"var(--size-s)"} style={style}>
<Link href="/">
@@ -30,4 +27,3 @@ export function DesktopNavigation({ style, className }: DesktopNavigationProps)
</Box>
)
}
@@ -3,8 +3,7 @@
import s from "./nav.module.css"
import { Menu } from "../Menu"
import { useCallback, useContext, useEffect, useRef } from "react"
import { MenuContext } from "@/context/MenuContext"
import { useCallback, useEffect, useRef } from "react"
import { Box } from "@/ui/Box"
import { Spacer } from "../Spacer"
import HudozkaLogo from "../HudozkaLogo"
@@ -12,6 +11,7 @@ import { HudozkaTitle } from "../HudozkaTitle"
import Link from "next/link"
import { usePathname } from "next/navigation"
import { HiOutlineMenuAlt4, HiOutlineX } from "react-icons/hi"
import { menu } from "@/const"
export type MobileNavigationProps = {
className?: string
@@ -19,7 +19,6 @@ export type MobileNavigationProps = {
}
export function MobileNavigation({ className, style }: MobileNavigationProps) {
const menu = useContext(MenuContext)
const detailsRef = useRef<HTMLDetailsElement>(null)
const pathname = usePathname()
-17
View File
@@ -1,17 +0,0 @@
"use client"
import { MenuContext } from "@/context/MenuContext"
import type { MenuItem } from "@/types"
export type ProvidersProps = {
menu: MenuItem[]
children: React.ReactNode
}
export function Providers({ menu, children }: ProvidersProps) {
return (
<MenuContext.Provider value={menu}>
{children}
</MenuContext.Provider>
)
}
+25
View File
@@ -1,2 +1,27 @@
import type { MenuItem } from "./types"
export const yearRange = [2012, 2026].join("—")
export const siteUrl = "https://art.shlisselburg.org"
export const menu: MenuItem[] = [
{
name: "Школа",
href: "/",
},
{
name: "Предметы",
href: "/cources",
},
{
name: "Коллектив",
href: "/collective",
},
{
name: "Документы",
href: "/documents",
},
{
name: "Сведения об образовательной организации",
href: "/info",
},
]
-10
View File
@@ -1,10 +0,0 @@
import { createContext } from "react"
export const menu = [
{
name: "Школа",
href: "/",
},
]
export const MenuContext = createContext(menu)
-23
View File
@@ -142,29 +142,6 @@ export async function getHomeCards(): Promise<PageCardDto[]> {
}
}
export async function getMenu(): Promise<MenuItem[]> {
try {
const kv = await pb.collection("kv").getFirstListItem<{ data: PbMenuData }>(
"key=\"menu\"",
)
const data = kv.data
if (!data.items || data.items.length === 0) {
return [{
href: "/",
name: data.homeLabel,
}]
}
const pageIds = data.items.map(i => i.page)
const pages = await fetchPagesByIds(pageIds)
return createMenu(data, pages)
} catch (error) {
console.error(`Failed to fetch menu: ${error}`)
return []
}
}
export async function getRecentPages(limit: number = 30): Promise<FeedPage[]> {
try {
const result = await pb.collection("pages").getList<PbPage>(1, limit, {