build: resolve build related to global window

This commit is contained in:
Jean-Philippe Sirois
2020-05-12 00:14:19 -04:00
parent 9840502612
commit 5e8edd29d4
+8 -1
View File
@@ -23,7 +23,14 @@ function extractTitle(title: string): ITitle {
} }
export const Toc: FC<ITocProps> = ({ header, items }) => { export const Toc: FC<ITocProps> = ({ 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 ( return (
<SC.TocWrapper> <SC.TocWrapper>
{header} {header}