-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #623 from juestchaos/main
更新
- Loading branch information
Showing
17 changed files
with
1,430 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,313 @@ | ||
--- | ||
uid: 20240115155129 | ||
title: Obsidian 主页制作小教程 | ||
tags: [Obsidian, Obsidian插件] | ||
description: Obsidian 主页制作小教程 | ||
author: 余月鱼鸽 | ||
type: other | ||
draft: false | ||
editable: false | ||
modified: 20240115155704 | ||
--- | ||
|
||
# Obsidian 主页制作小教程 | ||
|
||
## Obsidian 主页简介 | ||
|
||
@熊猫别熬夜 发现了: | ||
|
||
- [Obsidian 样式 - 调整图片不同布局样式]( https://pkmer.cn/show/20231202002300 ) | ||
- [Obsidian 样式:minimal 主题 Cards 卡片布局]( https://pkmer.cn/show/20230905221421 ) | ||
|
||
这两个 css 的搭配的妙用: | ||
|
||
 | ||
|
||
经过一小段时间的折腾后,我搭配出了一个 moc 主页,具体效果可见下方: | ||
|
||
1. 浅色模式: | ||
 | ||
2. 深色模式: | ||
 | ||
|
||
## 制作教程 | ||
|
||
 | ||
|
||
Obsidian 主页的制作方法,大致为以下 4 个步骤: | ||
|
||
1. 配置头图 | ||
2. 制作标题栏 | ||
3. 制作 moc 卡片 | ||
4. 微调界面细节 | ||
|
||
### 1.配置头图 | ||
|
||
这个步骤使用的是 Obsidian Banners 插件,该插件可以将库内图片,甚至是外部图片链接变为笔记中的头图。 | ||
|
||
具体使用方法:在 YAML 区添加 banner 相关的参数即可: | ||
|
||
 | ||
|
||
这样切换到阅读模式,我们就能收获到一个有头图的文件: | ||
|
||
 | ||
|
||
Tip : | ||
|
||
- 除使用库内图片,也可以使用 bing 的每日一图,将 <https://api.dujin.org/bing/1366.php> 作为图片路径,每天重登 obsidian 即可收获不一样的头图 | ||
- 更新 1.4.x 之后,很多人因为使用了 banner 插件,还有 properties 新核心插件而出现了高度问题,会出现莫名的留白,这个文档提供了解决方案:[Obsidian 样式:修复 banner 和 Properties 高度冲突以及多余留白改善]( https://pkmer.cn/show/20230918104801 ) | ||
- 更多的 banner 插件使用小技巧可以见: [Obsidian 插件:Obsidian Banners 为你的笔记添加头图]( https://pkmer.cn/show/20230329141826 ) | ||
|
||
### 2. 制作标题栏 | ||
|
||
 | ||
|
||
标题栏的部分主要用到两个插件: | ||
|
||
1. button 插件,主要用来添加快捷打开的 project 的按钮,网站上的文章:[Obsidian 插件:Buttons 美化必备的按钮插件]( https://pkmer.cn/show/20230514144947 ) 解释得挺详细的,此处就不展开了 | ||
2. 本主页主要用 dataview 插件,统计本文本库的文件、标签数量。安装 dataview 插件后,直接将这段 dataviewjs 代码区域中复制到文件中即可。 | ||
|
||
 | ||
|
||
dataviewjs 代码: | ||
|
||
```` | ||
```dataviewjs | ||
let ftMd = dv.pages("").file.sort(t => t.cday)[0] | ||
let total = parseInt([new Date() - ftMd.ctime] / (60*60*24*1000)) | ||
let totalDays = " 您已使用 *Obsidian* "+total+" 天," | ||
let nofold = '!"misc/templates"' | ||
let allFile = dv.pages(nofold).file | ||
let totalMd = "共创建 "+ | ||
allFile.length+" 篇笔记" | ||
let totalTag = allFile.etags.distinct().length+" 个标签" | ||
dv.paragraph( | ||
totalDays+totalMd+"、"+totalTag+"" | ||
) | ||
``` | ||
```` | ||
|
||
Tip :本段代码摘抄自 bt 示例库。 | ||
|
||
稍微加上一些文字、以及分割符做装饰,我们的主页已经进化到以下效果: | ||
|
||
 | ||
|
||
### 3. 制作 moc 卡片 | ||
|
||
#### 3.1 将 css 片段导入文库内 | ||
|
||
Tip :第一次接触 css 的新手可以看一下这个文章:[Obsidian 的 CSS 代码片段]( https://pkmer.cn/show/20230329145845 ) | ||
|
||
本步骤主要使用 3 种 css 片段,分别为: | ||
|
||
1. [Obsidian 样式:minimal 主题 Cards 卡片布局]( https://pkmer.cn/show/20230905221421 ) | ||
2. [Obsidian 样式 - 调整图片不同布局样式]( https://pkmer.cn/show/20231202002300 ) | ||
3. 界面全宽显示,来源是 @熊猫别熬夜 ,在网站上没搜到对应的文章,具体 css 代码可以直接在下方复制: | ||
|
||
```css | ||
/* 输定字体大小 */ | ||
|
||
/* .view-content .small-font , */ | ||
.small-font.markdown-preview-view .markdown-embed .markdown-preview-view, | ||
.small-font.markdown-preview-view { | ||
font-size: 18px !important; | ||
line-height: 180%; | ||
} | ||
|
||
/* 关闭显示标签页标题栏。 */ | ||
.small-font.markdown-preview-view .mod-header .inline-title { | ||
display: none; | ||
line-height: 0px; | ||
/* text-align: right; */ | ||
} | ||
.view-content .small-font .inline-title { | ||
display: none; | ||
} | ||
|
||
/* 关闭显示标题栏:colse_show_title */ | ||
.colse_show_title.markdown-preview-view .mod-header .inline-title { | ||
display: none; | ||
line-height: 0px; | ||
/* text-align: right; */ | ||
} | ||
|
||
.colse_show_title.markdown-preview-view { | ||
--file-line-width: 100% !important; | ||
} | ||
.view-content .colse_show_title .inline-title { | ||
display: none; | ||
} | ||
|
||
|
||
/* 设定字体大小 */ | ||
.colse_show_title.markdown-preview-view { | ||
font-size: 21px !important; | ||
line-height: 150%; | ||
} | ||
|
||
/* 设定Excalidraw的CSS:Excalidraw-Markdown */ | ||
.Excalidraw-Markdown.markdown-preview-view .mod-header .inline-title { | ||
display: none; | ||
line-height: 0px; | ||
/* text-align: right; */ | ||
} | ||
.view-content .Excalidraw-Markdown .inline-title { | ||
display: none; | ||
} | ||
|
||
/* 设定字体大小 */ | ||
/* .Excalidraw-Markdown.markdown-preview-view{ | ||
font-size: 18px !important; | ||
line-height: 150%; | ||
} */ | ||
|
||
/* ==word-font 论文排版格式,缩行缩进、中英文字体== */ | ||
|
||
.word-font.markdown-preview-view { | ||
font-family: "Times New Roman", 宋体 !important; | ||
} | ||
|
||
.word-font div p { | ||
text-indent: 2em; | ||
} | ||
|
||
.word-font strong { | ||
font-family: "Times New Roman", "黑体"; | ||
font-weight: bold; | ||
} | ||
.word-font p { | ||
/* border: solid 1px #ff0000; */ | ||
font-family: "Times New Roman", "宋体"; | ||
text-decoration-line: none; | ||
margin: 10px 0px; | ||
line-height: 120%; | ||
text-indent: 2em; | ||
font-size: 20px; | ||
} | ||
.word-font h1 { | ||
font-family: "Times New Roman", "宋体"; | ||
font-size: 42px !important; | ||
font-weight: bold; | ||
text-align: center; | ||
} | ||
|
||
.word-font h2 { | ||
font-family: "Times New Roman", "黑体"; | ||
font-weight: 700; | ||
font-size: 35px !important; | ||
font-weight: bold; | ||
text-align: left; | ||
} | ||
.word-font h3 { | ||
font-family: "Times New Roman", "黑体"; | ||
font-weight: 700; | ||
font-size: 25px !important; | ||
font-weight: lighter; | ||
text-align: left; | ||
} | ||
.word-font h4 { | ||
font-family: "Times New Roman", "宋体"; | ||
font-weight: 700; | ||
font-weight: lighter; | ||
font-size: 23px !important; | ||
text-align: left; | ||
} | ||
|
||
.word-font h5, | ||
h6 { | ||
font-family: "Times New Roman", "宋体" !important; | ||
font-weight: normal !important; | ||
font-size: 20px !important; | ||
text-align: left !important; | ||
} | ||
|
||
.word-font .footnote-link { | ||
color: #2e3338; | ||
line-height: 10px !important; | ||
} | ||
sup { | ||
vertical-align: 25%; | ||
font-size: 10px; | ||
} | ||
|
||
.word-font .image-embed { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.word-font ul, | ||
.word-font ol { | ||
/* border: solid 1px #ff0000; */ | ||
font-family: "Times New Roman", "宋体"; | ||
text-decoration-line: none; | ||
margin: 10px 0px; | ||
line-height: 120%; | ||
font-size: 20px; | ||
} | ||
|
||
/* 普通表格 */ | ||
|
||
.word-font blockquote p { | ||
font-family: "楷体", "Times New Roman"; | ||
} | ||
.word-font .theme-light blockquote p { | ||
color: #5f5f5f; | ||
} | ||
.word-font .theme-dark blockquote p { | ||
color: #a1a1a1; | ||
} | ||
|
||
|
||
``` | ||
|
||
#### 3.2 制作 moc 卡片 | ||
|
||
3.2.1 在文件属性区域的【 cssclasses 】添加 list-cards 以及 colse_show_title 两个参数: | ||
|
||
- list-cards :这个参考可以让文件中的无序列表变为卡片视图 | ||
- colse_show_title:让界面进入全宽模式 | ||
 | ||
|
||
3.2.2 开始配置 | ||
|
||
在文件中添加一组无序列表,具体格式为: | ||
|
||
 | ||
|
||
其中,图片部分的格式为 `"!"` + `"[["` + `"图片名"` + `"#L"` + `"|"` + `"图片大小"` + `"]]"` , 意思是将图片变为 200 x 135 大小后,放在这个无序列表的左边。同理,若想将图片放在右边,将上述格式的 `"#L"` 变更为 `"#R"` 即可。 | ||
|
||
Tip :建议使用背景透明的 png 图,在这类图片能比较好地兼容浅色模式与深色模式; | ||
|
||
成功实现一组无序列表后,按同样的方式复现几组,即可得到一个接近于完工的界面啦~ | ||
|
||
 | ||
|
||
Tip :一般推荐一行放 4 个以内的无序列表,文本太长,或者显示器的分比率不高的情况下,很可能出现侧边栏出现时,会有字体换行的情况: | ||
|
||
 | ||
|
||
### 4. 微调界面细节 | ||
|
||
#### 4.1 添加装饰图片 | ||
|
||
目前主页的效果已经比较接近于示例图了,相比之下,少了以下几个小图标: | ||
|
||
 | ||
|
||
图片部分的格式依旧为: `"!"` + `"[["` + `"图片名"` + `"#L"` + `"|"` + `"图片大小"` + `"]]"` ,其中两个比较小的图案设置为: 30 ,比较大的图案设置为 200x135。 | ||
|
||
 | ||
|
||
至此,主页制作的效果层面的内容基本已经完成。 | ||
|
||
#### 4.2 设置启动 Obsidian 时,自动打开主页 | ||
|
||
此步骤属于锦上添花系列,大家可以根据自己的实际需求设置。 Obsidian 的 Homepage 插件,可以让我们在启动软件时,就默认打开我们设计好的软件(不用在文件夹中捞半天) | ||
|
||
以下是我的插件设置,大家可以参考一下: | ||
|
||
 |
Oops, something went wrong.