Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes the documentation page loading performance by deferring the extraction and transmission of full document content until the AI assistant is actually invoked. Previously, all document content (up to 50,000 characters) was extracted and embedded in the initial HTML payload regardless of whether users interacted with the AI assistant. Now, only the document slug is passed initially, and content is fetched on-demand via the API route when users engage with the chat feature.
Changes:
- Removed server-side content extraction logic from the docs page component
- Moved the
extractTextFromMDXfunction from page.tsx to the API chat route - Modified the chat API to fetch and process document content on-demand when a slug is provided
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/docs/[...slug]/page.tsx | Removed content extraction logic and eliminated the content field from pageContext |
| app/components/DocsAssistant.tsx | Removed content field from the PageContext interface |
| app/api/chat/route.ts | Added on-demand content fetching logic and moved the extractTextFromMDX helper function here |
Comments suppressed due to low confidence (1)
app/docs/[...slug]/page.tsx:1
- Corrected 'client/page side' to 'server/page side' since Next.js page components run on the server, not the client.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (page) { | ||
| const fullFilePath = path.join(process.cwd(), "app/docs", page.path); |
There was a problem hiding this comment.
The path construction uses page.path directly, but based on the original code it should use page.file.path to match the previous implementation in page.tsx.
| if (page) { | |
| const fullFilePath = path.join(process.cwd(), "app/docs", page.path); | |
| if (page && page.file?.path) { | |
| const fullFilePath = path.join( | |
| process.cwd(), | |
| "app/docs", | |
| page.file.path, | |
| ); |
There was a problem hiding this comment.
这是老用法,file是deprecated
之前的流程:
现在的流程是:
经过本地pnpm dev 初步测试,build阶段会比之前快很多