Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] add notebook support #464

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,29 @@ site_tree:
menu_id: wiki # 未在 front-matter 中指定 menu_id 时,layout 为 wiki 的页面默认使用这里配置的 menu_id
leftbar: tree, related, recent # for wiki
rightbar: ghrepo, toc
# 笔记本列表页配置
notebooks:
base_dir: notebooks # 笔记本列表页的路径。以及未指定 base_dir 的笔记本的路径前缀。
menu_id: notebooks # 笔记本列表页高亮的主导航栏菜单按钮。
# 笔记本列表页的左侧栏和右侧栏。
leftbar: recent # recent within all notebooks
rightbar: null
# 笔记列表页配置
notes:
# 笔记列表页和笔记页高亮的主导航栏菜单按钮。
# 可以在笔记本 yaml 的 menu_id 字段中覆盖此参数。
# 可以在笔记的 front-matter/menu_id 中覆盖此参数。
menu_id: notebooks
# 笔记列表页的左侧栏和右侧栏。可以在笔记本 yaml 的 leftbar 和 rightbar 字段中覆盖此参数。
leftbar: tagtree, recent # recent of current notebook
rightbar: null
# 笔记页配置
note:
# 笔记页的左侧栏和右侧栏
# 可以在笔记本 yaml 的 note_leftbar 和 note_rightbar 字段中覆盖此参数。
# 可以在笔记的 front-matter/leftbar 和 rightbar 字段中覆盖此参数。
leftbar: tagtree, recent # recent of current notebook
rightbar: toc
# 作者信息配置
author:
base_dir: author # 只影响自动生成的页面路径
Expand All @@ -116,6 +139,30 @@ site_tree:
rightbar: toc


######## Notebook ########
notebook:
# 如果没有指定 excerpt 和 description,将自动取多长的内容作为文章摘要。
auto_excerpt: 128
# 可以为某个 tag 设定图标(显示在标签树中)。
tagcons:
'': solar:hashtag-linear
# 每页显示多少篇笔记。0 表示不分页,null 则 fallback 到 hexo 的配置。
# 可以在笔记本 yaml 的 per_page 字段中覆盖此参数。
per_page: null
# 笔记的排序方式。默认按照 updated 降序排序。
# 可以在笔记本 yaml 的 order_by 字段中覆盖此参数。
# 注意:置顶的笔记会始终排在最前面。
# 在 front-matter 中设置 pin:true|number 或 sticky:true|number 来置顶。
order_by: -updated
# 是否在笔记页面显示许可协议。false 表示不显示。true 表示沿用主题许可协议内容。也可以给定具体的文本指定协议内容。
# 可以在笔记本 yaml 的 license 字段中覆盖此参数。
# 可以在笔记的 front-matter/license 中覆盖此参数。
license: false
# 是否在笔记页面显示分享按钮。
# 可以在笔记本 yaml 的 share 字段中覆盖此参数。
# 可以在笔记的 front-matter/share 中覆盖此参数。
share: false


