Skip to content

GenerateMarkdownLinkParams

Params for generateMarkdownLink.

Import:

import type { GenerateMarkdownLinkParams } from 'obsidian-dev-utils/obsidian/link';

Signature:

export interface GenerateMarkdownLinkParams

Properties

PropertyTypeDescription
alias?stringAn alias for the link.
appAppAn Obsidian app instance.
isEmbed?booleanIndicates if the link should be embedded. If not provided, it will be inferred based on the file type.

If true: ![[target]].

If false: [[target]].
isEmptyEmbedAliasAllowed?booleanWhether to allow an empty alias for embeds.

Applicable only if the result link style is LinkStyle.Markdown.

If true: ![](foo.png).

If false: ![foo](foo.png).
isNonExistingFileAllowed?booleanWhether to allow non-existing files.

If false and targetPathOrFile is a non-existing file, an error will be thrown.
isSingleSubpathAllowed?booleanWhether to allow a single subpath.

Applicable only if targetPathOrFile and sourcePathOrFile are the same file.

If true: [[#subpath]].

If false: [[source#subpath]]
linkPathStyle?LinkPathStyleA style of the link path.
linkStyle?LinkStyleA style of the link.
originalLink?stringAn original link text.

If provided, it will be used to infer the values of

- isEmbed - linkStyle - shouldUseAngleBrackets - shouldUseLeadingDotForRelativePaths - shouldUseLeadingSlashForAbsolutePaths

These inferred values will be overridden by corresponding settings if specified.
shouldEscapeAlias?booleanWhether to escape the alias.

Applicable only if the result link style is LinkStyle.Markdown.

If true: [\*\*alias\*\*](link.md).

If false: [**alias**](link.md).
shouldIncludeAttachmentExtensionToEmbedAlias?booleanWhether to include the attachment extension in the embed alias.

Applicable only if isEmptyEmbedAliasAllowed is false.

If true: [foo.png](foo.png).

If false: [foo](foo.png).
shouldUseAngleBrackets?booleanIndicates if the link should use angle brackets.

Applicable only if linkStyle is LinkStyle.Markdown.

If true: [alias](<path with spaces.md>).

If false: [alias](path%20with%20spaces.md).
shouldUseLeadingDotForRelativePaths?booleanIndicates if the link should use a leading dot.

Applicable only if linkPathStyle is LinkPathStyle.RelativePathToSource.

If true: [[./relative/path/to/target]]

If false: [[relative/path/to/target]]
shouldUseLeadingSlashForAbsolutePaths?booleanIndicates if the link should use a leading slash.

Applicable only if linkPathStyle is LinkPathStyle.AbsolutePathInVault.

If true: [[/absolute/path/to/target]]

If false: [[absolute/path/to/target]]
sourcePathOrFilePathOrFileA source path of the link.
subpath?stringA subpath of the link.

Should be empty or start with #.
targetPathOrFilePathOrFileA target path or file.

Links to this page: