UNPKG

vitepress-plugin-llms

Version:

šŸ“œ A VitePress plugin for generating LLM-friendly documentation

167 lines (119 loc) • 9.98 kB
<!-- GitAds-Verify: WF65H9RCZLX4T489172MEB5JFHGL4B46 --> <!-- markdownlint-capture --> <!-- markdownlint-disable no-inline-html heading-start-left first-line-h1 --> <div align="center"> **Is this plugin useful for your site? Consider [sponsoring the developer](https://github.com/okineadev/vitepress-plugin-llms?sponsor) to support the project's development 😺** <br><br> <a href="https://npmjs.com/package/vitepress-plugin-llms"> <!-- https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#specifying-the-theme-an-image-is-shown-to --> <picture> <source media="(prefers-color-scheme: dark)" srcset="assets/hero-dark.png"> <source media="(prefers-color-scheme: light)" srcset="assets/hero-light.png"> <img src="assets/hero-dark.png" alt="Banner"> </picture> </a> <!-- prettier-ignore-start --> # šŸ“œ vitepress-plugin-llms [![NPM Downloads](https://img.shields.io/npm/dw/vitepress-plugin-llms?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAtOTYwIDk2MCA5NjAiIHdpZHRoPSIyNHB4IiBmaWxsPSIjMDAwMDAwIj48cGF0aCBkPSJNNDgwLTMyMCAyODAtNTIwbDU2LTU4IDEwNCAxMDR2LTMyNmg4MHYzMjZsMTA0LTEwNCA1NiA1OC0yMDAgMjAwWk0xNjAtMTYwdi0yMDBoODB2MTIwaDQ4MHYtMTIwaDgwdjIwMEgxNjBaIi8%2BPC9zdmc%2B&labelColor=FAFAFA&color=212121)](https://www.npmjs.com/package/vitepress-plugin-llms) [![NPM Version](https://img.shields.io/npm/v/vitepress-plugin-llms?logo=npm&logoColor=212121&label=version&labelColor=FAFAFA&color=212121)](https://npmjs.com/package/vitepress-plugin-llms) [![Tests Status](https://img.shields.io/github/actions/workflow/status/okineadev/vitepress-plugin-llms/ci.yml?label=tests&labelColor=212121)](https://github.com/okineadev/vitepress-plugin-llms/actions/workflows/ci.yml) [![Built with Bun](https://img.shields.io/badge/Built_with-Bun-fbf0df?logo=bun&labelColor=212121)](https://bun.sh) [![Formatted with Biome](https://img.shields.io/badge/Formatted_with-Biome-60a5fa?style=flat&logo=biome&labelColor=212121)](https://biomejs.dev/) [![sponsor](https://img.shields.io/badge/sponsor-EA4AAA?logo=githubsponsors&labelColor=FAFAFA)](https://github.com/okineadev/vitepress-plugin-llms?sponsor=1) [šŸ› Report bug](https://github.com/okineadev/vitepress-plugin-llms/issues/new?template=bug-report.yml) • [Request feature ✨](https://github.com/okineadev/vitepress-plugin-llms/issues/new?template=feature-request.yml) </div> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> ## šŸ“¦ Installation ```bash npm install vitepress-plugin-llms --save-dev ``` ## šŸ› ļø Usage Add the Vite plugin to your VitePress configuration (`.vitepress/config.ts`): ```ts import { defineConfig } from 'vitepress' import llmstxt from 'vitepress-plugin-llms' export default defineConfig({ vite: { plugins: [llmstxt()] } }) ``` Now, thanks to this plugin, the LLM version of the website documentation is automatically generated ### Plugin Settings See [`src/types.d.ts`](src/types.d.ts) ### Redirects (optional, but recommended āœ…) It is recommended to configure redirects so that AI can use addresses with both `.md` and `.txt` extensions #### Netlify `public/_redirects`: ```plaintext /llms-full.md /llms-full.txt 200! /llms-full.txt /llms-full.txt 200! ``` <!-- prettier-ignore-start --> <!-- markdownlint-disable-next-line --> <sub>Syntax documentation: <https://docs.netlify.com/routing/redirects></sub> <!-- prettier-ignore-end --> #### Example Configuration Here is an example of how to configure the plugin with custom settings: ```ts import { defineConfig } from 'vitepress' import llmstxt from 'vitepress-plugin-llms' export default defineConfig({ vite: { plugins: [ llmstxt({ generateLLMsFullTxt: false, ignoreFiles: ['sponsors/*'], customLLMsTxtTemplate: `# {title}\n\n{foo}`, title: 'Awesome tool', customTemplateVariables: { foo: 'bar' } }) ] } }) ``` This configuration does the following: - `generateLLMsFullTxt: false`: Disables the generation of the `llms-full.txt` file. - `ignoreFiles: ['sponsors/*']`: Ignores all files in the `sponsors` directory. - `customLLMsTxtTemplate`: Uses a custom template for the `llms.txt` file. - `title`: Sets a custom header in `llms.txt`, for your custom variables use `customTemplateVariables`. - `customTemplateVariables`: Sets custom variables for the template, replaces `{foo}` with `bar`. ## GitAds Sponsored [![Sponsored by GitAds](https://gitads.dev/v1/ad-serve?source=okineadev/vitepress-plugin-llms@github)](https://gitads.dev/v1/ad-track?source=okineadev/vitepress-plugin-llms@github) ## šŸš€ Why `vitepress-plugin-llms`? LLMs (Large Language Models) are great at processing text, but traditional documentation formats can be too heavy and cluttered. `vitepress-plugin-llms` generates raw Markdown documentation that LLMs can efficiently process The file structure in `.vitepress/dist` folder will be as follows: ```plaintext šŸ“‚ .vitepress/dist ā”œā”€ā”€ ... ā”œā”€ā”€ llms-full.txt // A file where all the website documentation is compiled into one file ā”œā”€ā”€ llms.txt // The main file for LLMs with all links to all sections of the documentation for LLMs ā”œā”€ā”€ markdown-examples.html // A human-friendly version of `markdown-examples` section in HTML format └── markdown-examples.md // A LLM-friendly version of `markdown-examples` section in Markdown format ``` ### āœ… Key Features - āš”ļø Easy integration with VitePress - āœ… Zero config required, everything works out of the box - āš™ļø Customizable - šŸ¤– An LLM-friendly version is generated for each page - šŸ“ Generates `llms.txt` with section links - šŸ“– Generates `llms-full.txt` with all content in one file ## šŸ“– [llmstxt.org](https://llmstxt.org/) Standard This plugin follows the [llmstxt.org](https://llmstxt.org/) standard, which defines the best practices for LLM-friendly documentation. ## ✨ Projects where this plugin is used | Project | Stars | `llms.txt` | `llms-full.txt` | | -------------------------------------------------------- | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------: | :-------------------------------------------------------------: | | [**Slidev**](https://sli.dev/) | [![Stars](https://img.shields.io/github/stars/slidevjs/slidev?style=flat&label=%E2%AD%90&labelColor=FAFAFA&color=212121)](https://github.com/slidevjs/slidev) | [llms.txt](https://sli.dev/llms.txt) | [llms-full.txt](https://sli.dev/llms-full.txt) | | [**Elysia**](https://elysiajs.com/) | [![Stars](https://img.shields.io/github/stars/elysiajs/elysia?style=flat&label=%E2%AD%90&labelColor=FAFAFA&color=212121)](https://github.com/elysiajs/elysia) | [llms.txt](https://elysiajs.com/llms.txt) | [llms-full.txt](https://elysiajs.com/llms-full.txt) | | [**shadcn/vue**](https://shadcn-vue.com/) | [![Stars](https://img.shields.io/github/stars/unovue/shadcn-vue?style=flat&label=%E2%AD%90&labelColor=FAFAFA&color=212121)](https://github.com/unovue/shadcn-vue) | [llms.txt](https://shadcn-vue.com/llms.txt) | [llms-full.txt](https://shadcn-vue.com/llms-full.txt) | | [**Fantastic-admin**](https://fantastic-admin.hurui.me/) | [![Stars](https://img.shields.io/github/stars/fantastic-admin/basic?style=flat&label=%E2%AD%90&labelColor=FAFAFA&color=212121)](https://github.com/fantastic-admin/basic) | [llms.txt](https://fantastic-admin.hurui.me/llms.txt) | [llms-full.txt](https://fantastic-admin.hurui.me/llms-full.txt) | | [**Vue Macros**](https://vue-macros.dev/) | [![Stars](https://img.shields.io/github/stars/vue-macros/vue-macros?style=flat&label=%E2%AD%90&labelColor=FAFAFA&color=212121)](https://github.com/vue-macros/vue-macros) | [llms.txt](https://vue-macros.dev/llms.txt) | [llms-full.txt](https://vue-macros.dev/llms-full.txt) | | [**oRPC**](https://orpc.unnoq.com/) | [![Stars](https://img.shields.io/github/stars/unnoq/orpc?style=flat&label=%E2%AD%90&labelColor=FAFAFA&color=212121)](https://github.com/unnoq/orpc) | [llms.txt](https://orpc.unnoq.com/llms.txt) | [llms-full.txt](https://orpc.unnoq.com/llms-full.txt) | | [**GramIO**](https://gramio.dev/) | [![Stars](https://img.shields.io/github/stars/gramiojs/gramio?style=flat&label=%E2%AD%90&labelColor=FAFAFA&color=212121)](https://github.com/gramiojs/gramio) | [llms.txt](https://gramio.dev/llms.txt) | [llms-full.txt](https://gramio.dev/llms-full.txt) | ## ā¤ļø Support If you like this project, consider supporting it by starring ⭐ it on GitHub, sharing it with your friends, or [buying me a coffee ā˜•](https://github.com/okineadev/vitepress-plugin-llms?sponsor=1) ## šŸ¤ Contributing You can read the instructions for contributing here - [CONTRIBUTING.md](./CONTRIBUTING.md) ## šŸ“œ License [MIT License](./LICENSE) Ā© 2025-present [Yurii Bogdan](https://github.com/okineadev) ## šŸ‘Øā€šŸ­ Contributors Thank you to everyone who helped with the project! ![Contributors](https://contributors-table.vercel.app/image?repo=okineadev/vitepress-plugin-llms&width=50&columns=10)