devbean / obsidian-wordpress

An obsidian plugin for publishing docs to WordPress.
https://devbean.github.io/obsidian-wordpress
Apache License 2.0
158 stars 22 forks source link

能否将[[]]内链解析为外部链接? #32

Open weqoocu opened 1 year ago

weqoocu commented 1 year ago

使用了wordpress插件发布到博客,在yaml区域有的postId, 如果文章中有内链[[]],能否获得内部链接的yaml区域的postId组装成一个地址 比如自己的yaml区域,增加了一个新的字段:source, 这个就是目标地址。能否为这个链接变为这个链接。请大神帮忙评估。

---
source: 'https://www.weqoocu.com/10990.html'
postId: '10990'
---
weqoocu commented 1 year ago

期待这个功能

devbean commented 1 year ago

并没有很理解这个需求。是说在 yaml 中添加了source字段,然后将[[source]]替换为这个 URL 吗?这样的话,如果是多个内部链接,是需要在 yaml 中添加多个类似source的字段?

weqoocu commented 1 year ago

我们的插件,每次发布都会在yaml区域返回一个:postId和categories的字段

---
postId: '11597'
categories:
  - 1119
---

source这个字段,其实是从postId组合出来的,自己的wordpress页面地址格式是这样的:

https://www.weqoocu.com/postId.html

如果发布到wordpress, 发现对应的[[内链]]的yaml区域有postId这个字段,就转化为:

