Skip to content

Commit

Permalink
feat: add the ability to hide a document from the menu (#1354)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelzhang authored and rakannimer committed Jan 12, 2020
1 parent f0baf67 commit 95b0d7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions core/docz-core/src/lib/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class Entry {
public readonly fullpath: string
public readonly headings: Heading[]
public readonly id: string
public readonly hidden: boolean
public readonly menu: string | null
public readonly name: string
public readonly route: string
Expand All @@ -57,6 +58,7 @@ export class Entry {
this.filepath = filepath
this.fullpath = path.resolve(root, file)
this.link = ''
this.hidden = parsed.hidden || false
this.slug = this.slugify(filepath, config.separator)
this.route = this.getRoute(parsed)
this.name = name
Expand Down
7 changes: 6 additions & 1 deletion core/gatsby-theme-docz/src/components/NavLink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ const getCurrentHash = () => {

export const NavLink = React.forwardRef(({ item, ...props }, ref) => {
const docs = useDocs()
const current = useCurrentDoc()

if (item.hidden) {
return null
}

const to = item.route
const headings = docs && getHeadings(to, docs)
const current = useCurrentDoc()
const isCurrent = item.route === current.route
const showHeadings = isCurrent && headings && headings.length > 0
const currentHash = getCurrentHash()
Expand Down

0 comments on commit 95b0d7f

Please sign in to comment.