npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@knewbeing/markdown-it-bi-directional-links

v1.1.1

Published

[![npm version](https://img.shields.io/npm/v/@knewbeing/markdown-it-bi-directional-links.svg)](https://www.npmjs.com/package/@knewbeing/markdown-it-bi-directional-links) [![license](https://img.shields.io/npm/l/@knewbeing/markdown-it-bi-directional-links

Readme

@knewbeing/markdown-it-bi-directional-links

npm version license

将 Obsidian 风格的 [[wikilink]] 语法转换为标准 HTML 链接的 markdown-it 插件。

支持 Markdown 文件、图片、音频、视频的双向链接解析,自动在文件系统中查找匹配文件并生成正确的相对或绝对路径链接。


版权声明 / Copyright

本包代码派生自 @nolebase/markdown-it-bi-directional-links(MIT 许可证)。
原始版权归 nolebase 所有。
knewbeing(知在,[email protected])改进并重新发布,修改部分仍遵循 MIT 许可证。

This package is derived from @nolebase/markdown-it-bi-directional-links (MIT License).
Original copyright belongs to nolebase.
Improved and republished by knewbeing ([email protected]). Modifications remain under MIT License.


功能特性 / Features

  • 🔗 Wikilink 语法 — 支持 [[文件名]][[文件名|显示文本]] 两种格式
  • 📁 自动文件查找 — 在指定目录下通过 glob 递归匹配目标文件
  • 🖼 多媒体支持 — 自动识别图片(PNG/JPG/GIF/SVG/WebP 等)、音频(MP3/WAV/OGG 等)、视频(MP4/WebM/MOV 等)并生成对应 HTML 标签
  • 冲突处理 — 同名文件冲突时自动退化为全路径匹配
  • 🛣 相对/绝对路径 — 支持 isRelativePath 选项切换路径模式,兼容 VitePress 和 VuePress
  • 🐛 调试模式 — 可选开启详细日志,方便排查链接解析问题
  • ⚠️ 无效链接渲染stillRenderNoMatched 选项支持仍渲染未匹配的链接(带 CSS 标记)

安装 / Installation

npm install @knewbeing/markdown-it-bi-directional-links
# or
pnpm add @knewbeing/markdown-it-bi-directional-links

快速开始 / Quick Start

在 VitePress 中使用

// .vitepress/config.ts
import { defineConfig } from 'vitepress'
import { BiDirectionalLinks } from '@knewbeing/markdown-it-bi-directional-links'
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'node:url'

const __dirname = dirname(fileURLToPath(import.meta.url))

export default defineConfig({
  markdown: {
    config: (md) => {
      md.use(BiDirectionalLinks({
        dir: resolve(__dirname, '../'),
      }))
    },
  },
})

在 markdown-it 中直接使用

import MarkdownIt from 'markdown-it'
import { BiDirectionalLinks } from '@knewbeing/markdown-it-bi-directional-links'

const md = new MarkdownIt()
md.use(BiDirectionalLinks({ dir: '/path/to/docs' }))

const result = md.render('[[my-page]]')
// <p><a href="/my-page">my-page</a></p>

语法示例 / Syntax

<!-- 链接到 Markdown 文件 -->
[[page-name]]
[[page-name|自定义文字]]

<!-- 链接到图片 -->
[[image.png]]
[[image.png|图片描述]]

<!-- 嵌入图片(以 ! 开头) -->
![[image.png]]

<!-- 链接到音频 -->
[[audio.mp3]]

<!-- 链接到视频 -->
[[video.mp4]]

<!-- 带锚点的链接 -->
[[page-name#section]]

<!-- 带查询参数的链接 -->
[[page-name?tab=2]]

配置项 / Options

BiDirectionalLinksOptions

| 参数 | 类型 | 默认值 | 说明 | |------|------|--------|------| | dir | string | cwd() | 搜索文件的根目录(绝对路径) | | baseDir | string | '/' | 生成链接的 base 前缀 | | includesPatterns | string[] | ['**/*.md', '**/*.png', ...] | 参与匹配的 glob 规则 | | excludesPatterns | string[] | ['_*', 'dist', 'node_modules'] | 排除的 glob 规则 | | debug | boolean | false | 开启调试日志 | | noNoMatchedFileWarning | boolean | false | 禁用"未找到文件"警告 | | stillRenderNoMatched | boolean | false | 未匹配时仍渲染链接(href 为空,带 .nolebase-route-link-invalid class) | | isRelativePath | boolean | false | 强制使用相对路径(而非绝对路径) |


许可证 / License

MIT

相关链接 / Links