diff --git a/src/components/PageLayout/Context.js b/src/components/PageLayout/Context.js new file mode 100644 index 000000000..e3049cf1c --- /dev/null +++ b/src/components/PageLayout/Context.js @@ -0,0 +1,5 @@ +import { createContext } from 'react'; + +const PageLayoutContext = createContext(); + +export default PageLayoutContext; diff --git a/src/components/PageLayout/PageLayout.js b/src/components/PageLayout/PageLayout.js index 8eeecada0..6750aceac 100644 --- a/src/components/PageLayout/PageLayout.js +++ b/src/components/PageLayout/PageLayout.js @@ -6,6 +6,7 @@ import Content from './Content'; import Header from './Header'; import MarkdownContent from './MarkdownContent'; import RelatedContent from './RelatedContent'; +import Context from './Context'; const TYPES = { SINGLE_COLUMN: 'SINGLE_COLUMN', @@ -57,7 +58,7 @@ const PageLayout = ({ children, type }) => { ${LAYOUTS[type]}; `} > - {children} + {children} ); }; @@ -70,6 +71,7 @@ PageLayout.propTypes = { PageLayout.TYPE = TYPES; PageLayout.Content = Content; +PageLayout.Context = Context; PageLayout.Header = Header; PageLayout.MarkdownContent = MarkdownContent; PageLayout.RelatedContent = RelatedContent; diff --git a/src/hooks/usePageLayout.js b/src/hooks/usePageLayout.js new file mode 100644 index 000000000..6143f068a --- /dev/null +++ b/src/hooks/usePageLayout.js @@ -0,0 +1,6 @@ +import { useContext } from 'react'; +import PageLayout from '../components/PageLayout'; + +const usePageLayout = () => useContext(PageLayout.Context); + +export default usePageLayout;