silverwolf-x/project / examples /cms-agilitycms /lib /use-preview-redirect.ts
silverwolf-x's picture
download
raw
741 Bytes
import { useEffect } from "react";
import { useRouter } from "next/router";
export default function usePreviewRedirect() {
const router = useRouter();
const { agilitypreviewkey, contentid } = router.query;
useEffect(() => {
// kickout if we don't have an agilityPreviewKey
if (!agilitypreviewkey) return;
// redirect to our preview API route
let redirectLink = `/api/preview?slug=${window.location.pathname}&agilitypreviewkey=${agilitypreviewkey}`;
// Check if we have a `contentid` in the query, if so this is a preview request for a Dynamic Page Item
if (contentid) redirectLink = `${redirectLink}&contentid=${contentid}`;
window.location.href = redirectLink;
}, [agilitypreviewkey, contentid]);
}

Xet Storage Details

Size:
741 Bytes
·
Xet hash:
661f3b1a1a4bbb9f6ad8c33082b22412fe7cf05f607727b3241a5aba0f2f88f0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.