######## Article ########
article:
Expand Down
3 changes: 2 additions & 1 deletion _data/icons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ solar:documents-bold-duotone: <svg xmlns="http://www.w3.org/2000/svg" width="32"
solar:chat-square-like-bold-duotone: <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="m13.629 20.472l-.542.916c-.483.816-1.69.816-2.174 0l-.542-.916c-.42-.71-.63-1.066-.968-1.262c-.338-.197-.763-.204-1.613-.219c-1.256-.021-2.043-.098-2.703-.372a5 5 0 0 1-2.706-2.706C2 14.995 2 13.83 2 11.5v-1c0-3.273 0-4.91.737-6.112a5 5 0 0 1 1.65-1.651C5.59 2 7.228 2 10.5 2h3c3.273 0 4.91 0 6.113.737a5 5 0 0 1 1.65 1.65C22 5.59 22 7.228 22 10.5v1c0 2.33 0 3.495-.38 4.413a5 5 0 0 1-2.707 2.706c-.66.274-1.447.35-2.703.372c-.85.015-1.275.022-1.613.219c-.338.196-.548.551-.968 1.262" opacity=".5"/><path fill="currentColor" d="M10.99 14.308c-1.327-.978-3.49-2.84-3.49-4.593c0-2.677 2.475-3.677 4.5-1.609c2.025-2.068 4.5-1.068 4.5 1.609c0 1.752-2.163 3.615-3.49 4.593c-.454.335-.681.502-1.01.502c-.329 0-.556-.167-1.01-.502"/></svg>
solar:planet-bold-duotone: <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M20 12a8 8 0 1 1-16 0a8 8 0 0 1 16 0" opacity=".5"/><path fill="currentColor" d="M17.712 5.453c1.047-.193 2.006-.259 2.797-.152c.77.103 1.536.393 1.956 1.064c.446.714.312 1.542-.012 2.258c-.33.728-.918 1.499-1.672 2.268c-1.516 1.547-3.836 3.226-6.597 4.697c-2.763 1.472-5.495 2.484-7.694 2.92c-1.095.217-2.098.299-2.923.201c-.8-.095-1.6-.383-2.032-1.075c-.47-.752-.296-1.63.07-2.379c.375-.768 1.032-1.586 1.872-2.403L4 12.416c0 .219.083.71.168 1.146c.045.23.09.444.123.596c-.652.666-1.098 1.263-1.339 1.756c-.277.567-.208.825-.145.925c.072.116.305.305.937.38c.609.073 1.44.018 2.455-.183c2.02-.4 4.613-1.351 7.28-2.772c2.667-1.42 4.85-3.015 6.23-4.423c.694-.707 1.15-1.334 1.377-1.836c.233-.515.167-.75.107-.844c-.07-.112-.289-.294-.883-.374c-.542-.072-1.272-.041-2.163.112L16.87 5.656c.338-.101.658-.17.842-.203"/></svg>
solar:notebook-bookmark-bold-duotone: <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" fill-rule="evenodd" d="M14.25 4.48v3.057c0 .111 0 .27.02.406a.936.936 0 0 0 .445.683a.96.96 0 0 0 .783.072c.13-.04.272-.108.378-.159L17 8.005l1.124.534c.106.05.248.119.378.16a.958.958 0 0 0 .783-.073a.936.936 0 0 0 .444-.683c.021-.136.021-.295.021-.406V3.031c.113-.005.224-.01.332-.013C21.154 2.98 22 3.86 22 4.933v11.21c0 1.112-.906 2.01-2.015 2.08c-.97.06-2.108.179-2.985.41c-1.082.286-1.99 1.068-3.373 1.436c-.626.167-1.324.257-1.627.323V5.174c.32-.079 1.382-.203 1.674-.371c.184-.107.377-.216.576-.323m5.478 8.338a.75.75 0 0 1-.546.91l-4 1a.75.75 0 0 1-.364-1.456l4-1a.75.75 0 0 1 .91.546" clip-rule="evenodd"/><path fill="currentColor" d="M18.25 3.151c-.62.073-1.23.18-1.75.336a8.2 8.2 0 0 0-.75.27v3.182l.75-.356l.008-.005a1.13 1.13 0 0 1 .492-.13c.047 0 .094.004.138.01c.175.029.315.1.354.12l.009.005l.749.356V3.647z"/><path fill="currentColor" d="M12 5.214c-.334-.064-1.057-.161-1.718-.339C8.938 4.515 8.05 3.765 7 3.487c-.887-.234-2.041-.352-3.018-.412C2.886 3.007 2 3.9 2 4.998v11.146c0 1.11.906 2.01 2.015 2.079c.97.06 2.108.179 2.985.41c.486.129 1.216.431 1.873.726c1.005.451 2.052.797 3.127 1.034z" opacity=".5"/><path fill="currentColor" d="M4.273 12.818a.75.75 0 0 1 .91-.545l4 1a.75.75 0 1 1-.365 1.455l-4-1a.75.75 0 0 1-.545-.91m.909-4.545a.75.75 0 1 0-.364 1.455l4 1a.75.75 0 0 0 .364-1.455z"/></svg>

