From 6e04aed8d5cb6ac3c46d74e05cb7217eea94846a Mon Sep 17 00:00:00 2001 From: Team3 Date: Mon, 25 May 2026 19:28:22 +0200 Subject: [PATCH] update --- src/fs.ts | 12 +++++++++++- src/views/GraphView.ts | 12 +++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/fs.ts b/src/fs.ts index e91b1af..d870e3e 100644 --- a/src/fs.ts +++ b/src/fs.ts @@ -57,12 +57,22 @@ export function listMarkdownFiles(app: App, path: string, exclude: string[] = [] .sort((a, b) => a.basename.localeCompare(b.basename)); } +export function listAllFiles(app: App, path: string, exclude: string[] = []): TFile[] { + const folder = path ? app.vault.getAbstractFileByPath(normalizePath(path)) : app.vault.getRoot(); + if (!(folder instanceof TFolder)) return []; + return folder.children + .filter((c): c is TFile => c instanceof TFile) + .filter((f) => !exclude.includes(f.name)) + .filter((f) => !f.basename.startsWith("_") || f.basename.startsWith("__")) + .sort((a, b) => a.basename.localeCompare(b.basename)); +} + export function listCollectionFeatures( app: App, project: string, collection: string, ): TFile[] { - return listMarkdownFiles(app, collectionPath(project, collection), []); + return listAllFiles(app, collectionPath(project, collection), []); } export async function readFile(app: App, path: string): Promise { diff --git a/src/views/GraphView.ts b/src/views/GraphView.ts index f0b2a48..3ebacdb 100644 --- a/src/views/GraphView.ts +++ b/src/views/GraphView.ts @@ -20,12 +20,14 @@ function escapeHtml(s: string): string { .replace(/'/g, "'"); } -function nodeTemplate(data: { name: string; features: string[] }): string { +interface FeatureEntry { file: string; label: string } + +function nodeTemplate(data: { name: string; features: FeatureEntry[] }): string { const name = escapeHtml(data.name); const badges = data.features .map( (f) => - `${escapeHtml(f)}`, + `${escapeHtml(f.label)}`, ) .join(""); return ` @@ -171,7 +173,7 @@ export class GraphView { valign: "center", halignBox: "center", valignBox: "center", - tpl: (d: { name: string; features: string[] }) => nodeTemplate(d), + tpl: (d: { name: string; features: FeatureEntry[] }) => nodeTemplate(d), }, ]); @@ -204,7 +206,7 @@ export class GraphView { visited.add(child); const id = `n_${child}`; const features = listCollectionFeatures(this.app, this.project, child) - .map((f) => f.basename); + .map((f) => ({ file: f.name, label: f.basename })); const { w, h } = this.nodeSize(features.length); els.push({ data: { id, name: child, depth, features, w, h }, @@ -374,7 +376,7 @@ export class GraphView { if (featEl?.dataset.feature) { void openMarkdown( this.app, - normalizePath(`${collectionPath(this.project, upName)}/${featEl.dataset.feature}.md`), + normalizePath(`${collectionPath(this.project, upName)}/${featEl.dataset.feature}`), this.leaf, ); } else {