mirror of
https://github.com/luxfi/docs.git
synced 2026-09-24 00:25:32 +00:00
The site can be searched, and read by a model
Search: the export now writes its index as a static file (/api/search) and the dialog searches it in the browser — this site has no server to ask. ⌘K did nothing before; the provider mounted no search at all. /llms-full.txt is the whole site as one document, for a model's context window, built from the same processed markdown each page compiled from. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { source } from '@/lib/source';
|
||||
import { createFromSource } from '@hanzo/docs/core/search/server';
|
||||
|
||||
// The search index, exported as a static file the client searches locally —
|
||||
// this site is a static export, so there is no server to query at runtime.
|
||||
export const revalidate = false;
|
||||
|
||||
export const { staticGET: GET } = createFromSource(source);
|
||||
@@ -48,7 +48,9 @@ export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
suppressHydrationWarning
|
||||
>
|
||||
<body className="flex flex-col min-h-screen">
|
||||
<RootProvider>{children}</RootProvider>
|
||||
{/* The index is a static file the export writes; the dialog searches
|
||||
it in the browser — this site has no server to ask. */}
|
||||
<RootProvider search={{ options: { type: 'static' } }}>{children}</RootProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { source } from '@/lib/source';
|
||||
import { getLLMText } from '@/lib/llm';
|
||||
|
||||
// The whole site as one document, for a model's context window. Static: the
|
||||
// export writes it as a file beside the pages it describes.
|
||||
export const revalidate = false;
|
||||
|
||||
export async function GET() {
|
||||
const pages = await Promise.all(source.getPages().map(getLLMText));
|
||||
return new Response(pages.join('\n\n'), {
|
||||
headers: { 'content-type': 'text/plain; charset=utf-8' },
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { source } from '@/lib/source';
|
||||
|
||||
type Page = ReturnType<typeof source.getPages>[number];
|
||||
|
||||
/** One page as a model reads it: title, canonical URL, source file, body. */
|
||||
export async function getLLMText(page: Page) {
|
||||
const processed = await page.data.getText('processed');
|
||||
return `# ${page.data.title}
|
||||
URL: https://docs.lux.network${page.url}
|
||||
Source: https://github.com/luxfi/docs/blob/main/apps/docs/content/docs/${page.path}
|
||||
|
||||
${page.data.description ?? ''}
|
||||
|
||||
${processed}`;
|
||||
}
|
||||
@@ -3,6 +3,12 @@ import { defineConfig, defineDocs } from '@hanzo/docs/mdx/config';
|
||||
export const docs = defineDocs({
|
||||
docs: {
|
||||
async: true,
|
||||
// The markdown each page compiled from, kept on the page object so the
|
||||
// /llms-full.txt route and the search index read the same words a person
|
||||
// reads.
|
||||
postprocess: {
|
||||
includeProcessedMarkdown: true,
|
||||
},
|
||||
},
|
||||
meta: {},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user