You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Whitespace normalization**: Removes excessive newlines and spacing
168
68
69
+
### Response Format
169
70
```markdown
170
71
# Page Title
171
72
172
-
[Actual page content converted to markdown]
73
+
[Full cleaned markdown content]
173
74
174
75
---
175
76
@@ -179,41 +80,43 @@ To test the feature:
179
80
*This is the full page content converted to markdown format.*
180
81
```
181
82
182
-
## Error Handling
183
-
184
-
The feature includes comprehensive error handling:
83
+
## File Structure
185
84
186
-
-**404 Not Found**: When the requested page doesn't exist
187
-
-**500 Internal Server Error**: When content processing fails
188
-
-**400 Bad Request**: When path parameter is missing
189
-
-**Graceful Fallbacks**: When source files aren't accessible
85
+
```
86
+
app/
87
+
├── api/
88
+
│ └── llms-txt/
89
+
│ └── [...path]/
90
+
│ └── route.ts # Dynamic API route handler
91
+
src/
92
+
├── middleware.ts # URL interception and rewriting
93
+
LLMS_TXT_FEATURE.md # This documentation
94
+
```
190
95
191
-
## Performance Considerations
96
+
## Error Handling
192
97
193
-
-**Caching**: Responses are cached for 1 hour to reduce server load
194
-
-**File System Access**: Direct file system reads for optimal performance
195
-
-**Efficient Processing**: Minimal regex operations for content cleanup
196
-
-**Error Recovery**: Fast fallback responses when content isn't available
98
+
-**404 errors**: When pages don't exist in the document tree
99
+
-**500 errors**: For file system or processing errors
100
+
-**Graceful fallbacks**: Default content when source files can't be accessed
101
+
-**Logging**: Error details logged to console for debugging
197
102
198
-
## Future Enhancements
103
+
## Performance Considerations
199
104
200
-
Potential improvements for the feature:
105
+
-**Caching**: Responses cached for 1 hour (`max-age=3600`)
106
+
-**File system access**: Direct file reads for better performance
107
+
-**Error boundaries**: Prevents crashes from affecting other routes
201
108
202
-
1.**Enhanced JSX Cleanup**: More sophisticated removal of React components
203
-
2.**Code Block Preservation**: Better handling of code examples
204
-
3.**Link Resolution**: Convert relative links to absolute URLs
205
-
4.**Image Handling**: Process and reference images appropriately
206
-
5.**Table of Contents**: Generate TOC from headings
207
-
6.**Metadata Extraction**: Include more frontmatter data in output
109
+
## Testing
208
110
209
-
## Maintenance
111
+
Test the feature by appending `llms.txt` to any documentation URL:
210
112
211
-
- The feature is self-contained with clear separation of concerns
212
-
- Content extraction logic can be enhanced in the API route
213
-
- Cleanup patterns can be updated in the `cleanupMarkdown()` function
214
-
- Performance can be monitored through response times and caching metrics
215
-
- Error handling provides clear debugging information
113
+
1. Visit any docs page (e.g., `/platforms/javascript/`)
114
+
2. Add `llms.txt` to the end: `/platforms/javascript/llms.txt`
115
+
3. Verify you receive plain markdown content instead of HTML
216
116
217
-
---
117
+
## Implementation Notes
218
118
219
-
**Note**: This feature extracts the actual page content from source MDX files and converts it to clean markdown format, making it ideal for LLM consumption and automated processing.
119
+
- The feature works with both regular documentation and developer documentation
120
+
- API documentation (dynamically generated) gets placeholder content
121
+
- Common platform files are automatically detected and used when appropriate
122
+
- The middleware preserves URL structure while routing to the appropriate API endpoint
0 commit comments