Skip to content

Commit

Permalink
fix: handle document location for build phase (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenweb committed Oct 5, 2019
1 parent c542fb1 commit 0c4d894
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/sidebar/treeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import ClosedSvg from '../images/closed';
import config from '../../../config';
import Link from "../link";

const TreeNode = ({className = '', setCollapsed, collapsed, url, title, items, location = document.location, ...rest}) => {
const TreeNode = ({className = '', setCollapsed, collapsed, url, title, items, ...rest}) => {
const isCollapsed = collapsed[url];
const collapse = () => {
setCollapsed(url);
}
const hasChildren = items.length !== 0;
let location;
if(typeof(document) != 'undefined') {
location = document.location;
}
const active =
location && (location.pathname === url || location.pathname === (config.gatsby.pathPrefix + url));
const calculatedClassName = `${className} item ${active ? 'active' : ''}`;
Expand Down

0 comments on commit 0c4d894

Please sign in to comment.