2018-08-29 01:57:18 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-11-30 21:46:22 +01:00
|
|
|
// I M P O R T
|
2018-08-29 01:57:18 +02:00
|
|
|
|
|
|
|
import html from "choo/html";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// E X P O R T
|
|
|
|
|
2018-10-03 23:13:31 +02:00
|
|
|
export default currentUrl => {
|
|
|
|
const links = [
|
|
|
|
{
|
|
|
|
name: "LBRY.io",
|
|
|
|
title: "Escape the techno scene",
|
2018-10-04 18:07:11 +02:00
|
|
|
url: process.env.NODE_ENV === "development" ? "http://localhost:8000" : "https://lbry.io"
|
2018-10-03 23:13:31 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Overview",
|
|
|
|
title: "LBRY overview",
|
|
|
|
url: "/overview"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Playground",
|
|
|
|
title: "Experience LBRY",
|
|
|
|
url: "/playground"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Resources",
|
|
|
|
title: "View LBRY resources",
|
2019-01-21 23:16:49 +01:00
|
|
|
url: "/resources",
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
name: "Blockchain API",
|
|
|
|
title: "Reference for the LBRY blockchain API",
|
|
|
|
url: "/api/blockchain"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "SDK API",
|
|
|
|
title: "Reference for the SDK API",
|
|
|
|
url: "/api/sdk"
|
|
|
|
}
|
|
|
|
]
|
2018-10-03 23:13:31 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Community",
|
|
|
|
title: "Interact with LBRY",
|
|
|
|
url: "/community"
|
|
|
|
}
|
|
|
|
];
|
2018-08-29 01:57:18 +02:00
|
|
|
|
2018-10-03 23:13:31 +02:00
|
|
|
return html`
|
|
|
|
<nav class="navigation">
|
2019-01-21 23:16:49 +01:00
|
|
|
<ul class="inner-wrap">
|
|
|
|
<li class="navigation__item logo">
|
|
|
|
<a href="/" title="LBRY homepage">Home</a>
|
|
|
|
</li>
|
2018-10-03 23:13:31 +02:00
|
|
|
${links.map(link => renderLink(currentUrl, link))}
|
2019-01-21 23:16:49 +01:00
|
|
|
</ul>
|
2018-10-03 23:13:31 +02:00
|
|
|
</nav>
|
|
|
|
`;
|
|
|
|
};
|
2018-08-29 01:57:18 +02:00
|
|
|
|
|
|
|
|
2018-10-03 23:13:31 +02:00
|
|
|
|
|
|
|
// H E L P E R
|
|
|
|
|
|
|
|
function renderLink(href, link) {
|
|
|
|
let activeClass;
|
|
|
|
|
|
|
|
switch(true) {
|
|
|
|
case (link.url !== "/" && href.indexOf(link.url) >= 0):
|
2018-08-29 01:57:18 +02:00
|
|
|
activeClass = true;
|
2018-10-03 23:13:31 +02:00
|
|
|
break;
|
2018-08-29 01:57:18 +02:00
|
|
|
|
2018-10-03 23:13:31 +02:00
|
|
|
default:
|
|
|
|
activeClass = false;
|
|
|
|
break;
|
2018-08-29 01:57:18 +02:00
|
|
|
}
|
2018-10-03 23:13:31 +02:00
|
|
|
|
2019-01-21 23:16:49 +01:00
|
|
|
if (link.children) {
|
|
|
|
const links = [];
|
|
|
|
|
|
|
|
links.push(html`
|
|
|
|
<li class="navigation__item parent${activeClass ? " active" : ""}">
|
|
|
|
<a
|
|
|
|
href="${link.url}"
|
|
|
|
title="${link.title}"
|
|
|
|
>${link.name}</a>
|
|
|
|
<ul>
|
|
|
|
`);
|
|
|
|
|
|
|
|
for (const child of link.children) {
|
|
|
|
links.push(html`
|
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="${child.url}"
|
|
|
|
title="${child.title}"
|
|
|
|
>${child.name}</a>
|
|
|
|
</li>
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
|
|
|
|
links.push(html`
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
`);
|
|
|
|
|
|
|
|
return links.join("");
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
return html`
|
|
|
|
<li class="navigation__item${activeClass ? " active" : ""}">
|
|
|
|
<a
|
|
|
|
href="${link.url}"
|
|
|
|
title="${link.title}"
|
|
|
|
>${link.name}</a>
|
|
|
|
</li>
|
|
|
|
`;
|
|
|
|
}
|
2018-08-29 01:57:18 +02:00
|
|
|
}
|