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

52 lines
1 KiB
JavaScript
Raw Normal View History

2018-07-12 10:21:42 -05:00
"use strict";
2018-11-30 14:46:22 -06:00
// I M P O R T 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
2018-10-10 12:56:35 -05:00
// U T I L
2018-07-12 10:21:42 -05:00
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-10-03 15:27:13 -05:00
export default 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}/app/views/home.js`;
2018-07-13 13:22:46 -05:00
break;
2018-10-03 15:27:13 -05:00
case "/api":
githubUrl = `${githubUrl}/app/views/api.js`;
2018-07-13 13:22:46 -05:00
break;
2018-10-03 15:27:13 -05:00
case "/api/blockchain":
githubUrl = "https://github.com/lbryio/lbrycrd/blob/add_api_docs_scripts/contrib/devtools/generated/api_v1.json";
break;
case "/api/sdk":
githubUrl = "https://github.com/lbryio/lbry/blob/master/docs/api.json";
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}"
rel="noopener noreferrer"
2018-10-03 15:27:13 -05:00
target="_blank"
2018-08-28 18:57:18 -05:00
title="${config.github.linkText}"
>${config.github.linkText}</a>
2018-07-12 10:21:42 -05:00
`;
2018-10-03 15:27:13 -05:00
};