Skip to content

feat: 📄 integrate llms.txt generation functionality #4692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
groupIconVitePlugin,
localIconLoader
} from 'vitepress-plugin-group-icons'
import llmstxt from 'vitepress-plugin-llms'

const prod = !!process.env.NETLIFY

Expand Down Expand Up @@ -123,15 +122,15 @@ export default defineConfig({
),
firebase: 'logos:firebase'
}
}),
prod &&
llmstxt({
workDir: 'en',
ignoreFiles: ['index.md']
})
})
]
},

llms: prod
? {
workDir: 'en',
ignoreFiles: ['index.md']
}
: false,
transformPageData: prod
? (pageData, ctx) => {
const site = resolveSiteDataByRoute(
Expand Down
3 changes: 1 addition & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"open-cli": "^8.0.0",
"postcss-rtlcss": "^5.7.0",
"vitepress": "workspace:*",
"vitepress-plugin-group-icons": "^1.4.1",
"vitepress-plugin-llms": "^1.1.0"
"vitepress-plugin-group-icons": "^1.4.1"
}
}
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,18 @@
"@vue/shared": "^3.5.13",
"@vueuse/core": "^13.1.0",
"@vueuse/integrations": "^13.1.0",
"byte-size": "^9.0.1",
"focus-trap": "^7.6.4",
"mark.js": "8.11.1",
"markdown-title": "^1.0.2",
"millify": "^6.1.0",
"minimatch": "^10.0.1",
"minisearch": "^7.1.2",
"remark": "^15.0.1",
"remark-frontmatter": "^5.0.0",
"shiki": "^3.2.2",
"tokenx": "^0.4.1",
"unist-util-remove": "^4.0.0",
"vite": "^6.2.6",
"vue": "^3.5.13"
},
Expand All @@ -129,6 +137,7 @@
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-replace": "^6.0.2",
"@types/byte-size": "^8.1.2",
"@types/cross-spawn": "^6.0.6",
"@types/debug": "^4.1.12",
"@types/fs-extra": "^11.0.4",
Expand Down
54 changes: 32 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export async function resolveConfig(
userConfig,
sitemap: userConfig.sitemap,
buildConcurrency: userConfig.buildConcurrency ?? 64,
...(await resolvePages(srcDir, userConfig, logger, true))
...(await resolvePages(srcDir, userConfig, logger, true)),
llms: userConfig.llms ?? false
}

// to be shared with content loaders
Expand Down Expand Up @@ -336,6 +337,7 @@ export async function resolveSiteData(
scrollOffset: userConfig.scrollOffset ?? 134,
cleanUrls: !!userConfig.cleanUrls,
contentProps: userConfig.contentProps,
llms: userConfig.llms ?? false,
additionalConfig: userConfig.additionalConfig
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { localSearchPlugin } from './plugins/localSearchPlugin'
import { rewritesPlugin } from './plugins/rewritesPlugin'
import { staticDataPlugin } from './plugins/staticDataPlugin'
import { webFontsPlugin } from './plugins/webFontsPlugin'
import llmstxt from './plugins/llmstxt'
import { slash, type PageDataPayload } from './shared'
import { deserializeFunctions, serializeFunctions } from './utils/fnSerialize'

Expand Down Expand Up @@ -80,6 +81,7 @@ export async function createVitePressPlugin(
site,
vue: userVuePluginOptions,
vite: userViteConfig,
llms,
lastUpdated,
cleanUrls
} = siteConfig
Expand Down Expand Up @@ -439,6 +441,7 @@ export async function createVitePressPlugin(
vuePlugin,
hmrFix,
webFontsPlugin(siteConfig.useWebFonts),
llms ? llmstxt(llms === true ? undefined : llms) : [],
...(userViteConfig?.plugins || []),
await localSearchPlugin(siteConfig),
staticDataPlugin,
Expand Down
11 changes: 11 additions & 0 deletions src/node/plugins/llmstxt/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** Default template for the `llms.txt` file. */
export const defaultLLMsTxtTemplate = `\
# {title}

{description}

{details}

## Table of Contents

{toc}`
Loading
Loading