chore(docs): fix explorer docs on filtering by title
This commit is contained in:
parent
f334e78ed6
commit
4d6e7ccba9
1 changed files with 9 additions and 4 deletions
|
@ -131,7 +131,8 @@ Using this example, the display names of all `FileNodes` (folders + files) will
|
||||||
```ts title="quartz.layout.ts"
|
```ts title="quartz.layout.ts"
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
mapFn: (node) => {
|
mapFn: (node) => {
|
||||||
return (node.displayName = node.displayName.toUpperCase())
|
node.displayName = node.displayName.toUpperCase()
|
||||||
|
return node
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
@ -145,8 +146,12 @@ Note that this example filters on the title but you can also do it via slug or a
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
filterFn: (node) => {
|
filterFn: (node) => {
|
||||||
// set containing names of everything you want to filter out
|
// set containing names of everything you want to filter out
|
||||||
const omit = new Set(["authoring content", "tags", "hosting"])
|
const omit = new Set(["authoring content", "tags", "advanced"])
|
||||||
return !omit.has(node.data.title.toLowerCase())
|
|
||||||
|
// can also use node.slug or by anything on node.data
|
||||||
|
// note that node.data is only present for files that exist on disk
|
||||||
|
// (e.g. implicit folder nodes that have no associated index.md)
|
||||||
|
return !omit.has(node.displayName.toLowerCase())
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
@ -159,7 +164,7 @@ You can access the tags of a file by `node.data.tags`.
|
||||||
Component.Explorer({
|
Component.Explorer({
|
||||||
filterFn: (node) => {
|
filterFn: (node) => {
|
||||||
// exclude files with the tag "explorerexclude"
|
// exclude files with the tag "explorerexclude"
|
||||||
return node.data.tags.includes("explorerexclude") !== true
|
return node.data.tags?.includes("explorerexclude") !== true
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue