@@ -31,13 +31,12 @@ async function toggleSidebar(visibility) {
3131async function loadChildren ( item , recursive ?: boolean ) {
3232 const el = document . querySelector ( '#view-file-tree' ) ;
3333 const apiBaseUrl = el . getAttribute ( 'data-api-base-url' ) ;
34- const response = await GET ( `${ apiBaseUrl } /tree/${ item ? item . path : '' } ?recursive=${ recursive ?? false } ` ) ;
34+ const response = await GET ( `${ apiBaseUrl } /tree/${ item ? item . path : '' } ?ref=& recursive=${ recursive ?? false } ` ) ;
3535 const json = await response . json ( ) ;
3636 if ( json instanceof Array ) {
3737 return json . map ( ( i ) => ( {
3838 name : i . name ,
3939 isFile : i . isFile ,
40- htmlUrl : i . html_url ,
4140 path : i . path ,
4241 children : i . children ,
4342 } ) ) ;
@@ -46,7 +45,10 @@ async function loadChildren(item, recursive?: boolean) {
4645}
4746
4847async function loadContent ( item ) {
49- document . querySelector ( '.repo-home-filelist' ) . innerHTML = `load content of ${ item . path } ` ;
48+ // todo: change path of `repo_path` `path_history`
49+ // load content by path (content based on home_content.tmpl)
50+ const response = await GET ( `${ window . location . href } ?only_content=true` ) ;
51+ document . querySelector ( '#path_content' ) . innerHTML = await response . text ( ) ;
5052}
5153
5254export async function initViewFileTreeSidebar ( ) {
@@ -63,13 +65,14 @@ export async function initViewFileTreeSidebar() {
6365
6466 const fileTree = document . querySelector ( '#view-file-tree' ) ;
6567 const treePath = fileTree . getAttribute ( 'data-tree-path' ) ;
68+ const basePath = window . location . href . replace ( treePath , '' ) ;
6669 const selectedItem = ref ( treePath ) ;
6770
6871 const files = await loadChildren ( { path : treePath } , true ) ;
6972
7073 fileTree . classList . remove ( 'is-loading' ) ;
7174 const fileTreeView = createApp ( ViewFileTree , { files, selectedItem, loadChildren, loadContent : ( item ) => {
72- window . history . pushState ( null , null , item . htmlUrl ) ;
75+ window . history . pushState ( null , null , ` ${ basePath } ${ item . path } ` ) ;
7376 selectedItem . value = item . path ;
7477 loadContent ( item ) ;
7578 } } ) ;
0 commit comments