How to use the docz.useCurrentDoc function in docz

To help you get started, we’ve selected a few docz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github doczjs / docz / core / gatsby-theme-docz / src / components / NavGroup / index.js View on Github external
export const NavGroup = ({ item, sidebarRef }) => {
  const currentDoc = useCurrentDoc()
  const currentDocRef = React.useRef()
  const { name, menu } = item
  const [subheadingsVisible, setShowsubheadings] = React.useState(
    currentDoc.menu === name
  )
  const toggleSubheadings = () => setShowsubheadings(!subheadingsVisible)
  React.useEffect(() => {
    if (sidebarRef.current && currentDocRef.current) {
      sidebarRef.current.scrollTo(0, currentDocRef.current.offsetTop)
    }
  }, [])
  return (
    <div data-testid="nav-group">
      <div>
        {item.name}
        </div></div>
github doczjs / docz / core / gatsby-theme-docz / src / components / NavLink / index.js View on Github external
export const NavLink = React.forwardRef(({ item, ...props }, ref) =&gt; {
  const docs = useDocs()
  const to = item.route
  const headings = docs &amp;&amp; getHeadings(to, docs)
  const current = useCurrentDoc()
  const isCurrent = item.route === current.route
  const showHeadings = isCurrent &amp;&amp; headings &amp;&amp; headings.length &gt; 0
  const currentHash = getCurrentHash()
  return (
    
      
      {showHeadings &amp;&amp;
        headings.map(heading =&gt; (
github doczjs / docz / core / gatsby-theme-docz / src / components / Sidebar / index.js View on Github external
export const Sidebar = React.forwardRef((props, ref) =&gt; {
  const [query, setQuery] = useState('')
  const menus = useMenus({ query })
  const currentDoc = useCurrentDoc()
  const currentDocRef = useRef()
  const handleChange = ev =&gt; {
    setQuery(ev.target.value)
  }
  useEffect(() =&gt; {
    if (ref.current &amp;&amp; currentDocRef.current) {
      ref.current.scrollTo(0, currentDocRef.current.offsetTop)
    }
  }, [])
  return (
    &lt;&gt;
      
        {props.open &amp;&amp; }

docz

It's has never been so easy to documents your things!

MIT
Latest version published 3 years ago

Package Health Score

62 / 100
Full package analysis