@@ -80,27 +80,35 @@ export default defineComponent({
8080      throw  new  Error ( 'If you want to use `GithubLink` component, you must specify: `owner`, `repo` and `branch`.' ) 
8181    } 
8282
83-     // eslint-disable-next-line vue/no-setup-props-destructure 
84-     let  {  repo,  owner,  branch,  contentDir }  =  props 
85-     let  prefix  =  '' 
86-     const  {  sources }  =  useRuntimeConfig ( ) . content 
87-     let  source 
88-     for  ( const  key  in  Object . keys ( sources ) )  { 
89-       if  ( props . page . _id . startsWith ( key ) )  { 
90-         source  =  sources [ key ] 
91-         break 
83+     const  source  =  computed ( ( )  =>  { 
84+       let  {  repo,  owner,  branch,  contentDir }  =  props 
85+       let  prefix  =  '' 
86+ 
87+       // Resolve source from content sources 
88+       if  ( useRuntimeConfig ( ) ?. public ?. content )  { 
89+         let  source 
90+         const  {  sources }  =  useRuntimeConfig ( ) . public . content 
91+ 
92+         for  ( const  key  in  sources  ||  [ ] )  { 
93+           if  ( props . page . _id . startsWith ( key ) )  { 
94+             source  =  sources [ key ] 
95+             break 
96+           } 
97+         } 
98+ 
99+         if  ( source ?. driver  ===  'github' )  { 
100+           repo  =  source . repo  ||  props . repo  ||  '' 
101+           owner  =  source . owner  ||  props . owner  ||  '' 
102+           branch  =  source . branch  ||  props . branch  ||  'main' 
103+           contentDir  =  source . dir  ||  props . contentDir  ||  '' 
104+           prefix  =  source . prefix  ||  '' 
105+         } 
92106      } 
93-     } 
94107
95-     if  ( source ?. driver  ===  'github' )  { 
96-       repo  =  source . repo 
97-       owner  =  '' 
98-       branch  =  source . branch  ||  'main' 
99-       contentDir  =  source . dir  ||  '' 
100-       prefix  =  source . prefix  ||  '' 
101-     } 
108+       return  {  repo,  owner,  branch,  contentDir,  prefix } 
109+     } ) 
102110
103-     const  base  =  computed ( ( )  =>  joinURL ( 'https://github.com' ,  `${ owner } ${ repo }  ) ) 
111+     const  base  =  computed ( ( )  =>  joinURL ( 'https://github.com' ,  `${ source . value . owner } ${ source . value . repo }  ) ) 
104112
105113    const  path  =  computed ( ( )  =>  { 
106114      const  dirParts : string [ ]  =  [ ] 
@@ -109,10 +117,10 @@ export default defineComponent({
109117      // Create the URL from a document data. 
110118      if  ( props ?. page ?. _path )  { 
111119        // Use content dir 
112-         if  ( contentDir )  {  dirParts . push ( contentDir )  } 
120+         if  ( source . value . contentDir )  {  dirParts . push ( source . value . contentDir )  } 
113121
114122        // Get page file from page data 
115-         dirParts . push ( props . page . _file . substring ( prefix . length ) ) 
123+         dirParts . push ( props . page . _file . substring ( source . value . prefix . length ) ) 
116124
117125        return  dirParts 
118126      } 
@@ -138,7 +146,7 @@ export default defineComponent({
138146
139147      if  ( props . edit )  {  parts . push ( 'edit' )  }  else  {  parts . push ( 'tree' )  } 
140148
141-       parts . push ( branch ,  ...path . value ) 
149+       parts . push ( source . value . branch ,  ...path . value ) 
142150
143151      return  parts . filter ( Boolean ) . join ( '/' ) 
144152    } ) 
0 commit comments