solar:pin-linear: <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path d="m15.9894 4.9502.5306-.53006zm3.0822 3.08542-.5306.53006zm-10.33323 11.39338-.5306.5301zm-4.11668-4.1209.5306-.53zm12.94521-.3138-.2637-.7021zm-1.9171.7203.2638.7021zm-7.3176-7.33283-.70422-.25802zm.69445-1.89541.70422.25802zm-3.18161 4.18714.19934.723zm1.45663-.5384-.43821-.60864zm.37415-.34472.57083.48642zm6.57518 6.59012.491.567zm-.8704 1.8207-.7232-.199zm.5363-1.4546-.6094-.4372zm-11.19844-3.9914-.74998.0048zm.21199-.8031-.64992-.3743zm8.37475 9.391.0012-.75zm.7881-.2084-.3718-.6514zm-.396-19.09864.1615.73239zm-10.2279 19.43384c-.29274.2931-.2925.768.00054 1.0607s.76792.2925 1.06066-.0005zm5.71443-3.5978c.29274-.293.2925-.7679-.00054-1.0607-.29305-.2927-.76792-.2925-1.06066.0006zm8.27497-12.39184 3.0822 3.08542 1.0612-1.06012-3.0822-3.08542zm-6.18983 13.41864-4.11668-4.1208-1.0612 1.0601 4.11668 4.1209zm8.03423-4.6067-1.9172.7203.5276 1.4042 1.9171-.7203zm-8.26678-5.65241.69445-1.89541-1.40844-.51604-.69445 1.89541zm-2.99204 2.75671c.71145-.1962 1.25281-.334 1.69549-.6527l-.87641-1.21734c-.17293.12451-.39745.19782-1.21776.42398zm1.5836-3.27275c-.29296.79957-.3846 1.01778-.52299 1.18016l1.14166.97289c.35376-.41505.53565-.94343.78977-1.63701zm.11189 2.62005c.18709-.1347.35725-.2915.50678-.467l-1.14166-.97289c-.07129.08366-.15239.15838-.24153.22255zm7.64613 4.2687c-.689.2589-1.2144.4446-1.626.801l.982 1.134c.1608-.1393.3772-.2323 1.1716-.5308zm-1.2823 3.3876c.2253-.8188.2984-1.0432.4226-1.2163l-1.2188-.8744c-.3173.4423-.4546.9825-.6501 1.6928zm-.3437-2.5866c-.1697.147-.3216.3134-.4525.4959l1.2188.8744c.0624-.087.1348-.1663.2157-.2363zm-8.60771-1.0354c-.64614-.6468-1.0843-1.0871-1.36863-1.4443-.28531-.3585-.31477-.5137-.31521-.5833l-1.49997.0095c.00367.5822.29279 1.0697.64154 1.5079.34974.4394.86113.9497 1.48107 1.5703zm.49341-4.82766c-.84522.23306-1.54174.42386-2.06274.63306-.51955.2085-1.0118.4897-1.30243.9943l1.29985.7486c.03462-.0601.13655-.1804.56142-.3509.42343-.17 1.02157-.3361 1.90258-.579zm-2.17725 2.80006c-.00094-.1489.03771-.2952.11193-.4241l-1.29985-.7486c-.20699.3594-.31467.7674-.31205 1.1822zm4.73932 7.2086c.62387.6245 1.13687 1.1396 1.5787 1.4915.44053.3509.93143.6416 1.51763.6425l.0023-1.5c-.0695-.0001-.225-.0287-.5854-.3158-.3592-.2861-.80177-.7274-1.45203-1.3784zm4.44963-1.9569c-.2441.8875-.4112 1.4902-.5823 1.9166-.1718.4279-.293.5299-.3536.5645l.7435 1.3028c.509-.2905.7923-.7857 1.0021-1.3086.2105-.5243.4023-1.2259.6366-2.0774zm-1.3533 4.0909c.4071.0006.8073-.1052 1.1609-.307l-.7435-1.3028c-.1265.0722-.2696.11-.4151.1098zm7.2369-13.52742c1.0635 1.06454 1.7993 1.80382 2.2507 2.41312.4436.5986.4946.9171.4404 1.1676l1.4661.317c.1899-.878-.16-1.6472-.7013-2.3777-.5334-.71978-1.3664-1.55084-2.3947-2.58014zm-.7103 7.13072c1.3614-.5115 2.4633-.9234 3.2464-1.358.7947-.4411 1.4312-.9968 1.6211-1.875l-1.4661-.317c-.0541.2504-.232.5191-.883.8804-.6626.3678-1.6379.7364-3.0459 1.2654zm-1.3107-11.27626c-1.0359-1.03694-1.8719-1.87661-2.5954-2.41376-.7338-.54473-1.5071-.89726-2.3889-.70271l.3231 1.46478c.2498-.0551.5689-.00515 1.1716.4423.6129.45504 1.3572 1.19726 2.4284 2.26951zm-6.78913 2.32424c.52163-1.42363.88523-2.41035 1.25033-3.08123.359-.65977.6278-.83958.8776-.8947l-.3231-1.46478c-.8817.19452-1.4352.83965-1.87208 1.64251-.43084.79175-.83674 1.90536-1.34119 3.28216zm-7.20027 15.78572 4.65323-4.658-1.0612-1.0601-4.65323 4.6579z" fill="currentColor"/></svg>
solar:hashtag-linear: <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><g stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"><path d="m10 3-5 18"/><path d="m19 3-5 18"/><path d="m22 9h-18"/><path d="m20 16h-18"/></g></svg>

default:goback: <svg aria-hidden="true" viewBox="0 0 16 16" fill="currentColor"><path fill-rule="evenodd" d="M7.78 12.53a.75.75 0 01-1.06 0L2.47 8.28a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 1.06L4.81 7h7.44a.75.75 0 010 1.5H4.81l2.97 2.97a.75.75 0 010 1.06z"></path></svg>

Expand Down
6 changes: 6 additions & 0 deletions _data/widgets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ timeline:
user: # 默认显示所有人的数据,设置名称可过滤为仅显示某人的数据,多个名称用英文逗号隔开,不要加空格
type: # 默认不用写,如果是友链朋友圈数据请写 fcircle
limit: # 默认通过 api 上增加 per_page 来设置,如果是友链朋友圈,可通过这个设置数量

tagtree:
layout: tagtree
expand_all: false # 是否展开所有节点
expand_active: true # 是否展开当前节点
show_tagcon: true # 是否显示标签 icon
3 changes: 3 additions & 0 deletions languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ btn:
blog: Blog
wiki: Wiki
topic: Topic
notebook: Notebook
recent_publish: Recent
all_wiki: All Products
category: Category
Expand All @@ -18,6 +19,8 @@ btn:

meta:
recent_update: Recent Update
tag_tree: Tags
all_notes: All Notes
toc: On This Page
read_next: READ NEXT
prev: Prev
Expand Down
3 changes: 3 additions & 0 deletions languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ btn:
blog: 文章
wiki: 文档
topic: 专栏
notebook: 笔记本
recent_publish: 近期发布
all_wiki: 所有项目
category: 分类
Expand All @@ -18,6 +19,8 @@ btn:

meta:
recent_update: 最近更新
tag_tree: 标签
all_notes: 所有笔记
toc: 本文目录
read_next: 接下来阅读
prev: 回顾上一篇
Expand Down
3 changes: 3 additions & 0 deletions languages/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ btn:
blog: 網誌
wiki: 文檔
topic: 專欄
notebook: 筆記本
recent_publish: 近期發布
all_wiki: 所有文檔
category: 分類
Expand All @@ -18,6 +19,8 @@ btn:

