Skip to content

Obsidian

Obsidian 是一个强大的知识库,基于本地纯文本 Markdown 文件夹工作。Protocol Launcher 允许您生成深度链接以在 Obsidian 中打开笔记、创建新笔记、搜索和执行命令。

使用方式

有两种使用此库的方式:

  • 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
  • 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。

生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。

选择安装方式

按需加载
推荐使用。生产环境优化。
全量导入
使用便捷。适合快速脚本。

打开 Obsidian

On-Demand
ts
import { open } from 'protocol-launcher/obsidian'

const url = open()

打开笔记

在 Obsidian 中打开特定的笔记。

On-Demand
ts
import { openNote } from 'protocol-launcher/obsidian'

const url = openNote({
  vault: 'My Vault',
  file: 'Notes/Meeting.md',
})

新建笔记

在 Obsidian 中创建新笔记。

On-Demand
ts
import { newNote } from 'protocol-launcher/obsidian'

const url = newNote({
  vault: 'My Vault',
  name: 'New Note',
  content: 'Hello World',
})

搜索

在 Obsidian 中搜索笔记。

On-Demand
ts
import { search } from 'protocol-launcher/obsidian'

const url = search({
  vault: 'My Vault',
  query: 'meeting notes',
})

插入内容

在 Obsidian 的当前笔记中插入内容。

On-Demand
ts
import { insert } from 'protocol-launcher/obsidian'

const url = insert({
  vault: 'My Vault',
  content: '## Heading',
})

执行命令

在 Obsidian 中执行命令。

On-Demand
ts
import { command } from 'protocol-launcher/obsidian'

const url = command({
  vault: 'My Vault',
  id: 'editor:save-file',
})

选项

打开 Obsidian 的选项(快速设置)。

On-Demand
ts
import { options } from 'protocol-launcher/obsidian'

const url = options({
  vault: 'My Vault',
})

设置

打开 Obsidian 设置。

On-Demand
ts
import { settings } from 'protocol-launcher/obsidian'

const url = settings({
  vault: 'My Vault',
  page: 'editor',
})