Erste brauchbare Version
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
'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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user