File tree Expand file tree Collapse file tree 4 files changed +18
-4
lines changed
Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export interface ContentPage extends PageProps {
1313}
1414
1515export interface LocalePage < T > extends PageProps {
16+ title ?: string
1617 ko : T
1718 en : T
1819}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { ThemeProvider } from 'styled-components'
77import '../assets/styles/global.css'
88import Theme from '../assets/styles/theme'
99import { NextSeo } from 'next-seo'
10+ import Head from 'next/head'
1011
1112const App = ( {
1213 Component,
@@ -19,14 +20,20 @@ const App = ({
1920 const { pathname } = router
2021
2122 const pageName = pageProps ?. title ?? ''
22- const pageTitle =
23- pageName !== ''
24- ? `${ t ( `pageTitle:${ pageName } ` ) } : ${ t ( `label:siteTitle` ) } `
25- : `${ t ( `label:siteTitle` ) } `
2623 const description = `${ t ( `label:pyconkrTitle` ) } : ${ t ( `label:pyconkrDate` ) } `
2724
2825 const hideSponsor = pathname === '/sponsor'
2926
27+ const getPageTitle = ( ) : string => {
28+ if ( i18n . exists ( `pageTitle:${ pageName } ` ) ) {
29+ return `${ t ( `pageTitle:${ pageName } ` ) } : ${ t ( `label:siteTitle` ) } `
30+ } else if ( pageProps ?. title ) {
31+ return `${ pageProps ?. title } : ${ t ( `label:siteTitle` ) } `
32+ }
33+ return `${ t ( `label:siteTitle` ) } `
34+ }
35+ const pageTitle = getPageTitle ( )
36+
3037 return (
3138 < >
3239 < I18nextProvider i18n = { i18n } >
@@ -47,6 +54,9 @@ const App = ({
4754 ]
4855 } }
4956 />
57+ < Head >
58+ < title > { pageTitle } </ title >
59+ </ Head >
5060 < Layout
5161 locale = { locale }
5262 pageName = { pageName }
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ export const getServerSideProps: GetServerSideProps = async (
8080 return {
8181 props : {
8282 locale,
83+ title : data . title ,
8384 ko : data ,
8485 en : data
8586 }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next'
1010import { media } from '../../../assets/styles/mixin'
1111
1212interface SponsorDetailProps extends LocalePage < ISponsorDetail > {
13+ title : string
1314 locale : string
1415}
1516
@@ -70,6 +71,7 @@ export const getServerSideProps: GetServerSideProps = async (
7071 return {
7172 props : {
7273 locale,
74+ title : data . name ,
7375 ko : data ,
7476 en : data
7577 }
You can’t perform that action at this time.
0 commit comments