Skip to content

Commit a132c5b

Browse files
docs: add llms.txt file (#745)
## Description This PR adds `llms.txt` file to our docs - `llms.txt` is built automatically using [docusaurus-plugin-llms-txt plugin](https://www.npmjs.com/package/@signalwire/docusaurus-plugin-llms-txt/v/1.2.2). Because of some bug regarding absolute urls in the plugin used, this PR also adds `postbuild` script that fixes duplicated url slugs in the `llms.txt` file. ### Introduces a breaking change? - [ ] Yes - [x] No ### Type of change - [ ] Bug fix (change which fixes an issue) - [ ] New feature (change which adds functionality) - [x] Documentation update (improves or adds clarity to existing documentation) - [ ] Other (chores, tests, code style improvements etc.) ### Tested on - [ ] iOS - [ ] Android ### Testing instructions - build docs locally (`yarn build -> yarn serve`) - verify `/react-native-executorch/llms.txt` url ### Screenshots [llms.txt](https://github.com/user-attachments/files/24794966/llms.txt) <img width="1720" height="949" alt="Screenshot 2026-01-22 at 13 52 51" src="https://github.com/user-attachments/assets/b3c33a8b-aaea-47dd-b461-88a3a384e099" /> ### Related issues #416 ### Checklist - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have updated the documentation accordingly - [ ] My changes generate no new warnings ### Additional notes After merging this PR, our DocSearch crawler configuration should be updated, so is does not index `llms.txt` file.
1 parent 8810ecc commit a132c5b

5 files changed

Lines changed: 361 additions & 8 deletions

File tree

docs/docusaurus.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,30 @@ const config = {
121121
enableSidePanel: true,
122122
},
123123
},
124+
plugins: [
125+
[
126+
'@signalwire/docusaurus-plugin-llms-txt',
127+
/** @type {import('@signalwire/docusaurus-plugin-llms-txt').PluginOptions} */
128+
({
129+
siteTitle: 'React Native ExecuTorch',
130+
siteDescription:
131+
"React Native ExecuTorch brings Meta's ExecuTorch AI framework into the React Native ecosystem, enabling developers to run AI models and LLMs locally, directly on mobile devices. It provides a declarative API for on-device inference, allowing you to use local AI models without relying on cloud infrastructure. Built on the ExecuTorch foundation - part of the PyTorch Edge ecosystem - it extends efficient on-device AI deployment to cross-platform mobile applications in React Native.",
132+
depth: 3,
133+
enableDescriptions: true,
134+
content: {
135+
includeVersionedDocs: false,
136+
relativePaths: false,
137+
enableMarkdownFiles: false,
138+
excludeRoutes: ['**/react-native-executorch/search'],
139+
},
140+
includeOrder: [
141+
'**/docs/!(category|benchmarks)**',
142+
'**/docs/benchmarks/**',
143+
'**/docs/category/**',
144+
],
145+
}),
146+
],
147+
],
124148
};
125149

126150
module.exports = config;

docs/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"docusaurus": "docusaurus",
77
"start": "docusaurus start",
8-
"build": "docusaurus build",
8+
"build": "docusaurus build && npm run postbuild",
9+
"postbuild": "node scripts/postbuild.mjs",
910
"swizzle": "docusaurus swizzle",
1011
"deploy": "docusaurus deploy",
1112
"clear": "docusaurus clear",
@@ -25,6 +26,7 @@
2526
"@emotion/styled": "^11.14.1",
2627
"@mdx-js/react": "^3.0.0",
2728
"@mui/material": "^7.3.7",
29+
"@signalwire/docusaurus-plugin-llms-txt": "^1.2.2",
2830
"@swmansion/t-rex-ui": "^1.2.1",
2931
"clsx": "^2.1.0",
3032
"copy-text-to-clipboard": "^3.2.2",

docs/scripts/postbuild.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { join, dirname } from 'path';
2+
import { fileURLToPath } from 'url';
3+
import { fixLLMsTxtDuplicatedPaths } from './tasks/fix-llms-txt.mjs';
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
7+
const BUILD_DIR = join(__dirname, '..', 'build');
8+
9+
async function postbuild() {
10+
try {
11+
fixLLMsTxtDuplicatedPaths(BUILD_DIR);
12+
console.log('All post-build tasks completed successfully.\n');
13+
} catch (error) {
14+
console.error('\nPost-build script failed:', error);
15+
process.exit(1);
16+
}
17+
}
18+
19+
postbuild();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { existsSync, readFileSync, writeFileSync } from 'fs';
2+
import { join, dirname } from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
export { fixLLMsTxtDuplicatedPaths };
6+
7+
const FILES_TO_FIX = ['llms.txt'];
8+
const DUPLICATED_PATH = '/react-native-executorch/react-native-executorch/';
9+
const FIXED_PATH = '/react-native-executorch/';
10+
11+
function fixLLMsTxtDuplicatedPaths(buildDir) {
12+
console.log('Running LLMS.txt fix script...');
13+
console.log(`Looking in: ${buildDir}`);
14+
15+
FILES_TO_FIX.forEach((fileName) => {
16+
const filePath = join(buildDir, fileName);
17+
18+
if (existsSync(filePath)) {
19+
try {
20+
const content = readFileSync(filePath, 'utf8');
21+
22+
if (content.includes(DUPLICATED_PATH)) {
23+
const fixedContent = content.replaceAll(DUPLICATED_PATH, FIXED_PATH);
24+
25+
writeFileSync(filePath, fixedContent, 'utf8');
26+
console.log(`Fixed URLs in ${fileName}`);
27+
} else {
28+
console.info(`No broken URLs found in ${fileName}`);
29+
}
30+
} catch (err) {
31+
console.error(`Could not process ${fileName}:`, err);
32+
process.exit(1);
33+
}
34+
} else {
35+
console.warn(`File ${fileName} not found`);
36+
}
37+
});
38+
}

0 commit comments

Comments
 (0)