lbry.tech/app/components/edit-link.js

48 lines
882 B
JavaScript
Raw Normal View History

2018-07-12 10:21:42 -05:00
"use strict";
2018-07-13 16:58:24 -05:00
// P A C K A G E S
2018-07-12 10:21:42 -05:00
2018-08-28 18:57:18 -05:00
import html from "choo/html";
import { require as local } from "app-root-path";
2018-07-12 10:21:42 -05:00
// V A R I A B L E
const config = local("/config");
2018-07-13 16:58:24 -05:00
// E X P O R T
2018-07-12 10:21:42 -05:00
2018-08-28 18:57:18 -05:00
export default function (pagePath) {
2018-07-13 13:22:46 -05:00
let githubUrl = `https://github.com/${config.github.repo}/edit/${config.github.branch}`;
2018-07-12 10:21:42 -05:00
2018-07-13 13:22:46 -05:00
switch(pagePath) {
case "":
githubUrl = `${githubUrl}/views/pages/home.js`;
break;
2018-07-25 17:04:21 -05:00
case "/resources":
2018-07-13 13:22:46 -05:00
githubUrl = `${githubUrl}/views/pages/resources.js`;
break;
2018-07-25 17:04:21 -05:00
case "/tour":
githubUrl = `${githubUrl}/views/partials/tour.js`;
2018-07-25 17:04:21 -05:00
break;
2018-07-13 13:22:46 -05:00
default:
githubUrl = `${githubUrl}/documents${pagePath}.md`;
break;
}
2018-07-12 10:21:42 -05:00
return html`
2018-08-28 18:57:18 -05:00
<a
href="${githubUrl}"
target="_blank"
rel="noopener noreferrer"
title="${config.github.linkText}"
>${config.github.linkText}</a>
2018-07-12 10:21:42 -05:00
`;
2018-08-28 18:57:18 -05:00
}