File tree Expand file tree Collapse file tree 5 files changed +22
-9
lines changed Expand file tree Collapse file tree 5 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -28,12 +28,14 @@ type Props = {
28
28
title : string
29
29
onTitleClick : ( event : React . MouseEvent < HTMLAnchorElement > ) => void
30
30
onMenuClick : ComponentProps < typeof Menu > [ 'onClick' ]
31
+ tabKey : string
31
32
}
32
33
33
34
export const Header : React . FC < Props > = ( {
34
35
onTitleClick,
35
36
onMenuClick,
36
37
title,
38
+ tabKey,
37
39
} ) => {
38
40
return (
39
41
< StyledHeader >
@@ -44,12 +46,12 @@ export const Header: React.FC<Props> = ({
44
46
</ HeaderTitle >
45
47
< StyledMenu
46
48
mode = "horizontal"
47
- defaultSelectedKeys = { [ 'days' ] }
49
+ selectedKeys = { [ tabKey ] }
48
50
onClick = { onMenuClick }
49
51
>
50
- < Menu . Item key = "days" > 日々</ Menu . Item >
51
- < Menu . Item key = "works" > 写真</ Menu . Item >
52
- < Menu . Item key = "about" > 私について</ Menu . Item >
52
+ < Menu . Item key = "/ days" > 日々</ Menu . Item >
53
+ < Menu . Item key = "/ works" > 写真</ Menu . Item >
54
+ < Menu . Item key = "/ about" > 私について</ Menu . Item >
53
55
</ StyledMenu >
54
56
</ StyledHeader >
55
57
)
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ export const About: React.FC<Props> = ({
50
50
< Col span = { 16 } >
51
51
< ProfileTypography >
52
52
{ profileDescriptions . map ( desc => (
53
- < Paragraph key = "" > { desc } </ Paragraph >
53
+ < Paragraph key = { desc } > { desc } </ Paragraph >
54
54
) ) }
55
55
</ ProfileTypography >
56
56
</ Col >
Original file line number Diff line number Diff line change @@ -25,13 +25,15 @@ type Props = ComponentProps<typeof Header> & ComponentProps<typeof Footer>
25
25
export const Layout : React . FC < Props > = ( {
26
26
children,
27
27
title,
28
+ tabKey,
28
29
onTitleClick,
29
30
onMenuClick,
30
31
onTwitterClick,
31
32
} ) => {
32
33
return (
33
34
< AntLayout style = { { minHeight : '100vh' } } >
34
35
< Header
36
+ tabKey = { tabKey }
35
37
title = { title }
36
38
onTitleClick = { onTitleClick }
37
39
onMenuClick = { onMenuClick }
Original file line number Diff line number Diff line change 1
1
import { ComponentProps , useCallback } from 'react'
2
- import { useHistory } from 'react-router'
2
+ import { useHistory , useLocation } from 'react-router'
3
3
4
4
import { Layout } from 'components/templates/Layout'
5
5
import SiteConfig from 'data/site.json'
@@ -9,10 +9,11 @@ const TWITTER_URL = 'https://twitter.com/'
9
9
10
10
export const useLayout = ( ) : ComponentProps < typeof Layout > => {
11
11
const history = useHistory ( )
12
-
12
+ const { pathname } = useLocation ( )
13
+ const currentKey = pathname === '/' ? '/days' : pathname
13
14
const onMenuClick = useCallback (
14
15
( { key } ) => {
15
- history . push ( `/ ${ key } ` )
16
+ history . push ( key )
16
17
} ,
17
18
[ history ]
18
19
)
@@ -28,6 +29,7 @@ export const useLayout = (): ComponentProps<typeof Layout> => {
28
29
} , [ ] )
29
30
30
31
return {
32
+ tabKey : currentKey ,
31
33
title : SiteConfig . blogTitle ,
32
34
onMenuClick,
33
35
onTitleClick,
Original file line number Diff line number Diff line change @@ -5,10 +5,17 @@ import { useLayout } from './hooks/useLayout'
5
5
import { Layout } from 'components/templates/Layout'
6
6
7
7
export const LayoutContainer : React . FC = ( { children } ) => {
8
- const { title, onTitleClick, onMenuClick, onTwitterClick } = useLayout ( )
8
+ const {
9
+ title,
10
+ onTitleClick,
11
+ onMenuClick,
12
+ onTwitterClick,
13
+ tabKey,
14
+ } = useLayout ( )
9
15
return (
10
16
< Layout
11
17
title = { title }
18
+ tabKey = { tabKey }
12
19
onTitleClick = { onTitleClick }
13
20
onMenuClick = { onMenuClick }
14
21
onTwitterClick = { onTwitterClick }
You can’t perform that action at this time.
0 commit comments