| name | using-obsidian-api |
| description | This rule provides instruction for interacting with the Obsidian API |
Obsidian Bases API
Main types
BasesEntry: Represents a note/entry with properties
BasesViewConfig: View configuration (user options)
BasesPropertyId: Property identifier (string)
App: Obsidian application instance
TFile: Obsidian file
Data access
const value = entry.getValue(propertyId);
const displayName = config.getDisplayName(propertyId);
import { getResourcePath } from "@/lib/obsidian/link";
const imageSrc = getResourcePath(app, imageUrl, entry.file.path);
Context
The Obsidian context exposes shared Obsidian variables.
const { app, component, containerEl, isEmbedded } = useObsidian();
Available hooks
Define and use reusable hooks to wrap Obsidian features in src/hooks to simplify the workflow and increase reusability
const layout = useConfigValue<"vertical" | "horizontal">("layout", "vertical");
const entry = useEntry(entryId);
const property = useEntryProperty(entryId, propertyId);
const title = useEntryTitle(entryId);
const handleOpen = useEntryOpen(entryId);
const handleHover = useEntryHover(entryId, linkRef);