Skip to content

Commit 0d4d980

Browse files
Feat: exclude from graph with #graph-exclude tag
Notes can be excluded from the graph view by adding the tag `#graph-exclude`. Use-case: Maintenance Templates which are embedded in a page can clutter up the graph. Excluding these gives a better picture of how the actual *content* of the site is interconnected.
1 parent e3d011d commit 0d4d980

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

quartz.layout.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import { PageLayout, SharedLayout } from "./quartz/cfg"
22
import * as Component from "./quartz/components"
33

4+
// MMW: hiding notes from graph via tags
5+
const tagsToRemove = ["graph-exclude"]
6+
const graphConfig = {
7+
localGraph: {
8+
removeTags: tagsToRemove,
9+
excludeTags: ["graph-exclude"]
10+
},
11+
globalGraph: {
12+
removeTags: tagsToRemove,
13+
excludeTags: ["graph-exclude"]
14+
}
15+
};
16+
417
// components shared across all pages
518
export const sharedPageComponents: SharedLayout = {
619
head: Component.Head(),
@@ -52,7 +65,7 @@ export const defaultContentPageLayout: PageLayout = {
5265
folderClickBehavior: "link",
5366
filterFn: (node) => node.name !== "Templates",
5467
})),
55-
Component.DesktopOnly(Component.Graph()),
68+
Component.DesktopOnly(Component.Graph(graphConfig)),
5669
Component.DesktopOnly(Component.TableOfContents()),
5770
Component.Backlinks(),
5871
],
@@ -76,7 +89,7 @@ export const defaultListPageLayout: PageLayout = {
7689
folderClickBehavior: "link",
7790
filterFn: (node) => node.name !== "Templates",
7891
})),
79-
Component.DesktopOnly(Component.Graph()),
92+
Component.DesktopOnly(Component.Graph(graphConfig)),
8093
Component.DesktopOnly(Component.TableOfContents()),
8194
Component.Backlinks(),
8295
],

quartz/components/scripts/graph.inline.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,21 @@ async function renderGraph(container: string, fullSlug: FullSlug) {
8787
removeTags,
8888
showTags,
8989
focusOnHover,
90+
excludeTags,
9091
} = JSON.parse(graph.dataset["cfg"]!) as D3Config
9192

92-
const data: Map<SimpleSlug, ContentDetails> = new Map(
93+
const originalData: Map<SimpleSlug, ContentDetails> = new Map(
9394
Object.entries<ContentDetails>(await fetchData).map(([k, v]) => [
9495
simplifySlug(k as FullSlug),
9596
v,
9697
]),
9798
)
99+
// MMW: Take out files that have the tags in excludeTags
100+
const data: Map<SimpleSlug, ContentDetails> = new Map(
101+
[...originalData.entries()].filter(([key, value]) => {
102+
return !value.tags?.some(tag => excludeTags.includes(tag))
103+
})
104+
)
98105
const links: SimpleLinkData[] = []
99106
const tags: SimpleSlug[] = []
100107
const validLinks = new Set(data.keys())

0 commit comments

Comments
 (0)