Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 95b0d7f

Browse files
mickaelzhangrakannimer
authored andcommitted
feat: add the ability to hide a document from the menu (#1354)
1 parent f0baf67 commit 95b0d7f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

core/docz-core/src/lib/Entry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export class Entry {
3939
public readonly fullpath: string
4040
public readonly headings: Heading[]
4141
public readonly id: string
42+
public readonly hidden: boolean
4243
public readonly menu: string | null
4344
public readonly name: string
4445
public readonly route: string
@@ -57,6 +58,7 @@ export class Entry {
5758
this.filepath = filepath
5859
this.fullpath = path.resolve(root, file)
5960
this.link = ''
61+
this.hidden = parsed.hidden || false
6062
this.slug = this.slugify(filepath, config.separator)
6163
this.route = this.getRoute(parsed)
6264
this.name = name

core/gatsby-theme-docz/src/components/NavLink/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ const getCurrentHash = () => {
2222

2323
export const NavLink = React.forwardRef(({ item, ...props }, ref) => {
2424
const docs = useDocs()
25+
const current = useCurrentDoc()
26+
27+
if (item.hidden) {
28+
return null
29+
}
30+
2531
const to = item.route
2632
const headings = docs && getHeadings(to, docs)
27-
const current = useCurrentDoc()
2833
const isCurrent = item.route === current.route
2934
const showHeadings = isCurrent && headings && headings.length > 0
3035
const currentHash = getCurrentHash()

0 commit comments

Comments
 (0)