MCPcopy
hub / github.com/CopilotKit/CopilotKit / getAllLlmPages

Function getAllLlmPages

showcase/shell-docs/src/lib/llm-text.ts:122–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120 * `content/docs/integrations/<folder>/`.
121 */
122export function getAllLlmPages(): LlmPage[] {
123 const pages: LlmPage[] = [];
124 const seenUrls = new Set<string>();
125
126 const push = (page: LlmPage): void => {
127 if (seenUrls.has(page.url)) return;
128 seenUrls.add(page.url);
129 pages.push(page);
130 };
131
132 // ROOT_FRAMEWORK's authored pages win at bare root URLs (the same
133 // resolution the live pages use — see UnscopedDocsPage). Walk its
134 // folder once so the bare loop below can swap in the override.
135 const rootFolder = getDocsFolder(ROOT_FRAMEWORK);
136 const rootOverrides = new Map<string, string>(); // slug → filePath
137 const rootDir = path.join(CONTENT_DIR, "integrations", rootFolder);
138 if (fs.existsSync(rootDir)) {
139 for (const { slug, filePath } of walkMdx(rootDir)) {
140 rootOverrides.set(slug, filePath);
141 }
142 }
143
144 // 1. Bare unscoped docs (`src/content/docs/**.mdx`, minus `integrations/`).
145 for (const { slug, filePath } of walkMdx(
146 DOCS_CONTENT_DIR,
147 new Set(["integrations"]),
148 )) {
149 if (!slug) continue;
150 // The root `built-in-agent.mdx` topic page's bare URL permanently
151 // redirects to `/` (the retired framework prefix); it stays
152 // reachable under other frameworks' scopes only.
153 if (slug === ROOT_FRAMEWORK) continue;
154 const overridePath = rootOverrides.get(slug);
155 const meta = readMetaFromFile(overridePath ?? filePath);
156 push({
157 url: slug,
158 title: meta.title ?? slug,
159 description: meta.description,
160 filePath: overridePath ?? filePath,
161 loadSlug: overridePath ? `integrations/${rootFolder}/${slug}` : slug,
162 framework: overridePath ? ROOT_FRAMEWORK : undefined,
163 });
164 }
165
166 // 2. Per-framework override pages — files under
167 // `content/docs/integrations/<folder>/` that don't have a
168 // root-level equivalent. We emit them at `/<framework>/<topic>`,
169 // or at `/<framework>` for the folder's `index.mdx`.
170 //
171 // Note: `walkMdx` strips trailing `/index` from yielded slugs, so
172 // a folder's `index.mdx` arrives here as `slug === ""`. The previous
173 // `if (!slug) continue` guard silently skipped framework root URLs
174 // from `/llms.txt`, leaving LLM crawlers unable to find e.g.
175 // `/langgraph-python`. Treat empty slug as the framework root and
176 // emit it as the bare integration URL.
177 const integrations = getIntegrations();
178 for (const integration of integrations) {
179 if (integration.docs_mode === "hidden") continue;

Callers 2

GETFunction · 0.90
GETFunction · 0.90

Calls 8

getDocsFolderFunction · 0.90
walkMdxFunction · 0.90
getIntegrationsFunction · 0.90
readMetaFromFileFunction · 0.85
pushFunction · 0.70
joinMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…