Skip to content

Commit dbf6b9f

Browse files
kodster28sdnts
authored andcommitted
[Docs Site] New schema value for Support AI (cloudflare#22794)
* [Docs Site] New schema value for Support AI * Test value * Update framing of frontmatter + logic to render in index.md * Add whole product option like noindex * Add tags to .md as well
1 parent 718d986 commit dbf6b9f

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/components/overrides/Head.astro

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { CollectionEntry } from "astro:content";
99
1010
const DEFAULT_TITLE_DELIMITER = "|";
1111
const NOINDEX_PRODUCTS = ["email-security", "style-guide", "security"];
12+
const CHATBOT_DEPRIORITIZE_PRODUCTS = ["firewall"];
1213
1314
const currentSection = Astro.url.pathname.split("/")[1].replaceAll(".", "");
1415
@@ -22,6 +23,10 @@ const shouldNoIndex =
2223
frontmatter.noindex ||
2324
frontmatter.external_link;
2425
26+
const shouldChatbotDeprioritize =
27+
CHATBOT_DEPRIORITIZE_PRODUCTS.includes(currentSection) ||
28+
frontmatter.chatbot_deprioritize;
29+
2530
if (currentSection) {
2631
const product = await getEntry("products", currentSection);
2732
@@ -83,6 +88,16 @@ if (shouldNoIndex) {
8388
});
8489
}
8590
91+
if (shouldChatbotDeprioritize) {
92+
head.push({
93+
tag: "meta",
94+
attrs: {
95+
name: "pcx_chatbot_deprioritize",
96+
content: true,
97+
},
98+
});
99+
}
100+
86101
if (
87102
frontmatter.description &&
88103
head.findIndex(

src/schemas/base.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ export const baseSchema = ({ image }: SchemaContext) =>
9797
.boolean()
9898
.optional()
9999
.describe(
100-
"If true, this property adds a `noindex` declaration to the page, which will tell internal / external search crawlers to ignore this page. Helpful for pages that are historically accurate, but no longer recommended, such as [Workers Sites](/workers/configuration/sites/).",
100+
"If true, this property adds a `noindex` declaration to the page, which will tell internal / external search crawlers to ignore this page. Helpful for pages that are historically accurate, but no longer recommended, such as [Workers Sites](/workers/configuration/sites/). Companion to the `chatbot_deprioritize` property.",
101+
),
102+
chatbot_deprioritize: z
103+
.boolean()
104+
.optional()
105+
.describe(
106+
"If true, this property will de-prioritize this page in the responses surfaced by Support AI. Helpful for pages that are historically accurate, but no longer recommended, such as [Workers Sites](/workers/configuration/sites/). Companion to the `noindex` property.",
101107
),
102108
sidebar,
103109
hideChildren: z

src/util/markdown.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ export async function htmlToMarkdown(
3232
const description = dom.querySelector("meta[name='description']")?.attributes
3333
.content;
3434
const lastUpdated = dom.querySelector(".meta time")?.attributes.datetime;
35+
const chatbotDeprioritize = dom.querySelector(
36+
"meta[name='pcx_chatbot_deprioritize']",
37+
)?.attributes.content;
38+
const tags = dom.querySelector("meta[name='pcx_tags']")?.attributes.content;
3539

3640
const withFrontmatter = [
3741
"---",
3842
`title: ${title}`,
3943
description ? `description: ${description}` : [],
4044
lastUpdated ? `lastUpdated: ${lastUpdated}` : [],
45+
chatbotDeprioritize ? `chatbotDeprioritize: ${chatbotDeprioritize}` : [],
46+
tags ? `tags: ${tags}` : [],
4147
`source_url:`,
4248
` html: ${url.replace("index.md", "")}`,
4349
` md: ${url}`,

0 commit comments

Comments
 (0)