Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(site): create wrapPageElement to group page layout #43

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading