Skip to content

Commit 74b6e66

Browse files
committed
fix(People): whoops make it work in SSR
1 parent 48622ae commit 74b6e66

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/ui/templates/PeopleTpl.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,18 @@ const PeopleTpl = (props: PageProps<Queries.PeopleTplQuery>) => {
5353
const genericAvatar = defaultAvatar.edges[0].node.childImageSharp;
5454

5555
// For routing to a specific person
56-
const personId = window.location.pathname
57-
.replace("/people/", "")
58-
.replace("/", "");
59-
const personObj = all.edges.find(
60-
({ node }: { node: PersonNode }) => node.frontmatter?.uid === personId
61-
);
56+
let personObj
57+
if (typeof window !== "undefined") {
58+
const personId = window.location.pathname
59+
.replace("/people/", "")
60+
.replace("/", "");
61+
personObj = all.edges.find(
62+
({ node }: { node: PersonNode }) => node.frontmatter?.uid === personId
63+
)?.node;
64+
}
6265

6366
const [currentPerson, setCurrentPerson] = useState<PersonNode | null>(
64-
personObj?.node ?? null
67+
personObj ?? null
6568
);
6669

6770
// from the <Modal /> component when it closes force a navigation back to

0 commit comments

Comments
 (0)