From 091dd14eb6c4423469a4c5584ceb132855dfee48 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Sun, 17 Dec 2023 19:39:23 +0800 Subject: [PATCH] [opt] wiki --- languages/zh-CN.yml | 2 +- languages/zh-TW.yml | 2 +- layout/_partial/main/post_list/wiki_card.ejs | 7 ++-- layout/_partial/widgets/related.ejs | 33 +++++++------------ layout/index.ejs | 13 ++++---- scripts/events/lib/doc_tree.js | 34 ++++++++++++++------ source/css/_layout/list.styl | 2 ++ source/js/main.js | 1 - 8 files changed, 51 insertions(+), 43 deletions(-) diff --git a/languages/zh-CN.yml b/languages/zh-CN.yml index 49af285..568ac08 100755 --- a/languages/zh-CN.yml +++ b/languages/zh-CN.yml @@ -23,7 +23,7 @@ meta: related_posts: 您可能感兴趣的文章 comment_title: 快来参与讨论吧 back_to_top: 回到顶部 - more: '更多%s' + more: '更多「%s」' created: 发布于 updated: 更新于 license: 许可协议 diff --git a/languages/zh-TW.yml b/languages/zh-TW.yml index f49a3dc..f2e49ae 100755 --- a/languages/zh-TW.yml +++ b/languages/zh-TW.yml @@ -23,7 +23,7 @@ meta: related_posts: 您可能感興趣的文章 comment_title: 參與討論 back_to_top: 回到頁首 - more: '更多%s' + more: '更多「%s」' created: 發布於 updated: 更新於 license: 授權條款 diff --git a/layout/_partial/main/post_list/wiki_card.ejs b/layout/_partial/main/post_list/wiki_card.ejs index de80573..b75b7dc 100644 --- a/layout/_partial/main/post_list/wiki_card.ejs +++ b/layout/_partial/main/post_list/wiki_card.ejs @@ -13,8 +13,11 @@ function layoutDiv() { } el += '
'; if (proj.tags && proj.tags.length > 0) { - let tag = proj.tags[0]; - el += ''; + el += '
'; + for (let tag of proj.tags) { + el += '' + tag + ''; + } + el += '
'; } el += '

' + (proj.title || proj.name) + '

'; if (proj.description) { diff --git a/layout/_partial/widgets/related.ejs b/layout/_partial/widgets/related.ejs index ae247fe..deafec0 100644 --- a/layout/_partial/widgets/related.ejs +++ b/layout/_partial/widgets/related.ejs @@ -3,34 +3,25 @@ function layoutDiv() { if (page.layout !== "wiki") { return ''; } - var related = []; - const { shelf, tree } = theme.wiki; - let proj = tree[page.wiki]; - if (proj?.related?.length > 0) { - proj.related.filter(pid => shelf.includes(pid)).forEach((pid, i) => { - let p = tree[pid]; - if (p && p.title !== proj?.title && p.homepage) { - related.push(p); - } - }); + let thisItemObject = theme.wiki.tree[page.wiki]; + if (thisItemObject == null) { + return ''; } + const relatedItems = thisItemObject.relatedItems; var el = ''; - if (related.length > 0) { + for (let relatedItem of relatedItems) { el += ''; el += '
'; - var title = __('btn.wiki'); - if (proj.tags && proj.tags[0]) { - title = proj.tags[0]; - } - el += '' + __('meta.more', title) + ''; + el += '' + __('meta.more', relatedItem.name) + ''; el += '
'; el += '