remark-obsidian-link
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

remark-obsidian-link

This package turns Obsidian-style wiki-links to mdast-links. It uses remark-wiki-link internally to parse wiki-links from markdown, and then visits each wiki-link node in the mdast and transforms it based on toLink.

const toLink = (wikiLink) => ({
  value: wikiLink.value,
  uri: `/${wikiLink.value}`,
});

unified().use(remarkParse).use(remarkObsidianLink, { toLink });

toLink option

toLink is an option that allows you to customize the transformation from wiki link to link.

The input is WikiLink:

type WikiLink = { value: string; alias?: string };

The output is either string or Link

type Link = { value: string; uri: string; title?: string };

If the return is of type string, then the wiki link will be replaced by that string as mdast-text. If it returns a Link it will be replaced by an mdast-link with the appropriate values from Link.

By default toLink returns a string of wikiLink.alias if available, and wikiLink.value otherwise. This will effectively remove all wiki-links.

Readme

Keywords

none

Package Sidebar

Install

npm i remark-obsidian-link

Weekly Downloads

3

Version

0.3.0

License

ISC

Unpacked Size

6.09 kB

Total Files

5

Last publish

Collaborators

  • aegatlin