0.3.0 • Published 1 year ago

remark-obsidian-link v0.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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.

0.3.0

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago