Skip to content

Commit d2694eb

Browse files
authored
[Docs Site] Add LLM Resources into sidebar (#20472)
1 parent b42cc8f commit d2694eb

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

src/content/docs/workers/llms.txt.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/content/docs/workers/prompt.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/util/sidebar.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { AstroGlobal } from "astro";
22
import type { Props } from "@astrojs/starlight/props";
33

4-
import { getEntry } from "astro:content";
4+
import { getEntry, getCollection } from "astro:content";
55
import { rehypeExternalLinksOptions } from "~/plugins/rehype/external-links";
66

77
type Link = Extract<Props["sidebar"][0], { type: "link" }> & { order?: number };
@@ -12,6 +12,7 @@ type Group = Extract<Props["sidebar"][0], { type: "group" }> & {
1212
export type SidebarEntry = Link | Group;
1313
type Badge = Link["badge"];
1414

15+
const products = await getCollection("products");
1516
const sidebars = new Map<string, Group>();
1617

1718
export async function getSidebar(context: AstroGlobal<Props>) {
@@ -88,6 +89,33 @@ export async function generateSidebar(group: Group) {
8889
group.entries[0].label = "Overview";
8990
}
9091

92+
const product = products.find((p) => p.id === group.label);
93+
if (product && product.data.product.group === "Developer platform") {
94+
const links = [
95+
["llms.txt", "/llms.txt"],
96+
["prompt.txt", "/workers/prompt.txt"],
97+
[`${product.data.name} llms-full.txt`, `/${product.id}/llms-full.txt`],
98+
["Developer Platform llms-full.txt", "/developer-platform/llms-full.txt"],
99+
];
100+
101+
group.entries.push({
102+
type: "group",
103+
label: "LLM resources",
104+
entries: links.map(([label, href]) => ({
105+
type: "link",
106+
label,
107+
href,
108+
isCurrent: false,
109+
attrs: {
110+
target: "_blank",
111+
},
112+
badge: undefined,
113+
})),
114+
collapsed: true,
115+
badge: undefined,
116+
});
117+
}
118+
91119
return group;
92120
}
93121

0 commit comments

Comments
 (0)