Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add head-title to pages #252

Merged
merged 2 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 37 additions & 20 deletions src/components/PageLayout/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import clsx from 'clsx'
import Head from 'next/head'
import {FC, ReactNode} from 'react'

import {BannerContainer} from '@/utils/BannerContainer'
import {PageTitleContainer} from '@/utils/PageTitleContainer'
import {Seminar, useSeminarInfo} from '@/utils/useSeminarInfo'

import {Footer} from './Footer/Footer'
import {MenuMain} from './MenuMain/MenuMain'
Expand All @@ -16,31 +18,46 @@ type PageLayoutProps = {
children: ReactNode
}

const seminarTitle: Record<Seminar, string> = {
strom: 'STROM',
matik: 'Matik',
malynar: 'Malynár',
}

// pre pouzitie len na seminarovych strankach a podstrankach - `/matik(/*)`
// ked budeme potrebovat top-level stranky ako `/ina-stranka`, budeme musiet upravit, ako sa pracuje s `useSeminarInfo`
export const PageLayout: FC<PageLayoutProps> = ({contentWidth = 2, title = '', children}) => {
const {seminar} = useSeminarInfo()
return (
<PageTitleContainer.Provider initialState={title}>
<BannerContainer.Provider>
<div className={styles.pageContainer}>
<TopGrid />
<MenuMain />
<div className={styles.grid}>
<StromLogo />
<div
className={clsx(
styles.mainContent,
contentWidth === 1 && styles.col1,
contentWidth === 2 && styles.col2,
contentWidth === 3 && styles.col3,
)}
>
{children}
<>
<Head>
<title>
{title && `${title} | `}
{seminarTitle[seminar]}
</title>
</Head>
<PageTitleContainer.Provider initialState={title}>
<BannerContainer.Provider>
<div className={styles.pageContainer}>
<TopGrid />
<MenuMain />
<div className={styles.grid}>
<StromLogo />
<div
className={clsx(
styles.mainContent,
contentWidth === 1 && styles.col1,
contentWidth === 2 && styles.col2,
contentWidth === 3 && styles.col3,
)}
>
{children}
</div>
</div>
<Footer />
</div>
<Footer />
</div>
</BannerContainer.Provider>
</PageTitleContainer.Provider>
</BannerContainer.Provider>
</PageTitleContainer.Provider>
</>
)
}
2 changes: 1 addition & 1 deletion src/pages/malynar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {PageLayout} from '@/components/PageLayout/PageLayout'
import {Posts} from '@/components/Posts/Posts'

const Malynar: NextPage = () => (
<PageLayout title="Seminár Malynár" contentWidth={1}>
<PageLayout title="Novinky" contentWidth={1}>
<Posts />
</PageLayout>
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/matik/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {PageLayout} from '@/components/PageLayout/PageLayout'
import {Posts} from '@/components/Posts/Posts'

const Matik: NextPage = () => (
<PageLayout title="Seminár Matik" contentWidth={1}>
<PageLayout title="Novinky" contentWidth={1}>
<Posts />
</PageLayout>
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/strom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {PageLayout} from '@/components/PageLayout/PageLayout'
import {Posts} from '@/components/Posts/Posts'

const Strom: NextPage = () => (
<PageLayout title="Seminár Strom" contentWidth={1}>
<PageLayout title="Novinky" contentWidth={1}>
<Posts />
</PageLayout>
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/strom/vysledky/[[...params]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Results} from '@/components/Results/Results'

const Vysledky: NextPage = () => {
return (
<PageLayout contentWidth={2}>
<PageLayout contentWidth={2} title="Výsledky">
<Results />
</PageLayout>
)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/strom/zadania/[[...params]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Problems} from '@/components/Problems/Problems'

const Zadania: NextPage = () => {
return (
<PageLayout contentWidth={2}>
<PageLayout contentWidth={2} title="Zadania">
<Problems />
</PageLayout>
)
Expand Down
Loading