diff --git a/bin/post-preview-url-comment/index.node.test.ts b/bin/post-preview-url-comment/index.node.test.ts index e2549d0e2f0a7ae..2aca2c7cd2fb545 100644 --- a/bin/post-preview-url-comment/index.node.test.ts +++ b/bin/post-preview-url-comment/index.node.test.ts @@ -63,13 +63,13 @@ describe("filenameToPath", () => { test("changelog", () => { expect( - filenameToPath("src/content/changelogs-next/2025-02-05-title.mdx"), + filenameToPath("src/content/changelog/workers/2025-02-05-title.mdx"), ).toEqual("changelog/2025-02-05-title/"); }); test("changelog base", () => { expect( - `${DOCS_BASE_URL}/${filenameToPath("src/content/changelogs-next/2025-02-05-title.mdx")}`, + `${DOCS_BASE_URL}/${filenameToPath("src/content/changelog/workers/2025-02-05-title.mdx")}`, ).toEqual("https://developers.cloudflare.com/changelog/2025-02-05-title/"); }); }); diff --git a/bin/post-preview-url-comment/index.ts b/bin/post-preview-url-comment/index.ts index 5430a0f762f8984..85c4cd4d0c63917 100644 --- a/bin/post-preview-url-comment/index.ts +++ b/bin/post-preview-url-comment/index.ts @@ -77,7 +77,7 @@ async function run(): Promise { (file) => file.filename.endsWith(".mdx") && (file.filename.startsWith(`${CONTENT_BASE_PATH}/docs/`) || - file.filename.startsWith(`${CONTENT_BASE_PATH}/changelogs-next/`)), + file.filename.startsWith(`${CONTENT_BASE_PATH}/changelog/`)), ) .sort((a, b) => b.changes - a.changes) .slice(0, 15) // Limit to 15 entries diff --git a/bin/post-preview-url-comment/util.ts b/bin/post-preview-url-comment/util.ts index 1640e482569c7ff..cab02a7047602d5 100644 --- a/bin/post-preview-url-comment/util.ts +++ b/bin/post-preview-url-comment/util.ts @@ -3,20 +3,24 @@ import { execSync } from "node:child_process"; import { CONTENT_BASE_PATH } from "./constants"; export const filenameToPath = (filename: string) => { - return filename + const segments = filename .replace(CONTENT_BASE_PATH, "") .replace(".mdx", "") .split("/") - .filter(Boolean) + .filter(Boolean); + + const changelogIdx = segments.findIndex((s) => s === "changelog"); + + if (changelogIdx !== -1) { + segments.splice(changelogIdx + 1, 1); + } + + return segments .flatMap((segment) => { if (segment === "docs") { return []; } - if (segment === "changelogs-next") { - segment = "changelog"; - } - const slugified = slug(segment); if (slugified === "1111") {