Skip to content

Commit 4d94f71

Browse files
committed
move sparse layout check into client-side
[#65 #69]
1 parent 56ac937 commit 4d94f71

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/templates/month-day.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import React from 'react'
1+
import React, {useEffect, useState} from 'react';
22
import {graphql} from 'gatsby'
3-
// import {format as pf} from 'pretty-format'
43
import MarkdownIt from 'markdown-it'
54

65
import Layout from '../components/layout';
@@ -27,8 +26,11 @@ export default function MonthDay({data, pageContext: {month, day}}) {
2726
allShowNotesJson: {edges: notesOnShows},
2827
} = data;
2928

30-
const isSparseLayout = global?.location?.search === '?ui=sparse'; // TODO this is not very robust
31-
global.console.log({isSparseLayout})
29+
const [isSparseLayout, setSparseLayout] = useState(false);
30+
useEffect(() => {
31+
setSparseLayout(global?.location?.search === '?ui=sparse') // TODO this is not very robust
32+
global?.console.log({isSparseLayout})
33+
}, []);
3234

3335
const dateObj = new Date(2000, month - 1, day); // note — JavaScript's Date object treats 0 = January, 11 = November...
3436
const theDayShort = dateToText(dateObj);

0 commit comments

Comments
 (0)