diff --git a/components/CookieConsent.js b/components/CookieConsent.js new file mode 100644 index 0000000..a85f122 --- /dev/null +++ b/components/CookieConsent.js @@ -0,0 +1,94 @@ +import React, { useEffect, useState } from "react"; + +const STORAGE_KEY = "allora-cookie-consent"; + +function CookieConsent() { + const [visible, setVisible] = useState(false); + + useEffect(() => { + if (typeof window === "undefined") return; + try { + if (!window.localStorage.getItem(STORAGE_KEY)) { + setVisible(true); + } + } catch (e) { + setVisible(true); + } + }, []); + + const respond = (choice) => { + try { + window.localStorage.setItem(STORAGE_KEY, choice); + } catch (e) {} + setVisible(false); + }; + + if (!visible) return null; + + return ( +
+ + We use cookies to improve your experience. You can accept or decline + non-essential cookies. + +
+ + +
+
+ ); +} + +export default CookieConsent; diff --git a/theme.config.tsx b/theme.config.tsx index 7c6bf10..471182f 100644 --- a/theme.config.tsx +++ b/theme.config.tsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/router' import Link from 'next/link' import { DocsThemeConfig, useConfig } from 'nextra-theme-docs' import AiButton from './components/AiButton.js' +import CookieConsent from './components/CookieConsent.js' const config: DocsThemeConfig = { useNextSeoProps() { @@ -68,16 +69,19 @@ const config: DocsThemeConfig = { // fixed-position container. footer: { component: () => ( -
- -
+ <> +
+ +
+ + ), }, sidebar: {