Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Real-Time Preview Panel
Screen.Recording.2025-12-05.at.4.08.41.AM.mov
Overview
This PR introduces a real-time preview panel that displays live content updates as users edit collection files. The preview shows the actual rendered website with content changes reflected instantly, providing a WYSIWYG editing experience.
Features
✨ Real-Time Preview
🎯 Framework Support
package.jsonand config files⚡ Performance Optimizations
remark/rehypeTechnical Implementation
New API Endpoints
GET /api/[owner]/[repo]/[branch]/preview/baseFetches the base HTML for a preview page. Called once when opening a file or switching files.
Query Parameters:
filePath: Path to the file being editedname: Schema/collection nameReturns:
{ "status": "success", "data": { "html": "<html>...</html>", "pageUrl": "https://example.com/page", "contentSelector": "main" } }POST /api/[owner]/[repo]/[branch]/preview(Legacy)Original endpoint that returns fully processed HTML. Kept for backward compatibility but not used by the new client-side implementation.
New Components
EntryPreviewReact component that:
remark/rehypepipelineConfiguration Schema
Preview configuration is added to collection schemas in
.pages.yml:Configuration Options:
url(required): Base URL of the deployed siteenabled(optional): Enable/disable preview (defaults totrue)selector(optional): CSS selector for the content area (defaults to"main")URL Mapping
File paths are automatically mapped to preview URLs:
src/content/articles/something/myarticle.md→https://site.com/something/myarticleschema.pathas input and empty string as output for path transformationsrc/content/orcontent/prefixesMarkdown Rendering
Uses the same rendering pipeline as Astro:
Supports:
User Experience
Preview Panel
Content Detection
Error Handling
Dependencies Added
cheerio: Server-side HTML parsing (for legacy endpoint)remark: Markdown processingremark-gfm: GitHub Flavored Markdownremark-rehype: Markdown to HTML conversionrehype-sanitize: HTML sanitizationrehype-stringify: HTML stringificationFiles Changed
New Files
app/api/[owner]/[repo]/[branch]/preview/base/route.ts- Base HTML endpointcomponents/entry/entry-preview.tsx- Preview componentlib/utils/framework-detector.ts- Framework detection utilityModified Files
lib/configSchema.ts- Added preview configuration schemalib/config.ts- Added preview config normalizationlib/schema.ts- AddedmapFilePathToPreviewUrlfunctioncomponents/entry/entry-form.tsx- Integrated preview componentpackage.json- Added new dependenciesTesting
Manual Testing Checklist
Future Enhancements
Breaking Changes
None. This is a new feature that doesn't affect existing functionality.
Migration Guide
To enable preview for a collection, add the preview configuration to your
.pages.yml:The preview panel will automatically appear in the entry editor when preview is configured.