-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add sitemap.xml and llms.txt #138
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
Conversation
Reviewer's Guide by SourceryThis pull request introduces a sitemap.xml and llms.txt file to improve SEO and LLM indexing. It also adds a docusaurus plugin to generate the llms.txt file. Sequence diagram for llms.txt generation processsequenceDiagram
participant P as Plugin
participant FS as FileSystem
participant B as Build Process
P->>FS: Read markdown files
FS-->>P: Return file contents
P->>P: Parse frontmatter
P->>P: Extract titles and permalinks
P->>P: Sort content
P->>P: Generate markdown content
P->>FS: Write llms.txt
P->>B: Complete build process
Class diagram for the LLMs PluginclassDiagram
class Plugin {
+name: string
+loadContent()
+contentLoaded()
+postBuild()
}
class ContentItem {
+title: string
+description: string
+permalink: string
+sectionNesting: number
}
class DocusaurusPlugin {
+loadVersions()
+loadDocs(version)
+loadBlog()
}
Plugin ..> ContentItem : creates
Plugin ..|> DocusaurusPlugin : implements
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @roderik - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider removing or replacing the console.log debug statements with proper logging before merging to production
- The error handling in the llms plugin could be improved to provide more context when issues occur rather than catching and continuing silently
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟡 Review instructions: 2 issues found
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
const fileName = fileNameMatch ? fileNameMatch[1] : ''; | ||
|
||
// Basic frontmatter parsing | ||
const titleMatch = content.match(/title:\s*(.+)/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Use a proper frontmatter parser instead of regex
The current regex-based approach is fragile and might break with complex frontmatter. Consider using a library like 'gray-matter' for robust frontmatter parsing.
Suggested implementation:
const fileNameMatch = file.match(/([^/]+)\.mdx?$/);
const fileName = fileNameMatch ? fileNameMatch[1] : '';
// Parse frontmatter using gray-matter
const matter = require('gray-matter');
const { data: frontmatter } = matter(content);
const title = frontmatter.title || fileName;
You'll need to:
- Install the gray-matter package:
npm install gray-matter
- Add gray-matter to your project's dependencies in package.json
@@ -0,0 +1,164 @@ | |||
import type { LoadContext, Plugin } from '@docusaurus/types'; | |||
import fs from 'fs'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (review_instructions): Consider using asynchronous fs methods for non-blocking I/O.
Using synchronous file system methods can block the event loop, potentially leading to performance issues. Consider using asynchronous methods like fs.promises for better performance.
Review instructions:
Path patterns: **/*.ts
Instructions:
Always write correct, up to date, bug free, fully functional and working, secure, performant and efficient code.
name: 'docusaurus-llms-plugin', | ||
|
||
async loadContent(): Promise<ContentItem[]> { | ||
console.log('Loading content...'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (review_instructions): Consider removing or using a logger for console.log statements.
Console.log statements can clutter the output and are not recommended for production code. Consider using a logging library that can be configured for different environments.
Review instructions:
Path patterns: **/*.ts
Instructions:
Focus on readability over being performant, but performance is important.
Summary by Sourcery
Add a sitemap and an llms.txt file for improved SEO and LLM indexing.
New Features:
Tests: