chore: migrate to payload / nextjs

This commit is contained in:
syntaxbullet
2026-06-16 13:02:47 +02:00
parent aff090b693
commit 6b395e5735
257 changed files with 33616 additions and 1451 deletions

View File

@@ -0,0 +1,15 @@
import type { CollectionBeforeChangeHook } from 'payload'
export const populatePublishedAt: CollectionBeforeChangeHook = ({ data, operation, req }) => {
if (operation === 'create' || operation === 'update') {
if (req.data && !req.data.publishedAt) {
const now = new Date()
return {
...data,
publishedAt: now,
}
}
}
return data
}

View File

@@ -0,0 +1,11 @@
import type { CollectionAfterChangeHook } from 'payload'
import { revalidateTag } from 'next/cache'
export const revalidateRedirects: CollectionAfterChangeHook = ({ doc, req: { payload } }) => {
payload.logger.info(`Revalidating redirects`)
revalidateTag('redirects', 'max')
return doc
}

View File

@@ -1,13 +0,0 @@
import { useState, useEffect } from 'react';
export function useIsMobile(breakpoint = 768): boolean {
const [isMobile, setIsMobile] = useState(() => window.innerWidth < breakpoint);
useEffect(() => {
const mq = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);
const handler = (e: MediaQueryListEvent) => setIsMobile(e.matches);
mq.addEventListener('change', handler);
setIsMobile(mq.matches);
return () => mq.removeEventListener('change', handler);
}, [breakpoint]);
return isMobile;
}