llms.txt JavaScript API

Everything the llms.txt extension adds to pb_hooks and page code, generated from the TypeScript declarations it ships (your app's types.d.ts has the same, so your editor knows them). For how to use it, see its docs; for Go, the Go API.

$llmsTxt

The app's /llms.txt (ext/llms-txt). Sections with the same heading merge under one ## heading, in the order added. Anyone can read the file: add nothing private.

$llmsTxt.add()

$llmsTxt.add(heading: string, content: string | ((req: llmsTxt.Request) => string | Promise<string>)): void

Adds a section. content is Markdown, or a function that builds it on each request (it may query $app; return "" to leave the section out). A function that throws leaves its section out and logs the error.

Parameter Type
heading string
content string | ((req: llmsTxt.Request) => string | Promise<string>)

Types

llmsTxt.Request

The request for /llms.txt, for absolute links.

Member Type
origin string scheme://host the request reached the app at, e.g. "https://example.com".
path string Always "/llms.txt".