-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples-links.js
58 lines (52 loc) · 1.23 KB
/
examples-links.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react';
const ExamplesLinks = () => {
const demos = [
{
label: 'Highlight.js (default)',
path: ''
},
{
label: 'Prism.js',
path: './prism.html'
},
{
label: 'Diff',
path: './diff.html'
},
{
label: 'Virtualized',
path: './virtualized.html'
},
{
label: 'Prism async light',
path: './prism-async-light.html'
}
];
const baseLiClass = 'demo-nav__li';
return (
<nav className="demo-nav">
<ul className="demo-nav__ul">
{demos.map(demo => {
const { label, path } = demo;
const currentPath = new URL(window.location.href).pathname
.split('/')
.filter(Boolean)
.pop();
const isCurrent =
path === `./${currentPath}` || (!path && currentPath === 'demo');
const itemClass = isCurrent
? `${baseLiClass} ${baseLiClass}--current`
: baseLiClass;
return (
<li className={itemClass}>
<a className="demo-nav__a" href={path || './'}>
{label}
</a>
</li>
);
})}
</ul>
</nav>
);
};
export default ExamplesLinks;