From a0866b51e1250c3a01306a8f88018b83856cb87a Mon Sep 17 00:00:00 2001 From: Kian Newman-Hazel Date: Thu, 13 Feb 2025 20:56:50 +0000 Subject: [PATCH 1/4] [Docs Site] Show changelogs in changed files comment --- bin/post-preview-url-comment/index.node.test.ts | 4 ++-- bin/post-preview-url-comment/index.ts | 2 +- bin/post-preview-url-comment/util.ts | 16 ++++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) 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..c8a20d6f9f2995f 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 + let 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") { From 82eb836a4372c8f174d78d67039730f608217608 Mon Sep 17 00:00:00 2001 From: Kian Newman-Hazel Date: Thu, 13 Feb 2025 20:57:53 +0000 Subject: [PATCH 2/4] test file --- src/content/changelog/ai-gateway/2025-02-13-test.mdx | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/content/changelog/ai-gateway/2025-02-13-test.mdx diff --git a/src/content/changelog/ai-gateway/2025-02-13-test.mdx b/src/content/changelog/ai-gateway/2025-02-13-test.mdx new file mode 100644 index 000000000000000..efa79a5b8c1a8cf --- /dev/null +++ b/src/content/changelog/ai-gateway/2025-02-13-test.mdx @@ -0,0 +1,7 @@ +--- +title: test +description: test +date: 2025-02-13T00:00:00Z +--- + +test \ No newline at end of file From 7c91d1231931240cda0590324ebb3bce0fc9b6a3 Mon Sep 17 00:00:00 2001 From: Kian Date: Thu, 13 Feb 2025 21:03:40 +0000 Subject: [PATCH 3/4] Update bin/post-preview-url-comment/util.ts Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- bin/post-preview-url-comment/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/post-preview-url-comment/util.ts b/bin/post-preview-url-comment/util.ts index c8a20d6f9f2995f..cab02a7047602d5 100644 --- a/bin/post-preview-url-comment/util.ts +++ b/bin/post-preview-url-comment/util.ts @@ -3,7 +3,7 @@ import { execSync } from "node:child_process"; import { CONTENT_BASE_PATH } from "./constants"; export const filenameToPath = (filename: string) => { - let segments = filename + const segments = filename .replace(CONTENT_BASE_PATH, "") .replace(".mdx", "") .split("/") From a4310fc6f184276614101f2ff54cc2412acc15a2 Mon Sep 17 00:00:00 2001 From: Kian Newman-Hazel Date: Thu, 13 Feb 2025 21:26:18 +0000 Subject: [PATCH 4/4] remove test file --- src/content/changelog/ai-gateway/2025-02-13-test.mdx | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 src/content/changelog/ai-gateway/2025-02-13-test.mdx diff --git a/src/content/changelog/ai-gateway/2025-02-13-test.mdx b/src/content/changelog/ai-gateway/2025-02-13-test.mdx deleted file mode 100644 index efa79a5b8c1a8cf..000000000000000 --- a/src/content/changelog/ai-gateway/2025-02-13-test.mdx +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: test -description: test -date: 2025-02-13T00:00:00Z ---- - -test \ No newline at end of file