Skip to content

Commit

Permalink
Fix the GH pages generation
Browse files Browse the repository at this point in the history
  • Loading branch information
petermuessig committed Jan 30, 2024
1 parent e67aa48 commit e0936db
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tools/prepare-gh-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function zipDirectory(sourceDir, outPath) {
if (existsSync(join(process.cwd(), "dist"))) {
rmSync(join(process.cwd(), "dist"), { recursive: true });
}
/*
mkdirSync(join(process.cwd(), "dist"), { recursive: true });
await Promise.all(steps.map((step) => {
return zipDirectory(join(process.cwd(), "steps", step), join(process.cwd(), "dist", `ui5-typescript-walkthrough-step-${step}.zip`))
Expand All @@ -43,10 +42,9 @@ function zipDirectory(sourceDir, outPath) {
cwd: join(process.cwd(), "steps", step)
});
}
*/

function rewriteLinks(file) {
let content = `---\npermalink: README.md\n---\n\n${readFileSync(file, { encoding: "utf8"})}`;
function rewriteLinks(file, path) {
let content = `---\npermalink: ${path ? path.replace(".md", ".html") : "index.html"}\n---\n\n${readFileSync(file, { encoding: "utf8"})}`;
content = content.replace(/steps\/(\d{2})/g, "step-$1");
content = content.replace(/\.\.\/(\d{2})/g, "../step-$1");
content = content.replace(/README\.md/g, "README.html");
Expand All @@ -61,7 +59,7 @@ function zipDirectory(sourceDir, outPath) {
const [, path, step] = readme.match("steps/((.*)/README.md)");
mkdirSync(join(process.cwd(), `dist/step-${step}`), { recursive: true });
copyFileSync(join(process.cwd(), readme), join(process.cwd(), `dist/step-${path}`));
rewriteLinks(join(process.cwd(), `dist/step-${path}`));
rewriteLinks(join(process.cwd(), `dist/step-${path}`), `step-${path}`);
});

}());

0 comments on commit e0936db

Please sign in to comment.