obsidian软件使用
这个软件 我也是第一次用:
typora 软件 已经用了好久了, typora 配合我自己定义的 js 脚本用起来太爽了,目前还不习惯 ob软件, 只能 typora 为主, ob为辅
ob 安装的插件
- sliding panel
- from template , 看别人转的,还没用过
- fire explorer note count , 可以快速预览文件夹的内容
双链功能
打上 方括号 就可以 链接到其他笔记, 进入其他笔记也可以快速预览 哪些文件链接到这个笔记,并且互相引用 链接, 目前 我的博客已经 支持 ob双链的功能, 代码如下:
通过正则 匹配括号 ,将 文本替换成链接
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
//hightlight
$(function () {
//双链支持
let ok = window.location.href.indexOf('/post/') > -1;
if (!ok) {
return;
}
//双链支持 和 高亮文本
function _renderText(i, e) {
let $e = $(e);
//raw text
let _t = $e.text();
let hasDoubleLink = _t && _t.indexOf('[[') > -1;
let hasHightLight = _t && _t.indexOf('==') > -1
if (hasDoubleLink) {
//双链渲染
$e.contents()
.filter(function(){
return this.nodeType === 3; //text nodes
}).each(function (i, e) {
const $this = $(this); //$(this).text()
let $text = $this.text();
let t = $this.text().replace(/\[\[(.*)\]\]/g, function (a, b) {
//双链
let prefix = '' //默认相对路径
if (b.indexOf('post') == 0) {
//采用绝对路径
prefix = '/'
}
let link;
let linkName;
// 别名判断
let _arr = b.split('|');
if (_arr[1]) {
linkName = _arr[1];// 别名
link = prefix + _arr[0];
} else {
linkName = b;//默认
link = prefix + b;
}
return '<a class="doubleLink" href="' + link + '" target="_blank">' + linkName + '</a><br/>';
});
if($text != t) {
$this.replaceWith(t);
}
});
}
if (hasHightLight) {
$e.contents().filter(function () {
return this.nodeType === 3; //text nodes
}).each(function () {
let $this = $(this);
let prev = $this.text();
let t = prev.replace(/==(.*)==/g, function (a, b) {
//实现高亮文字
return `<span class='hightlight_text'>` + b + `</span>`;
});
if(prev != t) {//被替换了元素,就更新文本
$this.replaceWith(t);
}
});
}
}
const pdom = $('body .post-content p');
//渲染文本
pdom.each(_renderText);
});
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/* 双链 */
body p a.doubleLink,
a.doubleLink:hover,
a.doubleLink:active {
color: #9ef24a !important;
text-decoration: none;
border-color: #9ef24a !important;
/* border-bottom: 1px solid #9ef24a; */
}
/* 文字高亮 */
.hightlight_text {
background-color: rgb(255, 255, 0);
}
body.dark-theme p span.hightlight_text {
background-color: rgb(46 43 222);
}
|
夜间模式支持
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
body.dark-theme,
body.dark-theme p,
.dark-theme #main,
.dark-theme div.container,
.dark-theme table,
.dark-theme tr,
.dark-theme .post-toc,
.dark-theme .chroma,
.dark-theme pre,
.dark-theme code {
background-color: #181c27 !important;
color: rgba(255, 255, 255, 0.65) !important;
}
body.dark-theme a {
color: #c1bcbc;
}
body.dark-theme .highlight .chroma tbody{
border-bottom: 1px solid;
}
/* 文字高亮 */
.hightlight_text {
background-color: rgb(255, 255, 0);
}
body.dark-theme p span.hightlight_text {
background-color: rgb(46 43 222);
}
/* theme */
#BR_cornner {
bottom: 0px;
right: 0px;
position: fixed;
width: 17vw;
height: 45vh;
}
/* 播放器 */
.dark-theme .aplayer.aplayer-withlist .aplayer-list {
color:black;
}
.dark-theme #globalbg {
opacity: 0.35;
}
body #darkThemeBtn {
border: 1px solid transparent;
border-radius: 12px;
display: inline-block;
width: 24px;
text-align: center;
color: white;
background-color: #181c27;
position: fixed;
bottom: 60px;
right: 15px;
cursor: pointer;
opacity: 0.58;
transition: all 0.6s ease-out;
}
#darkThemeBtn.hide {
right: -26px;
}
.dark-theme #darkThemeBtn {
color: black;
background-color: white;
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
const $body = $('body');
// $body.append($(`<div id='darkThemeBtn'>T</div>`))
$body.delegate('#darkThemeBtn', 'click', function () {
let isDark = $body.hasClass('dark-theme');
console.log('dark', isDark);
localStorage.setItem('dark-theme', !isDark);
// darkThemeToggle_();
$body.toggleClass('dark-theme');
});
let x = localStorage.getItem('dark-theme')
if (x == 'true' || x == true) {
$body.addClass('dark-theme');
}
|