Skip to content

make.md 插件高级使用案例

本文介绍 make.md 的进阶功能,涵盖双向链接自动化、Dataview 联动、自定义样式和知识图谱构建。

自定义 Callout 样式

在插件设置中添加自定义 callout 类型:

json
{
  "callouts": {
    "insight": {
      "color": "#4CAF50",
      "icon": "lightbulb",
      "title": "💡 洞察"
    },
    "action": {
      "color": "#FF5722",
      "icon": "rocket",
      "title": "🚀 行动"
    }
  }
}
markdown
> [!insight] 关键洞察
> 通过标签系统的层级结构,可以实现主题的渐进式细分。

> [!action] 下一步行动
> 1. 重构笔记标签体系
> 2. 清理重复标签

双向链接自动化

Templater 自动建立链接

markdown
<%*
const topic = await tp.system.prompt("笔记主题:");
const related = await tp.system.prompt("相关笔记(逗号分隔):");

// 创建笔记并添加相关链接
await tp.file.create_new(
  `# ${topic}\n\n## 定义\n\n## 示例\n\n## 相关\n`,
  topic.replace(/\s+/g, '-')
);

if (related) {
  const links = related.split(',').map(s => `[[${s.trim()}]]`).join('\n');
  await tp.file.append(tp.file.filename(), `\n\n## 相关\n\n${links}`);
}
-%>

孤立笔记检查

dataview
TABLE file.link AS 笔记, file.mtime AS 修改时间
FROM ""
WHERE file.mtime >= date(today) - dur(30 days)
WHERE length(file.inlinks) = 0
SORT file.mtime DESC

无传入链接的笔记将被列出,便于补充关联。

Dataview 联动

知识库统计面板

dataview
TABLE 
  length(file.tags) AS 标签数,
  length(file.outlinks) AS 链接数,
  length(file.tasks) AS 任务数,
  file.mtime AS 修改时间
FROM ""
WHERE file.mtime >= date(today) - dur(30 days)
SORT file.mtime DESC
LIMIT 20

标签关联分析

dataview
TABLE 
  regexreplace(string(file.tags), "#", "") AS 标签,
  length(file.outlinks) AS 链接数
FROM ""
WHERE length(file.tags) > 0
GROUP BY file.tags[0]
SORT length(file.outlinks) DESC

块级操作进阶

块 ID 导航

markdown
# 源笔记
## 方法论 ^methodology-section

这是方法的详细描述...

# 引用笔记
![[源笔记#^methodology-section]]

目录自动化

动态目录生成

markdown
<%*
const headings = app.metadataCache.getFileCache(
  app.workspace.getActiveFile()
)?.headings || [];

const toc = headings.map(h => {
  const indent = '  '.repeat(h.level - 1);
  const anchor = h.heading.replace(/ /g, '-');
  return `${indent}- [[#${anchor}]]`;
}).join('\n');
-%>

## 目录

<% toc %>

---

<!-- 笔记正文 -->

知识图谱构建

链接质量评估

dataview
TABLE 
  file.link AS 笔记,
  length(file.outlinks) AS 传出,
  length(file.inlinks) AS 传入,
  length(file.outlinks) + length(file.inlinks) AS 活跃度
FROM ""
WHERE length(file.outlinks) + length(file.inlinks) > 5
SORT 活跃度 DESC
LIMIT 10

高活跃度笔记通常是笔记网络中的枢纽节点。

CSS 自定义

css
/* 自定义 callout 渐变背景 */
.callout[data-callout="insight"] {
  --callout-color: 76, 175, 80;
  background: linear-gradient(135deg, rgba(76,175,80,0.1), rgba(76,175,80,0.05));
  border-left: 4px solid #4CAF50;
}

/* 标签面板美化 */
.tag-panel {
  background: var(--background-secondary);
  border-radius: 8px;
  padding: 12px;
}

常见问题

Q: 自定义 callout 不生效?

  1. 确认插件版本支持自定义 callout
  2. 检查设置中 JSON 格式是否正确
  3. 重启 Obsidian

Q: 目录生成遗漏标题?

确保标题使用标准 Markdown 语法(###),而非 HTML 标签。

Q: 块引用失效?

块 ID 必须在笔记内唯一。移动包含块 ID 的段落后需重新定义块 ID。