@@ -11,7 +11,7 @@ export async function ensureGitHubPagesWorkflow(getCurrentGitBranch, writeText,
1111 ? ` env:
1212 GITHUB_ACTIONS: "true"
1313 GITHUB_REPOSITORY: \${{ github.repository }}
14- GITPAGEDOCS_BASE_PATH : "/\${{ github.event.repository.name }}/ ${ pathSegment } "`
14+ GITPAGEDOCS_PATH : "${ pathSegment } "`
1515 : ` env:
1616 GITHUB_ACTIONS: "true"
1717 GITHUB_REPOSITORY: \${{ github.repository }}` ;
7474 working-directory: .gitpagedocs-runtime
7575${ buildEnvBlock }
7676
77+ - name: Relocate output to custom docs path
78+ if: \${{ env.GITPAGEDOCS_PATH != '' }}
79+ run: |
80+ mkdir -p .gitpagedocs-runtime/out_new/\${{ env.GITPAGEDOCS_PATH }}
81+ mv .gitpagedocs-runtime/out/* .gitpagedocs-runtime/out_new/\${{ env.GITPAGEDOCS_PATH }}/
82+ rm -rf .gitpagedocs-runtime/out
83+ mv .gitpagedocs-runtime/out_new .gitpagedocs-runtime/out
84+
7785 - name: Force root URL to docs entrypoint
7886 env:
7987 GITHUB_REPOSITORY: \${{ github.repository }}
@@ -83,6 +91,7 @@ ${buildEnvBlock}
8391 const path = require('path');
8492 const pathSegment = ${ JSON . stringify ( pathSegment ) } ;
8593 const repoName = (process.env.GITHUB_REPOSITORY || '').split('/')[1] || '';
94+ const isUserPage = repoName.toLowerCase().endsWith('.github.io');
8695 const rootRedirectBase = pathSegment;
8796 const cfgPath = path.join('.gitpagedocs-runtime', 'gitpagedocs', 'config.json');
8897 if (!fs.existsSync(cfgPath)) process.exit(0);
@@ -96,7 +105,7 @@ ${buildEnvBlock}
96105 const rootHtml = '<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="refresh" content="0;url=' + redirectTargetRoot + '"/><script>window.location.replace("' + redirectTargetRoot + '" + (window.location.search || ""));</script></head><body>Redirecting...</body></html>';
97106 fs.writeFileSync(path.join('.gitpagedocs-runtime', 'out', 'index.html'), rootHtml);
98107 const projectPathSegments = [];
99- if (repoName) projectPathSegments.push(repoName);
108+ if (repoName && !isUserPage ) projectPathSegments.push(repoName);
100109 if (pathSegment) projectPathSegments.push(pathSegment);
101110 if (projectPathSegments.length > 0) {
102111 const projectIndexPath = path.join('.gitpagedocs-runtime', 'out', ...projectPathSegments, 'index.html');
0 commit comments