Skip to content

Commit

Permalink
Add head-title to pages (#252)
Browse files Browse the repository at this point in the history
* add titles to pages

* import Seminar type and resolve optional title
  • Loading branch information
vikibrezinova authored Dec 9, 2023
1 parent 3bc981e commit 5df8ae8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 25 deletions.
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

0 comments on commit 5df8ae8

Please sign in to comment.