From 4afb099bf3ec96e5d795e871ecb19575271c0714 Mon Sep 17 00:00:00 2001
From: Ben Schlegel <ben5.schlegel@gmail.com>
Date: Sun, 17 Sep 2023 19:32:23 +0000
Subject: [PATCH] docs: fix examples
---
quartz/components/ExplorerNode.tsx | 2 +-
docs/features/explorer.md | 18 ++++++------------
2 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/docs/features/explorer.md b/docs/features/explorer.md
index 76d04c6..cb63e40 100644
--- a/docs/features/explorer.md
+++ b/docs/features/explorer.md
@@ -145,25 +145,19 @@
### Remove list of elements (`filter`)
-Using this example, you can remove elements from your explorer by providing a list of folders/files using the `list` array.
+Using this example, you can remove elements from your explorer by providing an array of folders/files using the `omit` set.
```ts title="quartz.layout.ts"
Component.Explorer({
filterFn: (node) => {
- // list containing names of everything you want to filter out
- const list = ["authoring content", "building your", "tags", "hosting"]
-
- for (let listNodeName of list) {
- if (listNodeName.toLowerCase() === node.name.toLowerCase()) {
- return false // Found a match, so return false to filter out the node
- }
- }
- return true // No match found, so return true to keep the node
+ // set containing names of everything you want to filter out
+ const omit = new Set(["authoring content", "tags", "hosting"])
+ return omit.has(node.name.toLowerCase())
},
})
```
-You can customize this by changing the entries of the `list` array. Simply add all folder or file names you want to remove to the array (case insensitive).
+You can customize this by changing the entries of the `omit` set. Simply add all folder or file names you want to remove.
## Advanced examples
@@ -224,7 +218,7 @@
> You can then import them like this:
>
> ```ts title="quartz.layout.ts"
-> import { mapFn, filterFn, sortFn } from "./path/to/your/functions"
+> import { mapFn, filterFn, sortFn } from "./functions.ts"
> Component.Explorer({
> mapFn: mapFn,
> filterFn: filterFn,
diff --git a/quartz/components/ExplorerNode.tsx b/quartz/components/ExplorerNode.tsx
index f8b99f0..fd0c082 100644
--- a/quartz/components/ExplorerNode.tsx
+++ b/quartz/components/ExplorerNode.tsx
@@ -82,7 +82,7 @@
/**
* Filter FileNode tree. Behaves similar to `Array.prototype.map()`, but modifies tree in place
- * @param mapFn function to filter tree with
+ * @param mapFn function to use for mapping over tree
*/
map(mapFn: (node: FileNode) => void) {
mapFn(this)
--
Gitblit v1.10.0