File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
src/components/github-buttons Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments