Skip to content

Commit 648a5a5

Browse files
lorenzolewissimonhyll
authored andcommitted
Fixes for non-main ref in translation status page (tauri-apps#1374)
* fixes for non-main ref Signed-off-by: Lorenzo Lewis <[email protected]> * fix edit link Signed-off-by: Lorenzo Lewis <[email protected]> * add comment Signed-off-by: Lorenzo Lewis <[email protected]> --------- Signed-off-by: Lorenzo Lewis <[email protected]>
1 parent c5cd7ac commit 648a5a5

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

astro.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ export default defineConfig({
2929
twitter: 'https://twitter.com/TauriApps',
3030
mastodon: 'https://fosstodon.org/@TauriApps',
3131
},
32+
// TODO: Be sure this is updated when the branch is switched
3233
editLink: {
33-
baseUrl: 'https://github.com/tauri-apps/tauri-docs/edit/starlight',
34+
baseUrl: 'https://github.com/tauri-apps/tauri-docs/edit/next',
3435
},
3536
customCss: ['./src/styles/custom.css'],
3637
sidebar: [

packages/i18n-tracker/build.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const translationStatusBuilder = new TranslationStatusBuilder({
1313
.filter((loc) => loc.lang !== 'en')
1414
.reduce((acc, curr) => ({ [curr.lang]: curr.label, ...acc }), {}),
1515
githubRepo: process.env.GITHUB_REPOSITORY || 'tauri-apps/tauri-docs',
16+
gitHubRef: 'next',
1617
githubToken: process.env.GITHUB_TOKEN,
1718
});
1819

packages/i18n-tracker/lib/translation-status/builder.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class TranslationStatusBuilder {
3838
targetLanguages: string[];
3939
languageLabels: { [key: string]: string };
4040
githubRepo: string;
41+
gitHubRef: string;
4142
githubToken?: string | undefined;
4243
}) {
4344
this.pageSourceDir = config.pageSourceDir;
@@ -46,6 +47,7 @@ export class TranslationStatusBuilder {
4647
this.targetLanguages = config.targetLanguages;
4748
this.languageLabels = config.languageLabels;
4849
this.githubRepo = config.githubRepo;
50+
this.githubRef = config.gitHubRef;
4951
this.githubToken = config.githubToken ?? '';
5052
this.git = simpleGit({
5153
maxConcurrentProcesses: Math.max(2, Math.min(32, os.cpus().length)),
@@ -58,6 +60,7 @@ export class TranslationStatusBuilder {
5860
readonly targetLanguages;
5961
readonly languageLabels;
6062
readonly githubRepo;
63+
readonly githubRef;
6164
readonly githubToken;
6265
readonly git;
6366

@@ -252,7 +255,6 @@ export class TranslationStatusBuilder {
252255

253256
getPageUrl({
254257
type = 'blob',
255-
refName = 'main',
256258
lang,
257259
subpath,
258260
query = '',
@@ -263,9 +265,9 @@ export class TranslationStatusBuilder {
263265
subpath: string;
264266
query?: string;
265267
}) {
266-
const noDotSrcDir = this.pageSourceDir.replace(/^\.+\//, '');
268+
const noDotSrcDir = this.pageSourceDir.replaceAll(/\.+\//g, '');
267269
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}${
269271
isSrcLang ? '' : `/${lang}`
270272
}/${subpath}${query}`;
271273
}
@@ -427,7 +429,9 @@ export class TranslationStatusBuilder {
427429
*/
428430
renderCreatePageButton(lang: string, filename: string): string {
429431
// 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+
);
431435
createUrl.searchParams.set('filename', lang + '/' + filename);
432436
createUrl.searchParams.set('value', '---\ntitle:\ndescription:\n---\n');
433437
return this.renderLink(createUrl.href, `Create\xa0page\xa0+`, 'create-button');

0 commit comments

Comments
 (0)