From 5e8edd29d42b40baef063787d04524dcc0b736ba Mon Sep 17 00:00:00 2001 From: Jean-Philippe Sirois Date: Tue, 12 May 2020 00:14:19 -0400 Subject: [PATCH] build: resolve build related to global window --- src/components/Toc/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/Toc/index.tsx b/src/components/Toc/index.tsx index 48c1016..06350f5 100644 --- a/src/components/Toc/index.tsx +++ b/src/components/Toc/index.tsx @@ -23,7 +23,14 @@ function extractTitle(title: string): ITitle { } export const Toc: FC = ({ header, items }) => { - const { pathname } = window.location + const windowGlobal = typeof window !== "undefined" && window + + // window is not available on build + if (!windowGlobal) { + return null + } + + const { pathname } = windowGlobal.location return ( {header}