Skip to content

Commit

Permalink
Merge pull request #43 from samcyn/feat/site
Browse files Browse the repository at this point in the history
style(site): create wrapPageElement to group page layout
  • Loading branch information
samcyn authored Apr 18, 2024
2 parents 88749a5 + 66c4e79 commit ea4b209
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
8 changes: 7 additions & 1 deletion packages/site/gatsby-browser.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export { default as wrapPageElement } from './src/components/AppLayout';
/* eslint-disable @typescript-eslint/naming-convention */
import LayoutComponent from './wrapPageElement';

// tailwind css
import './src/styles/global.css';

export const wrapPageElement = LayoutComponent;
5 changes: 4 additions & 1 deletion packages/site/gatsby-ssr.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export { default as wrapPageElement } from './src/components/AppLayout';
/* eslint-disable @typescript-eslint/naming-convention */
import LayoutComponent from './wrapPageElement';

export const wrapPageElement = LayoutComponent;
9 changes: 3 additions & 6 deletions packages/site/src/components/AppLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement } from 'react';
import React, { ReactNode } from 'react';
import { MDXProvider } from '@mdx-js/react';

import AppAside from '@components/AppAside';
Expand All @@ -7,10 +7,7 @@ import ThemeProvider from '../../providers/theme';
import AppFooter from '@components/AppFooter';
import { shortcodes } from '@components/AppShortCodes';

// tailwind css
import '../../styles/global.css';

const AppLayout = ({ element }: { element: ReactElement }) => {
const AppLayout = ({ children }: { children: ReactNode }) => {
const [open, setOpen] = React.useState(false);

const onOpen = () => {
Expand All @@ -33,7 +30,7 @@ const AppLayout = ({ element }: { element: ReactElement }) => {
)}
<section className="px-4 md:px-6 xl:px-19">
<AppHeader onOpen={onOpen} />
<MDXProvider components={shortcodes}>{element}</MDXProvider>
<MDXProvider components={shortcodes}>{children}</MDXProvider>
<AppFooter />
</section>
</section>
Expand Down
7 changes: 7 additions & 0 deletions packages/site/wrapPageElement.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */
import React from 'react';
import AppLayout from './src/components/AppLayout';

const wrapPageElement = ({ element, props }) => <AppLayout {...props}>{element}</AppLayout>;

export default wrapPageElement;

0 comments on commit ea4b209

Please sign in to comment.