Skip to content

Commit

Permalink
oof
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalkr committed Jul 30, 2020
1 parent 2c3b222 commit 6ede019
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
26 changes: 24 additions & 2 deletions pages/_app.tsx
Expand Up @@ -72,7 +72,8 @@ const MainLayout = ({ Component, pageProps }) => {
<GlobalStyles />
{loadFonts && <FontLoader />}
<ModalProvider>
<TinacmsGithubProvider
<MaybeGithubProvider
useGithub={!pageProps.withoutGithub}
onLogin={enterEditMode}
onLogout={exitEditMode}
error={pageProps.error}
Expand Down Expand Up @@ -107,12 +108,33 @@ const MainLayout = ({ Component, pageProps }) => {
</Head>
<GlobalStyle />
<Component {...pageProps} />
</TinacmsGithubProvider>
</MaybeGithubProvider>
</ModalProvider>
</TinaProvider>
)
}

const MaybeGithubProvider = ({
useGithub,
enterEditMode,
exitEditMode,
error,
children,
}: any) => {
if (useGithub) {
return (
<TinacmsGithubProvider
onLogin={enterEditMode}
onLogout={exitEditMode}
error={error}
>
{children}
</TinacmsGithubProvider>
)
}
return children
}

function useShouldLoadFont(cms: TinaCMS) {
const [enabled, setEnabled] = React.useState(cms.enabled)

Expand Down
1 change: 1 addition & 0 deletions pages/test.tsx
Expand Up @@ -23,6 +23,7 @@ export default function TestPage({ guidesIndex, packagesIndex }) {
export const getStaticProps = async ({ preview }) => {
return {
props: {
withoutGithub: true,
preview: !!preview,
guidesIndex: await readMarkdownFile(
path.resolve(process.cwd(), './content/guides/index.md')
Expand Down

0 comments on commit 6ede019

Please sign in to comment.