1
1
/** @jsx jsx */
2
2
import { jsx } from "theme-ui"
3
3
import { Link } from "gatsby"
4
- import { mediaQueries , colors } from "../gatsby-plugin-theme-ui"
4
+ import { colors , mediaQueries } from "../gatsby-plugin-theme-ui"
5
5
6
6
function isUnderDepthLimit ( depth , maxDepth ) {
7
7
if ( maxDepth === null ) {
@@ -17,38 +17,40 @@ function isUnderDepthLimit(depth, maxDepth) {
17
17
function createItems ( items , location , depth , maxDepth ) {
18
18
return (
19
19
items &&
20
- items . map ( item => (
20
+ items . map ( ( item , index ) => (
21
21
< li
22
22
sx = { { [ mediaQueries . xl ] : { fontSize : 1 } } }
23
- key = { location . pathname + item . url }
23
+ key = { location . pathname + ( item . url || depth + `-` + index ) }
24
24
>
25
- < Link
26
- sx = { {
27
- "&&" : {
28
- color : `textMuted` ,
29
- border : 0 ,
30
- transition : t =>
31
- `all ${ t . transition . speed . fast } ${ t . transition . curve . default } ` ,
32
- ":hover" : {
33
- color : `link.color` ,
34
- borderBottom : t => `1px solid ${ t . colors . link . hoverBorder } ` ,
25
+ { item . url && (
26
+ < Link
27
+ sx = { {
28
+ "&&" : {
29
+ color : `textMuted` ,
30
+ border : 0 ,
31
+ transition : t =>
32
+ `all ${ t . transition . speed . fast } ${ t . transition . curve . default } ` ,
33
+ ":hover" : {
34
+ color : `link.color` ,
35
+ borderBottom : t => `1px solid ${ t . colors . link . hoverBorder } ` ,
36
+ } ,
35
37
} ,
36
- } ,
37
- } }
38
- getProps = { ( { href , location } ) =>
39
- location && location . href && location . href . includes ( href )
40
- ? {
41
- style : {
42
- color : colors . link . color ,
43
- borderBottom : `1px solid ${ colors . link . hoverBorder } ` ,
44
- } ,
45
- }
46
- : null
47
- }
48
- to = { location . pathname + item . url }
49
- >
50
- { item . title }
51
- </ Link >
38
+ } }
39
+ getProps = { ( { href , location } ) =>
40
+ location && location . href && location . href . includes ( href )
41
+ ? {
42
+ style : {
43
+ color : colors . link . color ,
44
+ borderBottom : `1px solid ${ colors . link . hoverBorder } ` ,
45
+ } ,
46
+ }
47
+ : null
48
+ }
49
+ to = { location . pathname + item . url }
50
+ >
51
+ { item . title }
52
+ </ Link >
53
+ ) }
52
54
{ item . items && isUnderDepthLimit ( depth , maxDepth ) && (
53
55
< ul sx = { { color : `textMuted` , listStyle : `none` , ml : 5 } } >
54
56
{ createItems ( item . items , location , depth + 1 , maxDepth ) }
0 commit comments