From 17aab8d26a49263db322ce2dbcd291a8a3f54c51 Mon Sep 17 00:00:00 2001 From: Suguru Inatomi Date: Fri, 21 Nov 2025 20:59:21 +0900 Subject: [PATCH] fix(ci): correct tutorial preview URL generation in sync-untranslated-issue script --- .github/scripts/sync-untranslated-issue.mjs | 34 ++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/scripts/sync-untranslated-issue.mjs b/.github/scripts/sync-untranslated-issue.mjs index 75f2db2a9..52679d2fd 100644 --- a/.github/scripts/sync-untranslated-issue.mjs +++ b/.github/scripts/sync-untranslated-issue.mjs @@ -62,6 +62,29 @@ const CATEGORY_EMOJIS = { /** @type {string[]} */ const CATEGORY_ORDER = ['guide', 'tutorial', 'reference', 'best-practices', 'cli', 'tools', 'ecosystem', 'app', 'other']; +/** + * Generate preview path from file path + * @param {string} filepath - File path relative to adev-ja + * @returns {string} Preview path for angular.jp + */ +function generatePreviewPath(filepath) { + const basePath = filepath + .replace('src/content/', '') + .replace(/\/README\.md$/, '') // READMEの場合はディレクトリのみ + .replace(/\.md$/, ''); + + // チュートリアルの特殊なパス変換 + if (basePath.startsWith('tutorials/')) { + // tutorials/first-app/intro -> tutorials/first-app + // tutorials/first-app/steps/01-hello-world -> tutorials/first-app/01-hello-world + return basePath + .replace(/\/intro$/, '') // intro ディレクトリを削除 + .replace(/\/steps\//, '/'); // steps/ を削除 + } + + return basePath; +} + /** * Generate URLs for a file * @param {string} filepath - File path relative to adev-ja @@ -78,14 +101,9 @@ function generateLinks(filepath) { const issueUrl = `https://github.com/angular/angular-ja/issues/new?template=translation-checkout.md&title=${encodeURIComponent('translate: ' + title)}`; // .mdファイルのみプレビューURL生成 - let previewUrl = null; - if (filepath.endsWith('.md')) { - const previewPath = filepath - .replace('src/content/', '') - .replace(/\/README\.md$/, '') // READMEの場合はディレクトリのみ - .replace(/\.md$/, ''); - previewUrl = `https://angular.jp/${previewPath}`; - } + const previewUrl = filepath.endsWith('.md') + ? `https://angular.jp/${generatePreviewPath(filepath)}` + : null; return { githubUrl, previewUrl, issueUrl }; }