Skip to content

Commit aac3960

Browse files
authored
fix(ci): correct tutorial preview URL generation in sync-untranslated-issue script (#1118)
1 parent e93b833 commit aac3960

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

.github/scripts/sync-untranslated-issue.mjs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,29 @@ const CATEGORY_EMOJIS = {
6262
/** @type {string[]} */
6363
const CATEGORY_ORDER = ['guide', 'tutorial', 'reference', 'best-practices', 'cli', 'tools', 'ecosystem', 'app', 'other'];
6464

65+
/**
66+
* Generate preview path from file path
67+
* @param {string} filepath - File path relative to adev-ja
68+
* @returns {string} Preview path for angular.jp
69+
*/
70+
function generatePreviewPath(filepath) {
71+
const basePath = filepath
72+
.replace('src/content/', '')
73+
.replace(/\/README\.md$/, '') // READMEの場合はディレクトリのみ
74+
.replace(/\.md$/, '');
75+
76+
// チュートリアルの特殊なパス変換
77+
if (basePath.startsWith('tutorials/')) {
78+
// tutorials/first-app/intro -> tutorials/first-app
79+
// tutorials/first-app/steps/01-hello-world -> tutorials/first-app/01-hello-world
80+
return basePath
81+
.replace(/\/intro$/, '') // intro ディレクトリを削除
82+
.replace(/\/steps\//, '/'); // steps/ を削除
83+
}
84+
85+
return basePath;
86+
}
87+
6588
/**
6689
* Generate URLs for a file
6790
* @param {string} filepath - File path relative to adev-ja
@@ -78,14 +101,9 @@ function generateLinks(filepath) {
78101
const issueUrl = `https://github.com/angular/angular-ja/issues/new?template=translation-checkout.md&title=${encodeURIComponent('translate: ' + title)}`;
79102

80103
// .mdファイルのみプレビューURL生成
81-
let previewUrl = null;
82-
if (filepath.endsWith('.md')) {
83-
const previewPath = filepath
84-
.replace('src/content/', '')
85-
.replace(/\/README\.md$/, '') // READMEの場合はディレクトリのみ
86-
.replace(/\.md$/, '');
87-
previewUrl = `https://angular.jp/${previewPath}`;
88-
}
104+
const previewUrl = filepath.endsWith('.md')
105+
? `https://angular.jp/${generatePreviewPath(filepath)}`
106+
: null;
89107

90108
return { githubUrl, previewUrl, issueUrl };
91109
}

0 commit comments

Comments
 (0)