Add i18n to home sections, improve consent management and middleware asset handling
Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
@@ -38,9 +38,11 @@ function writeConsentCookie(value: ConsentState) {
|
||||
const ConsentContext = createContext<{
|
||||
consent: ConsentState | null;
|
||||
setConsent: (next: ConsentState) => void;
|
||||
resetConsent: () => void;
|
||||
}>({
|
||||
consent: null,
|
||||
setConsent: () => {},
|
||||
resetConsent: () => {},
|
||||
});
|
||||
|
||||
export function ConsentProvider({ children }: { children: React.ReactNode }) {
|
||||
@@ -55,7 +57,16 @@ export function ConsentProvider({ children }: { children: React.ReactNode }) {
|
||||
writeConsentCookie(next);
|
||||
}, []);
|
||||
|
||||
const value = useMemo(() => ({ consent, setConsent }), [consent, setConsent]);
|
||||
const resetConsent = useCallback(() => {
|
||||
setConsentState(null);
|
||||
// expire cookie
|
||||
document.cookie = `${COOKIE_NAME}=; path=/; max-age=0; samesite=lax`;
|
||||
}, []);
|
||||
|
||||
const value = useMemo(
|
||||
() => ({ consent, setConsent, resetConsent }),
|
||||
[consent, setConsent, resetConsent],
|
||||
);
|
||||
|
||||
return <ConsentContext.Provider value={value}>{children}</ConsentContext.Provider>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user