hasura / gatsby-gitbook-starter

Generate GitBook style modern docs/tutorial websites using Gatsby + MDX
https://hasura.io/learn/graphql/react/introduction/
MIT License
985 stars 376 forks source link

fix sidebar active element highlighting #21

Closed praveenweb closed 5 years ago

praveenweb commented 5 years ago

The highlighting of active element on the left sidebar doesn't seem to work. It's probably an issue with URL matching that ends without slashes.

i001962 commented 5 years ago

22 causes gatsby build to fail.

Building static HTML failed for path "/"

See our docs page for more info on this error: https://gatsby.dev/debug-html

   5 | import Link from "../link";
   6 | 
>  7 | const TreeNode = ({className = '', setCollapsed, collapsed, url, title, items, location = document.location, ...rest}) => {
     |                                                                                           ^
   8 |   const isCollapsed = collapsed[url];
   9 |   const collapse = () => {
  10 |     setCollapsed(url);

  WebpackError: ReferenceError: document is not defined
praveenweb commented 5 years ago

@i001962 - Thanks for pointing out. Builds failed obviously because document is available only on the client and not during build phase. Fixed it via https://github.com/hasura/gatsby-gitbook-starter/commit/0c4d89437e509270a711cf90d8ba8a83a084a01f