@@ -8,31 +8,31 @@ import {
88} from "../helpers/github.ts" ;
99import matter from "gray-matter" ;
1010
11- export function entriesGitHubLoader ( repository : string , directory : string ) : Loader {
11+ export function entriesGitHubLoader ( repository : string , branch : string , directory : string ) : Loader {
1212 return {
1313 name : 'github-entries-loader' ,
1414 load : async ( context : LoaderContext ) : Promise < void > => {
1515 const regex = new RegExp ( `^${ directory } /[^/]+/entry\.mdx?$` ) ;
16- await loadFilesWithRegex ( repository , regex , context ) ;
16+ await loadFilesWithRegex ( repository , branch , regex , context ) ;
1717 }
1818 } ;
1919}
2020
21- export function simpleGitHubLoader ( repository : string , directory : string ) : Loader {
21+ export function simpleGitHubLoader ( repository : string , branch : string , directory : string ) : Loader {
2222 return {
2323 name : 'github-simple-loader' ,
2424 load : async ( context : LoaderContext ) : Promise < void > => {
2525 const regex = new RegExp ( `^${ directory } /[^/]+\.mdx?$` ) ;
26- await loadSimpleFilesWithRegex ( repository , directory , regex , context ) ;
26+ await loadSimpleFilesWithRegex ( repository , branch , directory , regex , context ) ;
2727 }
2828 } ;
2929}
3030
31- export function kvpGitHubLoader ( repository : string , file : string , idKey : string , valueKey : string ) : Loader {
31+ export function kvpGitHubLoader ( repository : string , branch : string , file : string , idKey : string , valueKey : string ) : Loader {
3232 return {
3333 name : 'github-kvp-loader' ,
3434 load : async ( context : LoaderContext ) : Promise < void > => {
35- let kvp = await getKeyValueList ( repository , file ) ;
35+ let kvp = await getKeyValueList ( repository , branch , file ) ;
3636
3737 let toStore = Object . entries ( kvp ) . map ( ( [ key , value ] ) => ( {
3838 id : key ,
@@ -47,14 +47,14 @@ export function kvpGitHubLoader(repository: string, file: string, idKey: string,
4747 } ;
4848}
4949
50- async function loadFilesWithRegex ( repository : string , regex : RegExp , context : LoaderContext ) : Promise < void > {
51- const tree = await fetchRepoTree ( repository ) ;
50+ async function loadFilesWithRegex ( repository : string , branch : string , regex : RegExp , context : LoaderContext ) : Promise < void > {
51+ const tree = await fetchRepoTree ( repository , branch ) ;
5252 const entryFiles = tree . filter ( file =>
5353 file . type === 'blob' && regex . test ( file . path )
5454 ) ;
5555
5656 for ( const file of entryFiles ) {
57- const rawContent = await fetchFileContent ( repository , file . path ) ;
57+ const rawContent = await fetchFileContent ( repository , branch , file . path ) ;
5858 const { data, content} = matter ( rawContent ) ;
5959 const id = file . path . replace ( '/entry.mdx' , '' ) . replace ( 'entry.md' , '' )
6060
@@ -74,14 +74,14 @@ async function loadFilesWithRegex(repository: string, regex: RegExp, context: Lo
7474 }
7575}
7676
77- async function loadSimpleFilesWithRegex ( repository : string , directory : string , regex : RegExp , context : LoaderContext ) : Promise < void > {
78- const tree = await fetchRepoTree ( repository ) ;
77+ async function loadSimpleFilesWithRegex ( repository : string , branch : string , directory : string , regex : RegExp , context : LoaderContext ) : Promise < void > {
78+ const tree = await fetchRepoTree ( repository , branch ) ;
7979 const entryFiles = tree . filter ( file =>
8080 file . type === 'blob' && regex . test ( file . path )
8181 ) ;
8282
8383 for ( const file of entryFiles ) {
84- const rawContent = await fetchFileContent ( repository , file . path ) ;
84+ const rawContent = await fetchFileContent ( repository , branch , file . path ) ;
8585 const { data, content} = matter ( rawContent ) ;
8686 const id = file . path . replace ( '.mdx' , '' ) . replace ( '.md' , '' ) . replace ( '/entry.mdx' , '' ) . replace ( `${ directory } /` , '' )
8787
0 commit comments