Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the ability to hide a document from the menu #1354

Merged
merged 1 commit into from
Jan 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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