UNPKG

docusaurus-theme-frontmatter

Version:

Docusaurus theme plugin to expose front matter through a component hook

14 lines (13 loc) 600 B
// ================================================================= // // Copyright (c) roydukkey. All rights reserved. // // ================================================================= // import { createContext, useContext } from 'react'; export const Context = createContext(null); Context.displayName = 'FrontMatterContext'; export default function useFrontMatter() { const frontMatter = useContext(Context); if (frontMatter === null) { throw new TypeError('No front matter context is available for `useFrontMatter()`.'); } return frontMatter; }