Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"build:watch": "lerna run build:alone:watch --scope=@dzcode.io/web --include-dependencies --parallel",
"bundle": "npm run build && npm run bundle:alone",
"bundle:alone": "cross-env NODE_ENV=production rsbuild build",
"bundle:preview": "rsbuild preview",
"bundle:doctor": "RSDOCTOR=true rsbuild build",
"clean": "lerna run clean:alone --scope=@dzcode.io/web --include-dependencies --stream",
"clean:alone": "rimraf dist coverage bundle node_modules/.cache && rimraf ./cloudflare/public",
Expand Down
15 changes: 8 additions & 7 deletions web/src/_build/gen-multiple-htmls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// for dev, run:
// npm run clean && npm run bundle && npm run generate:htmls
// npm run rsbuild preview
// npm run bundle:preview

import { join } from "path";
import { readFileSync, writeFileSync, mkdirSync } from "fs";
Expand All @@ -24,13 +24,14 @@ const SKIP_ROOT_HTML = process.env.SKIP_ROOT_HTML === "true";
console.log(`generating ${allPages.length} html files ...`);

allPages.forEach((pageInfo) => {
const pathName = pageInfo.uri;
const outputHtmlDir = join(distFolder, pathName);
const outputHtmlPath = join(outputHtmlDir, "index.html");
if (SKIP_ROOT_HTML && outputHtmlPath === indexHtmlPath) {
console.log(`skipping root html: ${outputHtmlPath}`);
let pathName = pageInfo.uri.replace(/\/$/, "");
pathName = `${pathName || "index"}.html`;
if (SKIP_ROOT_HTML && pathName === "index.html") {
console.log(`skipping root html`);
return;
}
const outputHtmlPath = join(distFolder, pathName);
const outputHtmlParentDir = join(outputHtmlPath, "..");

let newHtml = indexHtml;
newHtml = newHtml.replace(
Expand Down Expand Up @@ -58,7 +59,7 @@ allPages.forEach((pageInfo) => {
newHtml = newHtml.replace(/{{ogImage}}/g, pageInfo.ogImage);
newHtml = newHtml.replace(/{{sentryOrigin}}/g, `https://${SENTRY_ORIGIN}`);

mkdirSync(outputHtmlDir, { recursive: true });
mkdirSync(outputHtmlParentDir, { recursive: true });
writeFileSync(outputHtmlPath, newHtml);

console.log(outputHtmlPath, "✅");
Expand Down
2 changes: 1 addition & 1 deletion web/src/_build/gen-robots-txt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// for dev, run:
// npm run clean && npm run bundle && npm run generate:robots-txt
// npm run rsbuild preview
// npm run bundle:preview

import { join } from "path";
import { writeFileSync } from "fs";
Expand Down
8 changes: 8 additions & 0 deletions web/src/_build/pages/static-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ const staticURLs: PageInfoWithLocalKeys[] = [
"https://images.unsplash.com/photo-1526663089957-f2aa2776f572?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=750&q=80&auto=format&fit=crop&w=1200&h=627&q=80",
keywords: "faq, open-source, algeria, dzcode",
},
{
uri: "/404",
title: "notfound-title",
description: "notfound-description",
ogImage:
"https://images.unsplash.com/photo-1510133768164-a8f7e4d4e3dc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=750&q=80&auto=format&fit=crop&w=1200&h=627&q=80",
keywords: "faq, open-source, algeria, dzcode",
},
];

export const staticPages: PageInfo[] = staticURLs.reduce<PageInfo[]>(
Expand Down