feat(preview): implement preview mode for content management
- 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:
+6
-1
@@ -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',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user