Skip to content

Commit c2e0209

Browse files
Zinovii DmytrivZinovii Dmytriv
andauthored
Linked top GitHub button to component subfolder (#561)
* Fixed github button * Fixed github buttons --------- Co-authored-by: Zinovii Dmytriv <zinovii@gmail.com>
1 parent 97a6501 commit c2e0209

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/github-buttons/github-buttons.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ export default function GitHubButtons({custom_edit_url}) {
55
if (custom_edit_url == undefined) {
66
return (<div/>);
77
} else {
8-
const url = new URL(custom_edit_url);
9-
const parts = url.pathname.split('/');
8+
const url = new URL(custom_edit_url.replace('/blob/', '/tree/'));
109

11-
let repoFullName = parts[1] + '/' + parts[2];
10+
let parts = url.pathname.split('/');
11+
parts.shift();
12+
let repoFullName = parts[0] + '/' + parts[1];
13+
14+
parts.pop();
15+
const componentFolderPath = parts.join('/');
1216

1317
return (
1418
<div className="github_buttons">
1519
<ul>
1620
<li>
1721
<GitHubButton
18-
href={'https://github.com/' + repoFullName}
22+
href={'https://github.com/' + componentFolderPath}
1923
aria-label="Open GitHub">GitHub</GitHubButton>
2024
</li>
2125

0 commit comments

Comments
 (0)