@@ -16,69 +16,71 @@ import PropTypes from 'prop-types';
16
16
import React from 'react' ;
17
17
import { colors , fonts , media } from 'theme' ;
18
18
19
- const NavigationFooter = ( { next, prev} ) => (
20
- < div
21
- css = { {
22
- background : colors . dark ,
23
- color : colors . white ,
24
- paddingTop : 50 ,
25
- paddingBottom : 50 ,
26
- } } >
27
- < Container >
28
- < Flex
29
- type = "ul"
30
- halign = "space-between"
31
- css = { {
32
- [ media . between ( 'small' , 'medium' ) ] : {
33
- paddingRight : 240 ,
34
- } ,
19
+ const NavigationFooter = ( { next, prev, location} ) => {
20
+ return (
21
+ < div
22
+ css = { {
23
+ background : colors . dark ,
24
+ color : colors . white ,
25
+ paddingTop : 50 ,
26
+ paddingBottom : 50 ,
27
+ } } >
28
+ < Container >
29
+ < Flex
30
+ type = "ul"
31
+ halign = "space-between"
32
+ css = { {
33
+ [ media . between ( 'small' , 'medium' ) ] : {
34
+ paddingRight : 240 ,
35
+ } ,
35
36
36
- [ media . between ( 'large' , 'largerSidebar' ) ] : {
37
- paddingRight : 280 ,
38
- } ,
37
+ [ media . between ( 'large' , 'largerSidebar' ) ] : {
38
+ paddingRight : 280 ,
39
+ } ,
39
40
40
- [ media . between ( 'largerSidebar' , 'sidebarFixed' , true ) ] : {
41
- paddingRight : 380 ,
42
- } ,
43
- } } >
44
- < Flex basis = "50%" type = "li" >
45
- { prev &&
46
- < div >
47
- < SecondaryLabel > Previous article</ SecondaryLabel >
48
- < div
49
- css = { {
50
- paddingTop : 10 ,
51
- } } >
52
- < PrimaryLink to = { prev } >
53
- { linkToTitle ( prev ) }
54
- </ PrimaryLink >
41
+ [ media . between ( 'largerSidebar' , 'sidebarFixed' , true ) ] : {
42
+ paddingRight : 380 ,
43
+ } ,
44
+ } } >
45
+ < Flex basis = "50%" type = "li" >
46
+ { prev &&
47
+ < div >
48
+ < SecondaryLabel > Previous article</ SecondaryLabel >
49
+ < div
50
+ css = { {
51
+ paddingTop : 10 ,
52
+ } } >
53
+ < PrimaryLink location = { location } to = { prev } >
54
+ { linkToTitle ( prev ) }
55
+ </ PrimaryLink >
56
+ </ div >
57
+ </ div > }
58
+ </ Flex >
59
+ { next &&
60
+ < Flex
61
+ halign = "flex-end"
62
+ basis = "50%"
63
+ type = "li"
64
+ css = { {
65
+ textAlign : 'right' ,
66
+ } } >
67
+ < div >
68
+ < SecondaryLabel > Next article</ SecondaryLabel >
69
+ < div
70
+ css = { {
71
+ paddingTop : 10 ,
72
+ } } >
73
+ < PrimaryLink location = { location } to = { next } >
74
+ { linkToTitle ( next ) }
75
+ </ PrimaryLink >
76
+ </ div >
55
77
</ div >
56
- </ div > }
78
+ </ Flex > }
57
79
</ Flex >
58
- { next &&
59
- < Flex
60
- halign = "flex-end"
61
- basis = "50%"
62
- type = "li"
63
- css = { {
64
- textAlign : 'right' ,
65
- } } >
66
- < div >
67
- < SecondaryLabel > Next article</ SecondaryLabel >
68
- < div
69
- css = { {
70
- paddingTop : 10 ,
71
- } } >
72
- < PrimaryLink to = { next } >
73
- { linkToTitle ( next ) }
74
- </ PrimaryLink >
75
- </ div >
76
- </ div >
77
- </ Flex > }
78
- </ Flex >
79
- </ Container >
80
- </ div >
81
- ) ;
80
+ </ Container >
81
+ </ div >
82
+ ) ;
83
+ } ;
82
84
83
85
NavigationFooter . propTypes = {
84
86
next : PropTypes . string ,
@@ -89,31 +91,37 @@ export default NavigationFooter;
89
91
90
92
const linkToTitle = link => link . replace ( / - / g, ' ' ) . replace ( '.html' , '' ) ;
91
93
92
- const PrimaryLink = ( { children, to} ) => (
93
- < Link
94
- css = { {
95
- display : 'inline' ,
96
- textTransform : 'capitalize' ,
97
- borderColor : colors . subtle ,
98
- transition : 'border-color 0.2s ease' ,
99
- fontSize : 30 ,
100
- borderBottomWidth : 1 ,
101
- borderBottomStyle : 'solid' ,
94
+ const PrimaryLink = ( { children, to, location} ) => {
95
+ // quick fix
96
+ // TODO: replace this with better method of getting correct full url
97
+ const updatedUrl =
98
+ ( location && location . pathname . replace ( / \/ [ ^ / ] + \. h t m l / , '/' + to ) ) || to ;
99
+ return (
100
+ < Link
101
+ css = { {
102
+ display : 'inline' ,
103
+ textTransform : 'capitalize' ,
104
+ borderColor : colors . subtle ,
105
+ transition : 'border-color 0.2s ease' ,
106
+ fontSize : 30 ,
107
+ borderBottomWidth : 1 ,
108
+ borderBottomStyle : 'solid' ,
102
109
103
- [ media . lessThan ( 'large' ) ] : {
104
- fontSize : 24 ,
105
- } ,
106
- [ media . size ( 'xsmall' ) ] : {
107
- fontSize : 16 ,
108
- } ,
109
- ':hover' : {
110
- borderColor : colors . white ,
111
- } ,
112
- } }
113
- to = { to } >
114
- { children }
115
- </ Link >
116
- ) ;
110
+ [ media . lessThan ( 'large' ) ] : {
111
+ fontSize : 24 ,
112
+ } ,
113
+ [ media . size ( 'xsmall' ) ] : {
114
+ fontSize : 16 ,
115
+ } ,
116
+ ':hover' : {
117
+ borderColor : colors . white ,
118
+ } ,
119
+ } }
120
+ to = { updatedUrl } >
121
+ { children }
122
+ </ Link >
123
+ ) ;
124
+ } ;
117
125
118
126
const SecondaryLabel = ( { children} ) => (
119
127
< div
0 commit comments