更新 2026-07-01

本站已改为 AI agent 重构的 Astro 项目,目前处于闭源开发状态。

原配置项目 需在 Obsidian 下载并安装 Obsidian-Digital-Garden 插件,可自行查阅相关文档 加以了解

选择理由

忽略初始设置,不必接触 Git。发布一些笔记更容易,而不是将整个内容库发布到您的数字花园。

通过插件与 Obsidian 集成。同时可以利用来自 Obsidian 社区的令人难以置信的插件和主题,支持如 Dataview、Excalidraw 和 Obisidian 主题等特定功能。

SEO 友好,Lighthouse 评分优秀

Lighthouse评分

发现的问题与缺陷

  1. 未能成功渲染 Dataview 内联数据查询,Issue 141
  2. 未支持 Dataview 的 Calendar 渲染
  3. 未支持 Excalidraw 插件内的双链等其他功能,Issue 132
  4. 插件发布文档频繁无法读取,经常空转,Issue 578

我的修复

  1. 对标题使用双链,侧边栏目录为渲染,显示为文件路径

解决方案: 在 sidebar.njk 里,先用 link 过滤器处理 content,再生成 TOC:

{%if settings.dgShowToc === true%}
    {# 先用 link 过滤器处理 content #}
    {% set processedContent = content | link %}
    {% set tocHtml = (processedContent and (processedContent | toc)) %}
    {% if tocHtml %}
        <div class="toc">
            <div class="toc-title-container">
                <div class="toc-title">
                    <!-- On this page -->
                </div>
            </div>
            <div class="toc-container">
                {{ tocHtml | safe }}
            </div>
        </div>
    {% endif %}
{%endif%}
  1. 代码块内使用 html 代码:a href="\" 被误识别为反向链接到主页。

解决方案:需要在 extractLinks 方法中,先去除代码块内容(包括 markdown 代码块和 HTML <pre> 块),再提取链接。

const wikiLinkRegex = /\[\[(.*?\|.*?)\]\]/g;
const internalLinkRegex = /href="\/(.*?)"/g;

function caselessCompare(a, b) {
  return a.toLowerCase() === b.toLowerCase();
}

function extractLinks(content) {
  // 去除 markdown 代码块和 HTML <pre> 块
  const withoutCodeBlocks = content
    .replace(/```[\s\S]*?```/g, "")      // 去除 markdown 代码块
    .replace(/<pre[\s\S]*?<\/pre>/gi, ""); // 去除 HTML <pre> 块

  return [
    ...(withoutCodeBlocks.match(wikiLinkRegex) || []).map(
      (link) =>
        link
          .slice(2, -2)
          .split("|")[0]
          .replace(/.(md|markdown)\s?$/i, "")
          .replace("\\", "")
          .trim()
          .split("#")[0]
    ),
    ...(withoutCodeBlocks.match(internalLinkRegex) || []).map(
      (link) =>
        link
          .slice(6, -1)
          .split("|")[0]
          .replace(/.(md|markdown)\s?$/i, "")
          .replace("\\", "")
          .trim()
          .split("#")[0]
    ),
  ];
}

// ...existing code...

其他配置方案

Obsidian Publish
Obsidian-webpage-export
Welcome to Quartz 4
11 Open-source Free Tools to build your own Digital Garden

作者头像
Davon
原创 花园配置办法

本文采用CC BY-NC-SA 4.0 许可协议,转载请注明出处。