diff --git a/src/components/Inspector.tsx b/src/components/Inspector.tsx index 16e1d554..66c43003 100644 --- a/src/components/Inspector.tsx +++ b/src/components/Inspector.tsx @@ -42,28 +42,44 @@ function wikilinkTarget(ref: string): string { return pipeIdx !== -1 ? inner.slice(0, pipeIdx) : inner } -function RelationshipGroup({ label, refs, onNavigate }: { label: string; refs: string[]; onNavigate: (target: string) => void }) { +function resolveRefType(ref: string, entries: VaultEntry[]): string | undefined { + const target = wikilinkTarget(ref) + const match = entries.find((e) => { + const stem = e.path.replace(/^.*\/Laputa\//, '').replace(/\.md$/, '') + if (stem === target) return true + const fileStem = e.filename.replace(/\.md$/, '') + if (fileStem === target.split('/').pop()) return true + return false + }) + return match?.isA +} + +function RelationshipGroup({ label, refs, entries, onNavigate }: { label: string; refs: string[]; entries: VaultEntry[]; onNavigate: (target: string) => void }) { if (refs.length === 0) return null return (
{label}
- {refs.map((ref, idx) => ( - - ))} + {refs.map((ref, idx) => { + const refType = resolveRefType(ref, entries) + return ( + + ) + })}
) } -function DynamicRelationshipsPanel({ frontmatter, onNavigate }: { frontmatter: ParsedFrontmatter; onNavigate: (target: string) => void }) { +function DynamicRelationshipsPanel({ frontmatter, entries, onNavigate }: { frontmatter: ParsedFrontmatter; entries: VaultEntry[]; onNavigate: (target: string) => void }) { const relationshipEntries = useMemo(() => { return Object.entries(frontmatter) .filter(([key, value]) => RELATIONSHIP_KEYS.has(key) || containsWikilinks(value)) @@ -83,7 +99,7 @@ function DynamicRelationshipsPanel({ frontmatter, onNavigate }: { frontmatter: P

No relationships

) : ( relationshipEntries.map(({ key, refs }) => ( - + )) )}