From 07b7f524bf3da661bf362f3e0464ef879456a67e Mon Sep 17 00:00:00 2001 From: kodster28 Date: Thu, 24 Jul 2025 13:39:34 -0500 Subject: [PATCH 01/11] [Changelog] Metadata values --- src/components/overrides/Head.astro | 10 +++++++++- src/pages/changelog/[...slug].astro | 2 ++ src/schemas/base.ts | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/overrides/Head.astro b/src/components/overrides/Head.astro index 002d1af64b61e4f..bb02753000f3fac 100644 --- a/src/components/overrides/Head.astro +++ b/src/components/overrides/Head.astro @@ -30,7 +30,14 @@ const shouldChatbotDeprioritize = frontmatter.chatbot_deprioritize; if (currentSection) { - const product = await getEntry("products", currentSection); + let product = await getEntry("products", currentSection); + + if (currentSection === "changelog") { + const products = frontmatter.products + if (products) { + product = await getEntry("products", products[0]); + } + } if (product) { if (product.data.meta.title) { @@ -209,6 +216,7 @@ metaTags.map((attrs) => { attrs, }); }); + --- diff --git a/src/pages/changelog/[...slug].astro b/src/pages/changelog/[...slug].astro index 787091db4a3a84b..56d282685534443 100644 --- a/src/pages/changelog/[...slug].astro +++ b/src/pages/changelog/[...slug].astro @@ -35,6 +35,8 @@ const props = { template: "splash", noindex: note.data.hidden, chatbot_deprioritize: true, + pcx_content_type: "changelog-entry", + products: note.data.products.map(a => a.id), }, headings, hideTitle: true, diff --git a/src/schemas/base.ts b/src/schemas/base.ts index d432095725bf817..6eb9547e5abec19 100644 --- a/src/schemas/base.ts +++ b/src/schemas/base.ts @@ -25,6 +25,7 @@ export const baseSchema = ({ image }: SchemaContext) => .union([ z.literal("api"), z.literal("changelog"), + z.literal("changelog-entry"), z.literal("configuration"), z.literal("concept"), z.literal("design-guide"), From f1567a7e77c08e24863e6e3236871e7cefdba199 Mon Sep 17 00:00:00 2001 From: kodster28 Date: Thu, 24 Jul 2025 14:02:38 -0500 Subject: [PATCH 02/11] Hacky workaround (for now) --- src/components/overrides/Head.astro | 4 +++- src/content/docs/autorag/platform/release-note.mdx | 2 +- .../docs/hyperdrive/examples/connect-to-mysql/index.mdx | 2 +- src/content/docs/turnstile/migration/hcaptcha.mdx | 2 +- src/content/docs/turnstile/migration/index.mdx | 2 +- src/content/docs/turnstile/migration/recaptcha.mdx | 2 +- src/content/docs/workers/languages/python/examples.mdx | 2 +- src/content/docs/workers/languages/python/ffi.mdx | 2 +- .../docs/workers/languages/python/how-python-workers-work.mdx | 2 +- .../docs/workers/languages/python/packages/fastapi.mdx | 2 +- .../docs/workers/languages/python/packages/langchain.mdx | 2 +- src/content/docs/workers/languages/python/stdlib.mdx | 2 +- src/content/docs/workflows/build/local-development.mdx | 2 +- src/schemas/base.ts | 2 +- 14 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/overrides/Head.astro b/src/components/overrides/Head.astro index bb02753000f3fac..9b127dba583ec1b 100644 --- a/src/components/overrides/Head.astro +++ b/src/components/overrides/Head.astro @@ -129,9 +129,11 @@ if ( if (frontmatter.pcx_content_type) { ["pcx_content_type", "algolia_content_type"].map((name) => { + const contentType = frontmatter.pcx_content_type + const updatedName = (contentType?.charAt(0).toUpperCase() + contentType?.slice(1))?.replace("-", " ") metaTags.push({ name, - content: frontmatter.pcx_content_type as string, + content: updatedName as string, }); }); } diff --git a/src/content/docs/autorag/platform/release-note.mdx b/src/content/docs/autorag/platform/release-note.mdx index 96487b8e0a33f0b..88c9e1a5ab20d80 100644 --- a/src/content/docs/autorag/platform/release-note.mdx +++ b/src/content/docs/autorag/platform/release-note.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: Release notes +pcx_content_type: release-notes title: Release note release_notes_file_name: - autorag diff --git a/src/content/docs/hyperdrive/examples/connect-to-mysql/index.mdx b/src/content/docs/hyperdrive/examples/connect-to-mysql/index.mdx index f1da4356b4b152c..4879f3d030bfd7b 100644 --- a/src/content/docs/hyperdrive/examples/connect-to-mysql/index.mdx +++ b/src/content/docs/hyperdrive/examples/connect-to-mysql/index.mdx @@ -1,6 +1,6 @@ --- type: overview -pcx_content_type: content +pcx_content_type: example title: Connect to MySQL hideChildren: false sidebar: diff --git a/src/content/docs/turnstile/migration/hcaptcha.mdx b/src/content/docs/turnstile/migration/hcaptcha.mdx index 4a406ed880d3967..5c6f400f15790ac 100644 --- a/src/content/docs/turnstile/migration/hcaptcha.mdx +++ b/src/content/docs/turnstile/migration/hcaptcha.mdx @@ -1,6 +1,6 @@ --- title: Migrate from hCaptcha -pcx_content_type: migration +pcx_content_type: how-to sidebar: order: 2 diff --git a/src/content/docs/turnstile/migration/index.mdx b/src/content/docs/turnstile/migration/index.mdx index 5e7d3a34537ca96..31497c9f30d3215 100644 --- a/src/content/docs/turnstile/migration/index.mdx +++ b/src/content/docs/turnstile/migration/index.mdx @@ -1,6 +1,6 @@ --- title: Migration -pcx_content_type: migration +pcx_content_type: navigation sidebar: order: 2 --- diff --git a/src/content/docs/turnstile/migration/recaptcha.mdx b/src/content/docs/turnstile/migration/recaptcha.mdx index 736e3891720d9e6..443b324b8cc0a0c 100644 --- a/src/content/docs/turnstile/migration/recaptcha.mdx +++ b/src/content/docs/turnstile/migration/recaptcha.mdx @@ -1,6 +1,6 @@ --- title: Migrate from reCAPTCHA -pcx_content_type: migration +pcx_content_type: how-to sidebar: order: 1 diff --git a/src/content/docs/workers/languages/python/examples.mdx b/src/content/docs/workers/languages/python/examples.mdx index a083955863c2683..1cf0f80c1186bfd 100644 --- a/src/content/docs/workers/languages/python/examples.mdx +++ b/src/content/docs/workers/languages/python/examples.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: content +pcx_content_type: example title: Examples head: - tag: title diff --git a/src/content/docs/workers/languages/python/ffi.mdx b/src/content/docs/workers/languages/python/ffi.mdx index f8ff1e67299a2d7..b8f994c49e00a1b 100644 --- a/src/content/docs/workers/languages/python/ffi.mdx +++ b/src/content/docs/workers/languages/python/ffi.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: content +pcx_content_type: reference title: Foreign Function Interface (FFI) head: - tag: title diff --git a/src/content/docs/workers/languages/python/how-python-workers-work.mdx b/src/content/docs/workers/languages/python/how-python-workers-work.mdx index 2318c4cce0d3f15..9c4c7bad165139d 100644 --- a/src/content/docs/workers/languages/python/how-python-workers-work.mdx +++ b/src/content/docs/workers/languages/python/how-python-workers-work.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: content +pcx_content_type: concept title: How Python Workers Work sidebar: order: 1 diff --git a/src/content/docs/workers/languages/python/packages/fastapi.mdx b/src/content/docs/workers/languages/python/packages/fastapi.mdx index b57cd40b4623050..2e8f6b80bc596f1 100644 --- a/src/content/docs/workers/languages/python/packages/fastapi.mdx +++ b/src/content/docs/workers/languages/python/packages/fastapi.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: content +pcx_content_type: reference title: FastAPI head: - tag: title diff --git a/src/content/docs/workers/languages/python/packages/langchain.mdx b/src/content/docs/workers/languages/python/packages/langchain.mdx index f67b14de02d15ad..497340e50e2ec5f 100644 --- a/src/content/docs/workers/languages/python/packages/langchain.mdx +++ b/src/content/docs/workers/languages/python/packages/langchain.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: content +pcx_content_type: reference title: Langchain head: - tag: title diff --git a/src/content/docs/workers/languages/python/stdlib.mdx b/src/content/docs/workers/languages/python/stdlib.mdx index 4f6ecb51f8720e7..e2b997708bff453 100644 --- a/src/content/docs/workers/languages/python/stdlib.mdx +++ b/src/content/docs/workers/languages/python/stdlib.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: content +pcx_content_type: reference title: Standard Library sidebar: order: 3 diff --git a/src/content/docs/workflows/build/local-development.mdx b/src/content/docs/workflows/build/local-development.mdx index a72947b9fd234e4..9ae0959a8c3d8c2 100644 --- a/src/content/docs/workflows/build/local-development.mdx +++ b/src/content/docs/workflows/build/local-development.mdx @@ -1,6 +1,6 @@ --- title: Local Development -pcx_content_type: build +pcx_content_type: reference updated: 2024-11-27 sidebar: order: 8 diff --git a/src/schemas/base.ts b/src/schemas/base.ts index 6eb9547e5abec19..a42205950fe7603 100644 --- a/src/schemas/base.ts +++ b/src/schemas/base.ts @@ -23,7 +23,6 @@ export const baseSchema = ({ image }: SchemaContext) => ), pcx_content_type: z .union([ - z.literal("api"), z.literal("changelog"), z.literal("changelog-entry"), z.literal("configuration"), @@ -41,6 +40,7 @@ export const baseSchema = ({ image }: SchemaContext) => z.literal("reference"), z.literal("reference-architecture"), z.literal("reference-architecture-diagram"), + z.literal("release-notes"), z.literal("troubleshooting"), z.literal("tutorial"), z.literal("video"), From b732fe0c0375cbf490e9faceb1715159e8d13d5b Mon Sep 17 00:00:00 2001 From: kodster28 Date: Thu, 24 Jul 2025 14:52:48 -0500 Subject: [PATCH 03/11] Fix failure --- .../2025-03-27-automatic-audit-logs-beta-release.mdx | 1 + src/content/products/audit-logs.yaml | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/content/changelog/audit-logs/2025-03-27-automatic-audit-logs-beta-release.mdx b/src/content/changelog/audit-logs/2025-03-27-automatic-audit-logs-beta-release.mdx index be90d517dc75b29..a63a4883e33a5be 100644 --- a/src/content/changelog/audit-logs/2025-03-27-automatic-audit-logs-beta-release.mdx +++ b/src/content/changelog/audit-logs/2025-03-27-automatic-audit-logs-beta-release.mdx @@ -3,6 +3,7 @@ title: Audit logs (version 2) - Beta Release description: New version of audit logs date: 2025-03-27 --- + The latest version of audit logs streamlines audit logging by automatically capturing all user and system actions performed through the Cloudflare Dashboard or public APIs. This update leverages Cloudflare’s existing API Shield to generate audit logs based on OpenAPI schemas, ensuring a more consistent and automated logging process. Availability: Audit logs (version 2) is now in Beta, with support limited to **API access**. diff --git a/src/content/products/audit-logs.yaml b/src/content/products/audit-logs.yaml index 45def0f70835307..808370236ecf675 100644 --- a/src/content/products/audit-logs.yaml +++ b/src/content/products/audit-logs.yaml @@ -5,3 +5,7 @@ product: group: Core platform url: /fundamentals/account/account-security/review-audit-logs/ show: false + +meta: + title: Cloudflare Audit Logs docs + author: "@cloudflare" \ No newline at end of file From 855207090c624e468b9fac9a0203149d703c1b8b Mon Sep 17 00:00:00 2001 From: kodster28 Date: Fri, 25 Jul 2025 09:49:10 -0500 Subject: [PATCH 04/11] slight refactor --- src/components/overrides/Head.astro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/overrides/Head.astro b/src/components/overrides/Head.astro index 9b127dba583ec1b..dd7fcde0a5fc561 100644 --- a/src/components/overrides/Head.astro +++ b/src/components/overrides/Head.astro @@ -130,10 +130,10 @@ if ( if (frontmatter.pcx_content_type) { ["pcx_content_type", "algolia_content_type"].map((name) => { const contentType = frontmatter.pcx_content_type - const updatedName = (contentType?.charAt(0).toUpperCase() + contentType?.slice(1))?.replace("-", " ") + const updatedName = contentType ? (contentType.charAt(0).toUpperCase() + contentType.slice(1)).replace("-", " ") : "" metaTags.push({ name, - content: updatedName as string, + content: updatedName, }); }); } From d743c7152045be953e601371f8692e1d9e6ae79b Mon Sep 17 00:00:00 2001 From: kodster28 Date: Fri, 25 Jul 2025 10:09:00 -0500 Subject: [PATCH 05/11] partial --- src/content/products/risk-score.yaml | 3 +++ src/pages/workers-ai/models/[name].astro | 1 + 2 files changed, 4 insertions(+) diff --git a/src/content/products/risk-score.yaml b/src/content/products/risk-score.yaml index 00ba51800e48bda..9000d3d88d3d321 100644 --- a/src/content/products/risk-score.yaml +++ b/src/content/products/risk-score.yaml @@ -5,3 +5,6 @@ product: group: Cloudflare One url: /cloudflare-one/insights/risk-score/ show: false + +meta: + title: Cloudflare Risk Score docs \ No newline at end of file diff --git a/src/pages/workers-ai/models/[name].astro b/src/pages/workers-ai/models/[name].astro index f37151f8e672bd9..a833a3ae2e96308 100644 --- a/src/pages/workers-ai/models/[name].astro +++ b/src/pages/workers-ai/models/[name].astro @@ -123,6 +123,7 @@ const starlightPageProps = { frontmatter: { title: name, description, + pcx_content_type: "reference", }, headings: [ hasPlayground From 08d623b41e1d4e83b638109d68268bde5ea143a2 Mon Sep 17 00:00:00 2001 From: kodster28 Date: Fri, 25 Jul 2025 11:39:48 -0500 Subject: [PATCH 06/11] Refactor code for clarity --- src/components/overrides/Head.astro | 51 +++++++++++++++-------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/components/overrides/Head.astro b/src/components/overrides/Head.astro index dd7fcde0a5fc561..8f644a079458a79 100644 --- a/src/components/overrides/Head.astro +++ b/src/components/overrides/Head.astro @@ -29,9 +29,11 @@ const shouldChatbotDeprioritize = frontmatter.sidebar.hidden || frontmatter.chatbot_deprioritize; +// if not a top-level page, add metadata values from src/content/products/ entries if (currentSection) { + // if entry for product, grab and proceed let product = await getEntry("products", currentSection); - + // if entry for changelog, grab the first product value (which corresponds to the folder the entry is in) and use as the primary "product" if (currentSection === "changelog") { const products = frontmatter.products if (products) { @@ -40,34 +42,33 @@ if (currentSection) { } if (product) { - if (product.data.meta.title) { - const titleIdx = head.findIndex((x) => x.tag === "title"); + let productMetaName = product.data.meta.title ? product.data.meta.title : "Cloudflare Docs"; + + if (currentSection === "changelog") { + productMetaName = "Changelog" + } - let title: string; + console.log(productMetaName) + const titleIdx = head.findIndex((x) => x.tag === "title"); - if (titleIdx !== -1) { - const existingTitle = head[titleIdx].content?.split( + let title: string; + + // Prefer the title set via frontmatter.head.title. If not, grab the regular frontmatter title value. + const existingTitle = head[titleIdx].content ? head[titleIdx].content?.split( ` ${DEFAULT_TITLE_DELIMITER} `, - )[0]; - title = `${existingTitle} · ${product.data.meta.title}`; - - head[titleIdx] = { - tag: "title", - content: title, - }; - } else { - title = `${frontmatter.title} · ${product.data.meta.title}`; - head.push({ - tag: "title", - content: title, - }); - } + )[0]: frontmatter.title; - metaTags.push({ - property: "og:title", - content: title, - }); - } + title = `${existingTitle} · ${productMetaName}`; + + head[titleIdx] = { + tag: "title", + content: title, + }; + + metaTags.push({ + property: "og:title", + content: title, + }); if (product.data.product.title) { ["pcx_product", "algolia_product_filter"].map((name) => { From cc617acc8c6228fb532ad4b572d92ecd2338ca11 Mon Sep 17 00:00:00 2001 From: kodster28 Date: Fri, 25 Jul 2025 11:41:29 -0500 Subject: [PATCH 07/11] remove logging --- src/components/overrides/Head.astro | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/overrides/Head.astro b/src/components/overrides/Head.astro index 8f644a079458a79..fa44c498bb54d09 100644 --- a/src/components/overrides/Head.astro +++ b/src/components/overrides/Head.astro @@ -48,9 +48,7 @@ if (currentSection) { productMetaName = "Changelog" } - console.log(productMetaName) const titleIdx = head.findIndex((x) => x.tag === "title"); - let title: string; // Prefer the title set via frontmatter.head.title. If not, grab the regular frontmatter title value. From b1a4b2982094c01aaa5a4d0e7a8382d03889edca Mon Sep 17 00:00:00 2001 From: kodster28 Date: Fri, 25 Jul 2025 11:55:15 -0500 Subject: [PATCH 08/11] remove other random value --- src/content/docs/use-cases/ai.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/use-cases/ai.mdx b/src/content/docs/use-cases/ai.mdx index 2da69992a5ad2b6..3ab10e940d1169d 100644 --- a/src/content/docs/use-cases/ai.mdx +++ b/src/content/docs/use-cases/ai.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: use_case +pcx_content_type: overview title: Build AI Applications head: - tag: title From 361d75b3a5d20319628471e17ca894c00806aa96 Mon Sep 17 00:00:00 2001 From: kodster28 Date: Fri, 25 Jul 2025 12:46:42 -0500 Subject: [PATCH 09/11] update --- src/content/docs/logs/logpush/logpush-job/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/logs/logpush/logpush-job/index.mdx b/src/content/docs/logs/logpush/logpush-job/index.mdx index 0ff0d1aef84ca46..7aaf6d587121dd7 100644 --- a/src/content/docs/logs/logpush/logpush-job/index.mdx +++ b/src/content/docs/logs/logpush/logpush-job/index.mdx @@ -1,5 +1,5 @@ --- -pcx_content_type: how-tp +pcx_content_type: navigation title: Logpush job setup sidebar: order: 2 From 684a4e6e439a9442b30f8d23a0d46a440d07509f Mon Sep 17 00:00:00 2001 From: kodster28 Date: Wed, 13 Aug 2025 08:46:01 -0500 Subject: [PATCH 10/11] update tests --- worker/index.worker.test.ts | 46 ++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/worker/index.worker.test.ts b/worker/index.worker.test.ts index 866e69d52a4f1e6..4da38a6fc3f9688 100644 --- a/worker/index.worker.test.ts +++ b/worker/index.worker.test.ts @@ -43,21 +43,6 @@ describe("Cloudflare Docs", () => { expect(response.headers.get("Location")).toBe("/products/"); }); - it("redirects /changelog-next/ to /changelog/", async () => { - const request = new Request("http://fakehost/changelog-next/"); - const response = await SELF.fetch(request, { redirect: "manual" }); - expect(response.status).toBe(301); - expect(response.headers.get("Location")).toBe("/changelog/"); - }); - - it("redirects /changelog-next/rss.xml to /changelog/rss.xml", async () => { - const request = new Request("http://fakehost/changelog-next/rss.xml"); - const response = await SELF.fetch(request, { redirect: "manual" }); - - expect(response.status).toBe(301); - expect(response.headers.get("Location")).toBe("/changelog/rss.xml"); - }); - it("redirects /workers/index.html.md to /workers/index.md", async () => { const request = new Request("http://fakehost/workers/index.html.md"); const response = await SELF.fetch(request, { redirect: "manual" }); @@ -241,15 +226,19 @@ describe("Cloudflare Docs", () => { const html = await response.text(); const dom = parse(html); - it("product meta tags", () => { + it("meta tags", () => { const product = dom.querySelector("meta[name='pcx_product']") ?.attributes.content; const group = dom.querySelector("meta[name='pcx_content_group']") ?.attributes.content; + const content_type = dom.querySelector("meta[name='pcx_content_type']") + ?.attributes.content; + expect(product).toBe("Workers"); expect(group).toBe("Developer platform"); + expect(content_type).toBe("Overview"); }); it("index.md rel='alternate' tag", () => { @@ -305,5 +294,30 @@ describe("Cloudflare Docs", () => { ); }); }); + describe("/changelog/ entry content types", async () => { + const request = new Request( + "http://fakehost/changelog/2025-03-03-saml-oidc-fields-saml-transformations/", + ); + const response = await SELF.fetch(request); + expect(response.status).toBe(200); + + const html = await response.text(); + const dom = parse(html); + + it("correct meta tags", () => { + const product = dom.querySelector("meta[name='pcx_product']") + ?.attributes.content; + + const group = dom.querySelector("meta[name='pcx_content_group']") + ?.attributes.content; + + const content_type = dom.querySelector("meta[name='pcx_content_type']") + ?.attributes.content; + + expect(product).toBe("Access"); + expect(group).toBe("Cloudflare One"); + expect(group).toBe("Changelog entry"); + }); + }); }); }); From fd711f5548e99e079d05569cd65c570e0860339b Mon Sep 17 00:00:00 2001 From: kodster28 Date: Wed, 13 Aug 2025 09:32:54 -0500 Subject: [PATCH 11/11] bug --- worker/index.worker.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/index.worker.test.ts b/worker/index.worker.test.ts index 4da38a6fc3f9688..89c02de4803e72a 100644 --- a/worker/index.worker.test.ts +++ b/worker/index.worker.test.ts @@ -316,7 +316,7 @@ describe("Cloudflare Docs", () => { expect(product).toBe("Access"); expect(group).toBe("Cloudflare One"); - expect(group).toBe("Changelog entry"); + expect(content_type).toBe("Changelog entry"); }); }); });