[内链](https://www.weqoocu.com/postId.html)

如果没有postId,就不转换。

不知道我有没有讲清楚, 可以加我微信:weqoocu

非常期待这个功能,不然现在发布文章,有链接不能跳转过去,只显示[[内链]],有点尴尬

devbean commented 1 year ago

这个[内链]是怎样的呀?方便给出一个 markdown 示例吗?

---
postId: '12345'
---

查看本篇文章:[点击这里](https://www.weqoocu.com/{{postId}}.html)

如果有postId,就将{{postId}}替换为对应的 ID?

weqoocu commented 1 year ago

比如:正文如下:

经历了各种[[知识管理工具]], 再深度体验[[obsidian]],发现自己之前的知识管理缺乏体系,从wodrpess时代开始线性的记录,但是总感觉[[知识管理能力|知识管理]]的流程不顺畅,今年接触了卡片盒笔记法和obsidian的双链结构,发现了知识可以进行卡片化、原子化形成卡片盒, 通过建立索引,形成网络化的知识结构,这种方式才是贴近真实的知识结构。 为此,全力转向了obsidian,进一步探索这种模式。


附加知识 [[知识管理工具]]对应的postid是:10660 -》进行替换 [[obsidian]]对应的postid是:12232 -》进行替换 [[知识管理能力|知识管理]]->[[知识管理能力]]对应的postid是:为空 -> 保存不变


发布后的代码为:

经历了各种[知识管理工具](https://www.weqoocu.com/10660.html) , 再深度体验[obsidian](https://www.weqoocu.com/12232.html),发现自己之前的知识管理缺乏体系,从wodrpess时代开始线性的记录,但是总感觉[[知识管理能力|知识管理]]的流程不顺畅,今年接触了卡片盒笔记法和obsidian的双链结构,发现了知识可以进行卡片化、原子化形成卡片盒, 通过建立索引,形成网络化的知识结构,这种方式才是贴近真实的知识结构。 为此,全力转向了obsidian,进一步探索这种模式。

更新的地方,我使用代码标识了一下

devbean commented 1 year ago

也就是说,需要在 YAML 段事先添加好:

---
知识管理工具: 10660
obsidian: 12232
---

这样

weqoocu commented 1 year ago

能否用类似dataview插件,根据文件名自动获取到yaml区域的postid呢?

weqoocu commented 1 year ago

发现wordpress插件有一个插件:支持关键词匹配到对应的链接,目前手动配置一些链接

image

其实我们的wordpress插件,可以类似“增强编辑”这个插件一样,增加一个输入框,可以进行录入: 设置每个双链中文对应的链接地址,比如:

曾国藩:https://www.weqoocu.com/5922.html 酷口家读书会:https://www.weqoocu.com/10421.html 包围式学习法:https://www.weqoocu.com/11060.html

设置好后,后面发布的时候,发现是对应的双链,就替换成为对应的链接


image
weqoocu commented 1 year ago

使用wordrpess的一个插件 "WP Keyword Link" 实现了自动双链: 配置文件如下:

Keyword,URL,NoFollow,First Only,New Window,Ignore Case,IsAffiliate,Enable In Comments,Chinese Keyword,Description "[[罪与罚]]","https://www.weqoocu.com/12797.html",0,0,1,1,0,0,1,"[[罪与罚]]" "[[1万小时定律]]","https://www.weqoocu.com/13004.html",0,0,1,1,0,0,1,"[[1万小时定律]]" "[[能力圈]]","https://www.weqoocu.com/13001.html",0,0,1,1,0,0,1,"[[能力圈]]" "[[康奈尔笔记法]]","https://www.weqoocu.com/12880.html",0,0,1,1,0,0,1,"[[康奈尔笔记法]]" "[[主题研究]]","https://www.weqoocu.com/12865.html",0,0,1,1,0,0,1,"[[主题研究]]" "[[QQ浏览器]]","https://www.weqoocu.com/12862.html",0,0,1,1,0,0,1,"[[QQ浏览器]]" "[[微信键盘]]","https://www.weqoocu.com/12843.html",0,0,1,1,0,0,1,"[[微信键盘]]" "[[微信]]","https://www.weqoocu.com/12832.html",0,0,1,1,0,0,1,"[[微信]]" "[[原子笔记]]","https://www.weqoocu.com/12806.html",0,0,1,1,0,0,1,"[[原子笔记]]" "[[商业画布]]","https://www.weqoocu.com/12795.html",0,0,1,1,0,0,1,"[[商业画布]]" "[[grow教练模型]]","https://www.weqoocu.com/12789.html",0,0,1,1,0,0,1,"[[grow教练模型]]" "[[wp keywords link]]","https://www.weqoocu.com/12747.html",0,0,1,1,0,0,1,"[[wp keywords link]]" "[[chrome 浏览器]]","https://www.weqoocu.com/12735.html",0,0,1,1,0,0,1,"[[chrome 浏览器]]" "[[FormatLink]]","https://www.weqoocu.com/12732.html",0,0,1,1,0,0,1,"[[FormatLink]]" "[[fleetingnotes]]","https://www.weqoocu.com/12728.html",0,0,1,1,0,0,1,"[[fleetingnotes]]" "[[平衡轮]]","https://www.weqoocu.com/12653.html",0,0,1,1,0,0,1,"[[平衡轮]]" "[[卡片盒笔记法]]","https://www.weqoocu.com/12631.html",0,0,1,1,0,0,1,"[[卡片盒笔记法]]" "[[obsidian cardbord]]","https://www.weqoocu.com/12629.html",0,0,1,1,0,0,1,"[[obsidian cardbord]]" "[[阿里巴巴考核机制]]","https://www.weqoocu.com/12556.html",0,0,1,1,0,0,1,"[[阿里巴巴考核机制]]" "[[PDCA]]","https://www.weqoocu.com/12554.html",0,0,1,1,0,0,1,"[[PDCA]]" "[[FARS模型]]","https://www.weqoocu.com/12475.html",0,0,1,1,0,0,1,"[[FARS模型]]" "[[数字花园]]","https://www.weqoocu.com/12465.html",0,0,1,1,0,0,1,"[[数字花园]]" "[[李白]]","https://www.weqoocu.com/12463.html",0,0,1,1,0,0,1,"[[李白]]" "[[wordpress]]","https://www.weqoocu.com/12378.html",0,0,1,1,0,0,1,"[[wordpress]]" "[[readwise]]","https://www.weqoocu.com/12315.html",0,0,1,1,0,0,1,"[[readwise]]" "[[flomo]]","https://www.weqoocu.com/12269.html",0,0,1,1,0,0,1,"[[flomo]]" "[[滴答清单]]","https://www.weqoocu.com/12255.html",0,0,1,1,0,0,1,"[[滴答清单]]" "[[Number Headings]]","https://www.weqoocu.com/12253.html",0,0,1,1,0,0,1,"[[Number Headings]]" "[[五彩插件]]","https://www.weqoocu.com/12240.html",0,0,1,1,0,0,1,"[[五彩插件]]" "[[Sliding Panes]]","https://www.weqoocu.com/12238.html",0,0,1,1,0,0,1,"[[Sliding Panes]]" "[[various complements]]","https://www.weqoocu.com/12236.html",0,0,1,1,0,0,1,"[[various complements]]" "[[obsidian]]","https://www.weqoocu.com/12232.html",0,0,1,1,0,0,1,"[[obsidian]]" "[[cubox]]","https://www.weqoocu.com/12225.html",0,0,1,1,0,0,1,"[[cubox]]" "[[视觉笔记]]","https://www.weqoocu.com/12076.html",0,0,1,1,0,0,1,"[[视觉笔记]]" "[[cmenu]]","https://www.weqoocu.com/12072.html",0,0,1,1,0,0,1,"[[cmenu]]" "[[美团]]","https://www.weqoocu.com/12061.html",0,0,1,1,0,0,1,"[[美团]]" "[[Pandoc]]","https://www.weqoocu.com/12045.html",0,0,1,1,0,0,1,"[[Pandoc]]" "[[daily notes]]","https://www.weqoocu.com/12032.html",0,0,1,1,0,0,1,"[[daily notes]]" "[[达克效应]]","https://www.weqoocu.com/11940.html",0,0,1,1,0,0,1,"[[达克效应]]" "[[STAR法则]]","https://www.weqoocu.com/11846.html",0,0,1,1,0,0,1,"[[STAR法则]]" "[[dataview]]","https://www.weqoocu.com/11831.html",0,0,1,1,0,0,1,"[[dataview]]" "[[Better Command Palette]]","https://www.weqoocu.com/11802.html",0,0,1,1,0,0,1,"[[Better Command Palette]]" "[[billfish]]","https://www.weqoocu.com/11800.html",0,0,1,1,0,0,1,"[[billfish]]" "[[知识投射原理]]","https://www.weqoocu.com/11791.html",0,0,1,1,0,0,1,"[[知识投射原理]]" "[[信息载体]]","https://www.weqoocu.com/11778.html",0,0,1,1,0,0,1,"[[信息载体]]" "[[系统思考]]","https://www.weqoocu.com/11754.html",0,0,1,1,0,0,1,"[[系统思考]]" "[[知识晶体]]","https://www.weqoocu.com/11649.html",0,0,1,1,0,0,1,"[[知识晶体]]" "[[演绎法-归纳法]]","https://www.weqoocu.com/11642.html",0,0,1,1,0,0,1,"[[演绎法-归纳法]]" "[[VARK学习类型]]","https://www.weqoocu.com/11637.html",0,0,1,1,0,0,1,"[[VARK学习类型]]" "[[Snipaste]]","https://www.weqoocu.com/11632.html",0,0,1,1,0,0,1,"[[Snipaste]]" "[[Macbook-深色模式]]","https://www.weqoocu.com/11628.html",0,0,1,1,0,0,1,"[[Macbook-深色模式]]" "[[能力树]]","https://www.weqoocu.com/11617.html",0,0,1,1,0,0,1,"[[能力树]]" "[[chrome插件- 微信读书笔记助手]]","https://www.weqoocu.com/11593.html",0,0,1,1,0,0,1,"[[chrome插件- 微信读书笔记助手]]" "[[记笔记]]","https://www.weqoocu.com/11591.html",0,0,1,1,0,0,1,"[[记笔记]]" "[[Vanilla]]","https://www.weqoocu.com/11585.html",0,0,1,1,0,0,1,"[[Vanilla]]" "[[yaml]]","https://www.weqoocu.com/11573.html",0,0,1,1,0,0,1,"[[yaml]]" "[[增强编辑]]","https://www.weqoocu.com/11571.html",0,0,1,1,0,0,1,"[[增强编辑]]" "[[崔西定律]]","https://www.weqoocu.com/11527.html",0,0,1,1,0,0,1,"[[崔西定律]]" "[[INKP]]","https://www.weqoocu.com/11523.html",0,0,1,1,0,0,1,"[[INKP]]" "[[R90睡眠法]]","https://www.weqoocu.com/11493.html",0,0,1,1,0,0,1,"[[R90睡眠法]]" "[[闪念笔记-滴答清单]]","https://www.weqoocu.com/11473.html",0,0,1,1,0,0,1,"[[闪念笔记-滴答清单]]" "[[6w2h]]","https://www.weqoocu.com/11453.html",0,0,1,1,0,0,1,"[[6w2h]]" "[[人物]]","https://www.weqoocu.com/11419.html",0,0,1,1,0,0,1,"[[人物]]" "[[B站笔记快捷键]]","https://www.weqoocu.com/11395.html",0,0,1,1,0,0,1,"[[B站笔记快捷键]]" "[[flomo to obsidian]]","https://www.weqoocu.com/11385.html",0,0,1,1,0,0,1,"[[flomo to obsidian]]" "[[信息漏斗阅读法]]","https://www.weqoocu.com/11374.html",0,0,1,1,0,0,1,"[[信息漏斗阅读法]]" "[[DICS]]","https://www.weqoocu.com/11368.html",0,0,1,1,0,0,1,"[[DICS]]" "[[识人五层模型]]","https://www.weqoocu.com/11347.html",0,0,1,1,0,0,1,"[[识人五层模型]]" "[[10-30-60原则]]","https://www.weqoocu.com/11344.html",0,0,1,1,0,0,1,"[[10-30-60原则]]" "[[冰山模型]]","https://www.weqoocu.com/11296.html",0,0,1,1,0,0,1,"[[冰山模型]]" "[[obsidian搜索技巧]]","https://www.weqoocu.com/11285.html",0,0,1,1,0,0,1,"[[obsidian搜索技巧]]" "[[2分钟法则]]","https://www.weqoocu.com/11244.html",0,0,1,1,0,0,1,"[[2分钟法则]]" "[[时间颗粒度]]","https://www.weqoocu.com/11238.html",0,0,1,1,0,0,1,"[[时间颗粒度]]" "[[杠杆]]","https://www.weqoocu.com/11225.html",0,0,1,1,0,0,1,"[[杠杆]]" "[[DIKW]]","https://www.weqoocu.com/11183.html",0,0,1,1,0,0,1,"[[DIKW]]" "[[黄金圈思维]]","https://www.weqoocu.com/11166.html",0,0,1,1,0,0,1,"[[黄金圈思维]]" "[[书单]]","https://www.weqoocu.com/11145.html",0,0,1,1,0,0,1,"[[书单]]" "[[MWeb]]","https://www.weqoocu.com/11130.html",0,0,1,1,0,0,1,"[[MWeb]]" "[[信息载体-人事网书]]","https://www.weqoocu.com/11107.html",0,0,1,1,0,0,1,"[[信息载体-人事网书]]" "[[包围式学习法]]","https://www.weqoocu.com/11060.html",0,0,1,1,0,0,1,"[[包围式学习法]]" "[[库伯学习圈]]","https://www.weqoocu.com/11039.html",0,0,1,1,0,0,1,"[[库伯学习圈]]" "[[Smart Hashtags]]","https://www.weqoocu.com/11001.html",0,0,1,1,0,0,1,"[[Smart Hashtags]]" "[[obsidian-wordpress]]","https://www.weqoocu.com/10990.html",0,0,1,1,0,0,1,"[[obsidian-wordpress]]" "[[莫法特休息法]]","https://www.weqoocu.com/10862.html",0,0,1,1,0,0,1,"[[莫法特休息法]]" "[[蔡格尼克记忆效应]]","https://www.weqoocu.com/10861.html",0,0,1,1,0,0,1,"[[蔡格尼克记忆效应]]" "[[帮小忙]]","https://www.weqoocu.com/10848.html",0,0,1,1,0,0,1,"[[帮小忙]]" "[[obsidian-weread]]","https://www.weqoocu.com/10832.html",0,0,1,1,0,0,1,"[[obsidian-weread]]" "[[三八定律]]","https://www.weqoocu.com/10819.html",0,0,1,1,0,0,1,"[[三八定律]]" "[[唐朝]]","https://www.weqoocu.com/10775.html",0,0,1,1,0,0,1,"[[唐朝]]" "[[文字就是自己思考]]","https://www.weqoocu.com/10763.html",0,0,1,1,0,0,1,"[[文字就是自己思考]]" "[[时间管理能力]]","https://www.weqoocu.com/10755.html",0,0,1,1,0,0,1,"[[时间管理能力]]" "[[moc]]","https://www.weqoocu.com/10698.html",0,0,1,1,0,0,1,"[[moc]]" "[[聚群效应]]","https://www.weqoocu.com/10691.html",0,0,1,1,0,0,1,"[[聚群效应]]" "[[知识管理工具]]","https://www.weqoocu.com/10660.html",0,0,1,1,0,0,1,"[[知识管理工具]]" "[[卡片盒笔记法编码体系]]","https://www.weqoocu.com/10658.html",0,0,1,1,0,0,1,"[[卡片盒笔记法编码体系]]" "[[知识管理能力]]","https://www.weqoocu.com/10653.html",0,0,1,1,0,0,1,"[[知识管理能力]]" "[[五分钟读书]]","https://www.weqoocu.com/10622.html",0,0,1,1,0,0,1,"[[五分钟读书]]" "[[Evernote Sync]]","https://www.weqoocu.com/10430.html",0,0,1,1,0,0,1,"[[Evernote Sync]]" "[[酷口家读书会]]","https://www.weqoocu.com/10421.html",0,0,1,1,0,0,1,"[[酷口家读书会]]" "[[查理.芒格传]]","https://www.weqoocu.com/9929.html",0,0,1,1,0,0,1,"[[查理.芒格传]]" "[[底层逻辑]]","https://www.weqoocu.com/8696.html",0,0,1,1,0,0,1,"[[底层逻辑]]" "[[知道做到]]","https://www.weqoocu.com/8694.html",0,0,1,1,0,0,1,"[[知道做到]]" "[[中年的意义]]","https://www.weqoocu.com/8363.html",0,0,1,1,0,0,1,"[[中年的意义]]" "[[商鞅变法]]","https://www.weqoocu.com/8084.html",0,0,1,1,0,0,1,"[[商鞅变法]]" "[[人生九宫格模型]]","https://www.weqoocu.com/7999.html",0,0,1,1,0,0,1,"[[人生九宫格模型]]" "[[讲书稿记录]]","https://www.weqoocu.com/7490.html",0,0,1,1,0,0,1,"[[讲书稿记录]]" "[[子弹笔记]]","https://www.weqoocu.com/7192.html",0,0,1,1,0,0,1,"[[子弹笔记]]" "[[3F原则]]","https://www.weqoocu.com/6998.html",0,0,1,1,0,0,1,"[[3F原则]]" "[[跃迁]]","https://www.weqoocu.com/6966.html",0,0,1,1,0,0,1,"[[跃迁]]" "[[一分钟经理人]]","https://www.weqoocu.com/6143.html",0,0,1,1,0,0,1,"[[一分钟经理人]]" "[[即兴演讲-万能脚本]]","https://www.weqoocu.com/6006.html",0,0,1,1,0,0,1,"[[即兴演讲-万能脚本]]" "[[费曼学习法]]","https://www.weqoocu.com/5989.html",0,0,1,1,0,0,1,"[[费曼学习法]]" "[[曾国藩]]","https://www.weqoocu.com/5922.html",0,0,1,1,0,0,1,"[[曾国藩]]" "[[复利效应]]","https://www.weqoocu.com/5767.html",0,0,1,1,0,0,1,"[[复利效应]]" "[[GTD]]","https://www.weqoocu.com/5670.html",0,0,1,1,0,0,1,"[[GTD]]" "[[三环理论]]","https://www.weqoocu.com/5646.html",0,0,1,1,0,0,1,"[[三环理论]]" "[[八大菜系]]","https://www.weqoocu.com/5636.html",0,0,1,1,0,0,1,"[[八大菜系]]" "[[LuckyWP]]","https://www.weqoocu.com/5540.html",0,0,1,1,0,0,1,"[[LuckyWP]]" "[[图书分类法]]","https://www.weqoocu.com/5384.html",0,0,1,1,0,0,1,"[[图书分类法]]"

weqoocu commented 1 year ago

这个配置文件,可以直接放到插件的设置中,自己是通过dataview插件从库里把双链和postid提出来,然后用腾讯文档进行组合的.

如果我们的插件能配置,就可以直接在发布的时候,自动替换链接