| 1 | import released from "@/data/agent-docs.release.json"; |
| 2 | import { DOC_TOPICS } from "./docs-map"; |
| 3 | import { REPO_URL } from "./i18n/links"; |
| 4 | import { buildInstallMarkdown } from "./llms-txt"; |
| 5 | |
| 6 | export const RELEASE_DOCS = released; |
| 7 | |
| 8 | export function buildTopicMarkdown(slug: string): string | null { |
| 9 | const document = RELEASE_DOCS.topics.find((entry) => entry.slug === slug); |
| 10 | const topic = DOC_TOPICS.find((entry) => entry.slug === slug); |
| 11 | if (!document || !topic) return null; |
| 12 | if (slug === "install") return buildInstallMarkdown(); |
| 13 | const { tag } = RELEASE_DOCS; |
| 14 | const many = document.sources.length > 1; |
| 15 | return [ |
| 16 | `# ${topic.label.en}`, "", topic.description.en, "", |
| 17 | `The document${many ? "s" : ""} below ${many ? "are" : "is"} the repository's file${many ? "s" : ""} as ${many ? "they were" : "it was"} at the published release ${tag}.`, "", |
| 18 | ...document.missing.flatMap((path) => [`${path} was added after ${tag} and is not part of this release; the document below is what ${tag} has.`, ""]), |
| 19 | ...document.sources.flatMap((source) => [ |
| 20 | `Source: ${REPO_URL}/blob/${tag}/${source.path}`, |
| 21 | `SHA-256: ${source.sha256}`, "", |
| 22 | source.path.split("#", 1)[0].endsWith(".json") ? `\`\`\`json\n${source.content}\n\`\`\`` : source.content, |
| 23 | "", |
| 24 | ]), |
| 25 | ].join("\n"); |
| 26 | } |
| 27 |