feat(preview): implement preview mode for content management
Deploy / verify (push) Successful in 41s
Deploy / deploy (push) Successful in 1m3s

- Added support for a preview mode in the CMS, allowing draft content to be viewed without being indexed.
- Updated hooks and server logic to handle preview parameters, adjusting cache control and robots tags accordingly.
- Enhanced layout to display a preview notification when in preview mode, improving user experience for content editors.
This commit is contained in:
Peter Meier
2026-04-23 11:11:27 +02:00
parent 9216138a8c
commit 50bb0ef398
5 changed files with 61 additions and 7 deletions
+6 -1
View File
@@ -49,9 +49,12 @@ export const handle: Handle = async ({ event, resolve }) => {
},
});
const isPreview = event.url.searchParams.has('preview');
if (
event.request.method === 'GET' &&
isCacheablePath(event.url.pathname) &&
!isPreview &&
!response.headers.has('cache-control')
) {
response.headers.set('cache-control', PAGE_CACHE_CONTROL);
@@ -64,7 +67,9 @@ export const handle: Handle = async ({ event, resolve }) => {
) {
response.headers.set(
'x-robots-tag',
'index, follow, max-image-preview:large, max-snippet:-1',
isPreview
? 'noindex, nofollow'
: 'index, follow, max-image-preview:large, max-snippet:-1',
);
}