meta:
recent_update: 最近更新
tag_tree: 標籤
all_notes: 所有筆記
toc: 本文目錄
read_next: 接下來閱讀
prev: 回顧上一篇
Expand Down
6 changes: 5 additions & 1 deletion layout/_partial/main/article/article_footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ function layoutDiv() {
if (theme.article.license && (page.license != false)) {
license = page.license || theme.article.license
}
} else if (page.license) {
license = page.license === true ? theme.article.license : page.license
}
if (license.length > 0) {
if (license?.length > 0) {
var author = null
if (theme.authors) {
if (page.author?.length > 0 && theme.authors[page.author] != null) {
Expand Down Expand Up @@ -84,6 +86,8 @@ function layoutDiv() {
}
} else if (page.layout == 'post') {
showSharePlugin = page.share != false
} else if (page.share) {
showSharePlugin = true
}
if (theme.article.share && showSharePlugin) {
function socialButtons() {
Expand Down
2 changes: 2 additions & 0 deletions layout/_partial/main/navbar/article_banner.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function layoutBreadcrumb() {
el += `<a class="cap breadcrumb" href="${url_for(config.root)}">${__("btn.home")}</a>`
if (theme.wiki.tree[page.wiki]) {
el += partial('breadcrumb/wiki')
} else if (page.notebook) {
el += partial('breadcrumb/note')
} else if (page.layout == 'post') {
el += partial('breadcrumb/blog')
} else {
Expand Down
8 changes: 8 additions & 0 deletions layout/_partial/main/navbar/breadcrumb/note.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%# 笔记页面的面包屑 %>
<span class="sep"></span>
<a class="cap breadcrumb" href="<%= url_for(theme.site_tree.notebooks.base_dir) %>"><%= __('btn.notebook') %></a>
<% const notebook = theme.notebooks.tree[page.notebook] %>
<% if (notebook) { %>
<span class="sep"></span>
<a class="cap breadcrumb" href="<%= url_for(notebook.base_dir) %>"><%= notebook.name || notebook.title %></a>
<% } %>
11 changes: 11 additions & 0 deletions layout/_partial/main/navbar/dateinfo.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ function layoutDiv() {
el += `<span class="text created">${__("meta.updated") + __("symbol.colon")}`
el += `<time datetime="${date_xml(page.updated)}">${date(page.updated, config.date_format)}</time>`
el += `</span>`
} else if (page.notebook) {
// 更新日期
el += `<span class="text created">${__("meta.updated") + __("symbol.colon")}`
el += `<time datetime="${date_xml(page.updated)}">${date(page.updated, config.date_format)}</time>`
el += `</span>`
// 发布日期
el += `<span class="sep updated"></span>`
el += `<span class="text updated">`
el += `${__("meta.created") + __("symbol.colon")}`
el += `<time datetime="${date_xml(page.date)}">${date(page.date, config.date_format)}</time>`
el += `</span>`
} else {
const author = theme.authors ? (theme.authors[page.author] || theme.default_author) : null
if (author) {
Expand Down
36 changes: 36 additions & 0 deletions layout/_partial/main/notebook/note_card.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<%# 笔记卡片 %>
<article class="md-text">
<% if (note.cover) { %>
<div class="post-cover">
<img src="<%= note.cover %>" alt="cover" />
</div>
<% } %>
<h2 class="post-title"><%= note.title %></h2>
<div class="excerpt<% if (theme.plugins.heti?.enable) { %> heti<% } %>">
<p>
<% if (note.excerpt) { %>
<%= strip_html(note.excerpt) %>
<% } else if (note.description) { %>
<%= note.description %>
<% } else if (note.content && theme.notebook.auto_excerpt > 0) { %>
<%= truncate(strip_html(note.content), { length: theme.notebook.auto_excerpt }) %>
<% } %>
</p>
</div>
<div class="meta cap">
<% if (note.pin) { %>
<span class="pin"><%- icon('solar:pin-linear') %></span>
<% } %>
<span class="cap" id="post-meta">
<%- icon('default:calendar') %>
<time datetime="<%= date_xml(note.updated || note.date) %>"><%= date(note.updated || note.date, config.date_format) %></time>
</span>
<% if (note.tags) { %>
<% note.tags.forEach((tag, i) => { %>
<span class="cap breadcrumb" %>>
<span class="tag"><%= tag %></span>
</span>
<% }) %>
<% } %>
</div>
</article>
9 changes: 9 additions & 0 deletions layout/_partial/main/notebook/note_tags.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%# 笔记的所属标签 %>
<% if (page.tags) { %>
<div class="tag-list">
<% for (const t of page.tags) { %>
<% const tag = notebook.tagTree.get(t.toLowerCase()) %>
<a class="tag" href="<%= url_for(tag.path) %>"><%= tag.name %></a>
<% } %>
</div>
<% } %>
10 changes: 10 additions & 0 deletions layout/_partial/main/notebook/notebook_card.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%# 笔记本信息卡片 %>
<article class="md-text">
<div class="preview"><img src="<%= notebook.icon || theme.default.project %>" alt="icon"/></div>
<div class="excerpt">
<h2 class="post-title"><%= notebook.title || notebook.name %></h2>
<% if (notebook.description) { %>
<p><%= notebook.description %></p>
<% } %>
</div>
</article>
9 changes: 9 additions & 0 deletions layout/_partial/main/notebook/paginator.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<% if ((page.total || 0) > 1) { %>
<div class="paginator-wrap dis-select<%= scrollreveal(' ') %>">
<%- paginator({
prev_text: '',
next_text: '',
force_prev_next: true,
}) %>
</div>
<% } %>
1 change: 1 addition & 0 deletions layout/_partial/scripts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ function custom_inject() {
<%- partial('scripts/defines') %>
<%- partial('scripts/utils') %>
<%- partial('scripts/sidebar') %>
<%- partial('scripts/tagtree') %>

<!-- required -->
<script src="<%- `${theme.stellar.main_js}?v=${stellar_info('version')}` %>" async></script>
Expand Down
29 changes: 29 additions & 0 deletions layout/_partial/scripts/tagtree.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script type="text/javascript">
(() => {
const tagSwitchers = document.querySelectorAll('.tag-subtree.parent-tag > a > .tag-switcher-wrapper')
for (const tagSwitcher of tagSwitchers) {
tagSwitcher.addEventListener('click', (e) => {
const parent = e.target.closest('.tag-subtree.parent-tag')
parent.classList.toggle('expanded')
e.preventDefault()
})
}

// Get active tag from query string, then activate it.
const urlParams = new URLSearchParams(window.location.search)
const activeTag = urlParams.get('tag')
if (activeTag) {
let tag = document.querySelector(`.tag-subtree[data-tag="${activeTag}"]`)
if (tag) {
tag.querySelector('a').classList.add('active')
<% if (!theme.widgets.tagtree.expand_active) { %>
tag = tag.parentElement.closest('.tag-subtree.parent-tag')
<% } %>
while (tag) {
tag.classList.add('expanded')
tag = tag.parentElement.closest('.tag-subtree.parent-tag')
}
}
}
})()
</script>
10 changes: 10 additions & 0 deletions layout/_partial/sidebar/index_leftbar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

const wiki = theme.wiki.tree[page.wiki]
const topic = theme.topic.tree[page.topic]
const notebook = theme.notebooks.tree[page.notebook]

if (page.leftbar == null) {
const { site_tree } = theme
var sidebar
if (is_home()) {
sidebar = site_tree.home.leftbar
} else if (page.layout === 'notebooks') {
// 笔记本列表页
sidebar = site_tree.notebooks.leftbar
} else if (page.layout === 'notes') {
// 笔记列表页
sidebar = notebook ? notebook.leftbar : site_tree.notes.leftbar
} else if (notebook) {
// 笔记本文章内页
sidebar = page.leftbar ?? notebook.note_leftbar
} else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) {
sidebar = site_tree.index_blog.leftbar
} else if (page.layout === 'index_topic') {
Expand Down
10 changes: 10 additions & 0 deletions layout/_partial/sidebar/index_rightbar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

const wiki = theme.wiki.tree[page.wiki]
const topic = theme.topic.tree[page.topic]
const notebook = theme.notebooks.tree[page.notebook]

if (page.rightbar == null) {
const { site_tree } = theme
var sidebar
if (is_home()) {
sidebar = site_tree.home.rightbar
} else if (page.layout === 'notebooks') {
// 笔记本列表页
sidebar = site_tree.notebooks.rightbar
} else if (page.layout === 'notes') {
// 笔记列表页
sidebar = notebook ? notebook.rightbar : site_tree.notes.rightbar
} else if (notebook) {
// 笔记本文章内页
sidebar = page.rightbar ?? notebook.note_rightbar
} else if (is_category() || is_tag() || is_archive() || ['categories', 'tags', 'archives'].includes(page.layout)) {
sidebar = site_tree.index_blog.rightbar
} else if (page.layout === 'index_topic') {
Expand Down
4 changes: 4 additions & 0 deletions layout/_partial/sidebar/search.ejs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<%
const notebook = theme.notebooks.tree[page.notebook]
if (item.filter == null) {
item.filter = 'auto'
}
if (item.placeholder == null && item.filter == 'auto') {
if (theme.wiki.tree[page.wiki]?.name) {
item.placeholder = __('search.search_in', theme.wiki.tree[page.wiki]?.name)
} else if (notebook) {
item.placeholder = __('search.search_in', notebook.name || __('btn.notebook'))
item.filter = notebook.base_dir
}
}
function layoutDiv() {
Expand Down
Loading