From 6e3b2263b0fa4464dad9d4997abc6f6a5804797c Mon Sep 17 00:00:00 2001 From: Sonny Date: Sat, 25 Nov 2023 19:32:09 +0100 Subject: [PATCH] fix: window is not defined (server) --- src/components/Links/LinkFavicon.tsx | 14 ++++++++------ src/pages/privacy.tsx | 9 ++++----- src/pages/terms.tsx | 13 ++++++------- src/styles/globals.scss | 1 + src/styles/legal-pages.module.scss | 15 +++++---------- 5 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/components/Links/LinkFavicon.tsx b/src/components/Links/LinkFavicon.tsx index bd584c4..ea409ac 100644 --- a/src/components/Links/LinkFavicon.tsx +++ b/src/components/Links/LinkFavicon.tsx @@ -14,15 +14,17 @@ interface LinkFaviconProps { // The Favicon API should always return an image, so it's not really useful to keep the loader nor placeholder icon, // but for slow connections and other random stuff, I'll keep this export default function LinkFavicon({ - url, - size = 32, - noMargin = false - }: LinkFaviconProps) { + url, + size = 32, + noMargin = false, +}: LinkFaviconProps) { const [isFailed, setFailed] = useState(false); const [isLoading, setLoading] = useState(true); - const baseUrlApi = process.env.NEXT_PUBLIC_API_URL || (typeof window !== "undefined" && window)?.location?.origin + "/api"; + const baseUrlApi = + process.env.NEXT_PUBLIC_API_URL || + (typeof window !== "undefined" && window)?.location?.origin + "/api"; if (!baseUrlApi) { - console.warn('Missing API URL') + console.warn("Missing API URL"); } const setFallbackFavicon = () => setFailed(true); diff --git a/src/pages/privacy.tsx b/src/pages/privacy.tsx index 016d13e..71ff61c 100644 --- a/src/pages/privacy.tsx +++ b/src/pages/privacy.tsx @@ -2,16 +2,16 @@ import LinkTag from "next/link"; import PageTransition from "components/PageTransition"; import styles from "styles/legal-pages.module.scss"; import clsx from "clsx"; -import Navbar from "../components/Navbar/Navbar"; +import Navbar from "components/Navbar/Navbar"; import { getServerSideTranslation } from "../i18n"; import { useTranslation } from "next-i18next"; -import { TFunctionParam } from "../types/i18next"; +import { TFunctionParam } from "types/i18next"; export default function Privacy() { const { t } = useTranslation("privacy"); return ( - +

{t("privacy:title")}

@@ -55,9 +55,8 @@ export default function Privacy() {

{t("privacy:contact.description")}{" "} - sonnyasdev[at]gmail.com + sonnyasdev[at]gmail[dot]com - .

{t("privacy:footer.changes")}

diff --git a/src/pages/terms.tsx b/src/pages/terms.tsx index 0e54ce7..064ce66 100644 --- a/src/pages/terms.tsx +++ b/src/pages/terms.tsx @@ -3,15 +3,15 @@ import styles from "styles/legal-pages.module.scss"; import clsx from "clsx"; import LinkTag from "next/link"; import Navbar from "components/Navbar/Navbar"; -import { getServerSideTranslation } from "../i18n"; +import { getServerSideTranslation } from "i18n"; import { Trans, useTranslation } from "next-i18next"; -import { TFunctionParam } from "../types/i18next"; +import { TFunctionParam } from "types/i18next"; import PATHS from "constants/paths"; export default function Terms() { const { t } = useTranslation("terms"); return ( - +

{t("terms:title")}

@@ -61,9 +61,8 @@ export default function Terms() {

{t("terms:contact.description")}{" "} - sonnyasdev[at]gmail.com + sonnyasdev[at]gmail[dot]com - .

{t("terms:footer.changes")}

@@ -76,7 +75,7 @@ export default function Terms() { export async function getServerSideProps({ locale }) { return { props: { - ...(await getServerSideTranslation(locale, ["terms"])), - }, + ...(await getServerSideTranslation(locale, ["terms"])) + } }; } diff --git a/src/styles/globals.scss b/src/styles/globals.scss index 003c9c5..a1a6ce9 100644 --- a/src/styles/globals.scss +++ b/src/styles/globals.scss @@ -33,6 +33,7 @@ body { width: 1280px; padding: 0.5em; display: flex; + flex-direction: column; } a { diff --git a/src/styles/legal-pages.module.scss b/src/styles/legal-pages.module.scss index 3eab0de..27321a5 100644 --- a/src/styles/legal-pages.module.scss +++ b/src/styles/legal-pages.module.scss @@ -1,24 +1,19 @@ -.privacy { - height: 100%; - flex-direction: column; -} - -.privacy main { +.legal main { overflow: auto; } -.privacy h1 { +.legal h1 { margin-top: 0.5em; } -.privacy h2 { +.legal h2 { margin-top: 1.5em; } -.privacy h3 { +.legal h3 { margin-top: 1em; } -.privacy p { +.legal p { margin-top: 0.5em; }