Skip to content

renderInternalLink

Renders an internal link.

What clicking the rendered link does depends on what it names:

  • A FILE is opened by Obsidian’s own link handler — and, with RenderInternalLinkParams.shouldRevealFile, additionally revealed in the file explorer. - A FOLDER cannot be opened, so its FOLDER NOTE is — the note whose properties describe the folder itself, resolved through resolveFolderNote (by default from the installed folder-notes plugin’s live configuration). The reveal lands on that note, unless the note is hidden in the explorer, in which case it lands on the folder — revealing a hidden note would highlight nothing. A folder with NO folder note reveals the folder and opens nothing: nothing here ever creates a note.

Everything is resolved at CLICK time rather than at render time, deliberately: a rendered link outlives the operation that produced it, so a destination renamed in between still reveals the right item, and a folder note written after the link appeared is still found.

Import:

import { renderInternalLink } from 'obsidian-dev-utils/obsidian/markdown';

Signature:

function renderInternalLink(params: RenderInternalLinkParams): Promise<HTMLAnchorElement>

Parameters:

ParameterTypeDescription
paramsRenderInternalLinkParamsThe parameters for rendering the internal link.

Returns: Promise<HTMLAnchorElement> — The HTMLAnchorElement containing the rendered internal link.


Links to this page: