Skip to content

Commit 4fb6e02

Browse files
committed
initial commit
thanks cursor and claude
0 parents  commit 4fb6e02

File tree

10 files changed

+9493
-0
lines changed

10 files changed

+9493
-0
lines changed

.github/workflows/publish.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish Package to npm
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
if: github.ref == 'refs/heads/master'
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: "18.x"
22+
registry-url: "https://registry.npmjs.org"
23+
24+
- name: Get yarn cache directory path
25+
id: yarn-cache-dir-path
26+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
27+
28+
- name: Cache dependencies
29+
uses: actions/cache@v3
30+
with:
31+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
32+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-yarn-
35+
36+
- name: Install dependencies
37+
run: yarn install --frozen-lockfile
38+
39+
- name: Check formatting
40+
run: yarn prettier --check .
41+
42+
- name: Run tests
43+
run: yarn test
44+
45+
- name: Publish to npm
46+
run: npm publish
47+
env:
48+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
node-version: [18.x, 20.x, 22.x]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
27+
- name: Get yarn cache directory path
28+
id: yarn-cache-dir-path
29+
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
30+
31+
- name: Cache dependencies
32+
uses: actions/cache@v3
33+
with:
34+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
35+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
36+
restore-keys: |
37+
${{ runner.os }}-yarn-
38+
39+
- name: Install dependencies
40+
run: yarn install --frozen-lockfile
41+
42+
- name: Check formatting
43+
run: yarn prettier --check .
44+
45+
- name: Run tests
46+
run: yarn test

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
node_modules/
2+
.DS_Store
3+
*.log
4+
5+
# Build outputs
6+
dist/
7+
build/
8+
lib/
9+
10+
# Environment variables
11+
.env
12+
.env.local
13+
.env.*.local
14+
15+
# IDE specific files
16+
.idea/
17+
.vscode/
18+
*.sublime-*
19+
20+
# Coverage directory
21+
coverage/
22+
23+
# Temporary files
24+
*.swp
25+
.tmp/
26+
temp/

.npmignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
__tests__/
2+
.github/
3+
.gitignore
4+
.npmignore
5+
6+
# Development files
7+
src/
8+
tests/
9+
test/
10+
coverage/
11+
.eslintrc.js
12+
.prettierrc
13+
.babelrc
14+
jest.config.js
15+
16+
# Documentation
17+
docs/
18+
*.md
19+
20+
# Build configs
21+
tsconfig.json
22+
webpack.config.js
23+
rollup.config.js
24+
25+
# CI/CD
26+
.travis.yml
27+
.gitlab-ci.yml
28+
29+
# Environment files
30+
.env*

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Dinos Papakostas
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Docusaurus llms.txt Generator
2+
3+
A Docusaurus plugin that generates a concatenated markdown file from your documentation under `/llms.txt`. This plugin helps make your documentation AI-friendly by following the [llms.txt specification](https://llmstxt.org/), allowing AI models to better understand and process your documentation.
4+
5+
[![npm version](https://badge.fury.io/js/docusaurus-plugin-generate-llms-txt.svg)](https://www.npmjs.com/package/docusaurus-plugin-generate-llms-txt)
6+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7+
8+
## What is llms.txt?
9+
10+
llms.txt is a standard that helps AI models better understand your documentation by providing it in a single, concatenated file. This can improve the quality of AI responses when users ask questions about your project.
11+
12+
## Installation
13+
14+
```bash
15+
npm install docusaurus-plugin-generate-llms-txt
16+
# or
17+
yarn add docusaurus-plugin-generate-llms-txt
18+
```
19+
20+
## Usage
21+
22+
Add the plugin to your `docusaurus.config.js`:
23+
24+
```js
25+
// docusaurus.config.js
26+
module.exports = {
27+
plugins: [
28+
[
29+
"docusaurus-plugin-generate-llms-txt",
30+
{
31+
outputFile: "llms.txt", // defaults to llms.txt if not specified
32+
},
33+
],
34+
// other plugins...
35+
],
36+
};
37+
```
38+
39+
The plugin will generate the llms.txt file in the following scenarios:
40+
41+
- When running `yarn start` (development mode)
42+
- When running `yarn build` (production build)
43+
44+
You can also manually generate the file by running:
45+
46+
```bash
47+
yarn docusaurus generate-llms-txt
48+
```
49+
50+
### Configuration Options
51+
52+
| Option | Type | Default | Description |
53+
| ------------ | -------- | ------------ | --------------------------- |
54+
| `outputFile` | `string` | `'llms.txt'` | The name of the output file |
55+
56+
## Documentation Structure
57+
58+
⚠️ **Note:** This plugin makes some assumptions about the structure of your docs:
59+
60+
- The `docs` directory contains your documentation
61+
- Each category has a `_category_.yml` file that contains the category metadata
62+
- Each page has frontmatter metadata
63+
- For top-level Markdown pages, there is a `sidebar_position` field in the metadata
64+
65+
Example structure:
66+
67+
```
68+
docs/
69+
├── my-first-category/
70+
│ ├── _category_.yml
71+
│ ├── ...
72+
│ ├── some-sub-page.md
73+
├── my-second-category/
74+
│ ├── _category_.yml
75+
│ ├── ...
76+
│ ├── some-sub-page.md
77+
├── some-top-level-page.md
78+
└── ...
79+
```
80+
81+
## Development
82+
83+
To test the plugin locally:
84+
85+
1. Clone the repository
86+
2. Install dependencies: `yarn install`
87+
3. Run tests: `yarn test`
88+
4. Link the package: `yarn link`
89+
5. In your Docusaurus project: `yarn link docusaurus-plugin-generate-llms-txt`
90+
91+
## License
92+
93+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
94+
95+
## Contributing
96+
97+
Contributions are welcome! Please feel free to:
98+
99+
- Open issues for bug reports or feature requests
100+
- Submit pull requests
101+
- Improve documentation
102+
- Share feedback
103+
104+
Before contributing, please:
105+
106+
1. Check existing issues and PRs
107+
2. For major changes, open an issue first
108+
3. Add tests for new features
109+
4. Ensure tests pass: `yarn test`

package.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "docusaurus-plugin-generate-llms-txt",
3+
"version": "0.0.1",
4+
"description": "A docusaurus plugin that generates a concatenated markdown file from your documentation.",
5+
"author": "din0s",
6+
"license": "MIT",
7+
"keywords": [
8+
"docusaurus",
9+
"docusaurus-plugin",
10+
"documentation",
11+
"markdown",
12+
"llms.txt",
13+
"llms-txt"
14+
],
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/din0s/docusaurus-plugin-generate-llms-txt.git"
18+
},
19+
"bugs": {
20+
"url": "https://github.com/din0s/docusaurus-plugin-generate-llms-txt/issues"
21+
},
22+
"homepage": "https://github.com/din0s/docusaurus-plugin-generate-llms-txt#readme",
23+
"main": "src/index.js",
24+
"scripts": {
25+
"format": "prettier --write .",
26+
"test": "jest",
27+
"test:watch": "jest --watch"
28+
},
29+
"jest": {
30+
"testEnvironment": "node",
31+
"testMatch": [
32+
"<rootDir>/src/__tests__/**/*.test.js"
33+
],
34+
"transform": {}
35+
},
36+
"dependencies": {
37+
"js-yaml": "^4.1.0"
38+
},
39+
"devDependencies": {
40+
"@docusaurus/core": "^3.6.1",
41+
"@docusaurus/types": "^3.6.1",
42+
"fs-extra": "^11.2.0",
43+
"jest": "^29.7.0",
44+
"prettier": "^3.0.0"
45+
},
46+
"peerDependencies": {
47+
"@docusaurus/core": ">=2.0.0"
48+
},
49+
"engines": {
50+
"node": ">=18"
51+
}
52+
}

0 commit comments

Comments
 (0)