@@ -38,6 +38,7 @@ export class TranslationStatusBuilder {
38
38
targetLanguages : string [ ] ;
39
39
languageLabels : { [ key : string ] : string } ;
40
40
githubRepo : string ;
41
+ gitHubRef : string ;
41
42
githubToken ?: string | undefined ;
42
43
} ) {
43
44
this . pageSourceDir = config . pageSourceDir ;
@@ -46,6 +47,7 @@ export class TranslationStatusBuilder {
46
47
this . targetLanguages = config . targetLanguages ;
47
48
this . languageLabels = config . languageLabels ;
48
49
this . githubRepo = config . githubRepo ;
50
+ this . githubRef = config . gitHubRef ;
49
51
this . githubToken = config . githubToken ?? '' ;
50
52
this . git = simpleGit ( {
51
53
maxConcurrentProcesses : Math . max ( 2 , Math . min ( 32 , os . cpus ( ) . length ) ) ,
@@ -58,6 +60,7 @@ export class TranslationStatusBuilder {
58
60
readonly targetLanguages ;
59
61
readonly languageLabels ;
60
62
readonly githubRepo ;
63
+ readonly githubRef ;
61
64
readonly githubToken ;
62
65
readonly git ;
63
66
@@ -252,7 +255,6 @@ export class TranslationStatusBuilder {
252
255
253
256
getPageUrl ( {
254
257
type = 'blob' ,
255
- refName = 'main' ,
256
258
lang,
257
259
subpath,
258
260
query = '' ,
@@ -263,9 +265,9 @@ export class TranslationStatusBuilder {
263
265
subpath : string ;
264
266
query ?: string ;
265
267
} ) {
266
- const noDotSrcDir = this . pageSourceDir . replace ( / ^ \. + \/ / , '' ) ;
268
+ const noDotSrcDir = this . pageSourceDir . replaceAll ( / \. + \/ / g , '' ) ;
267
269
const isSrcLang = lang === this . sourceLanguage ;
268
- return `https://github.com/${ this . githubRepo } /${ type } /${ refName } /${ noDotSrcDir } ${
270
+ return `https://github.com/${ this . githubRepo } /${ type } /${ this . githubRef } /${ noDotSrcDir } ${
269
271
isSrcLang ? '' : `/${ lang } `
270
272
} /${ subpath } ${ query } `;
271
273
}
@@ -427,7 +429,9 @@ export class TranslationStatusBuilder {
427
429
*/
428
430
renderCreatePageButton ( lang : string , filename : string ) : string {
429
431
// We include `lang` twice because GitHub eats the last path segment when setting filename.
430
- const createUrl = new URL ( `https://github.com/${ this . githubRepo } /new/main/src/content/docs` ) ;
432
+ const createUrl = new URL (
433
+ `https://github.com/${ this . githubRepo } /new/${ this . githubRef } /src/content/docs`
434
+ ) ;
431
435
createUrl . searchParams . set ( 'filename' , lang + '/' + filename ) ;
432
436
createUrl . searchParams . set ( 'value' , '---\ntitle:\ndescription:\n---\n' ) ;
433
437
return this . renderLink ( createUrl . href , `Create\xa0page\xa0+` , 'create-button' ) ;
0 commit comments