Files
cms-template/components/EndPreviewButton.tsx
2026-08-31 19:55:41 +02:00

29 lines
629 B
TypeScript

'use client';
import { useRouter } from 'next/navigation';
export default function EndPreviewButton() {
const router = useRouter();
const endPreview = () => {
// Cookie entfernen
document.cookie = 'payload-preview=; Max-Age=0; Path=/';
// ?preview entfernen
const url = new URL(window.location.href);
url.searchParams.delete('preview');
// Neuladen
router.replace(url.pathname + url.search);
router.refresh();
};
return (
<button
className="fixed bottom-0 left-0 bg-red-500 rounded-md p-2 m-2 text-sm text-white cursor-pointer"
onClick={endPreview}
>
Preview beenden
</button>
);
}