From 524fc2937e83b1c04298eef6a4d4c21ff18c27c3 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Mon, 5 Feb 2024 18:39:09 +0800 Subject: [PATCH] [opt] toc --- _data/widgets.yml | 2 +- layout/_partial/widgets/components/edit.ejs | 2 +- source/css/_layout/widgets/timeline.styl | 2 ++ source/css/_layout/widgets/widgets.styl | 3 +-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/_data/widgets.yml b/_data/widgets.yml index f78ca28..f6f1103 100644 --- a/_data/widgets.yml +++ b/_data/widgets.yml @@ -34,7 +34,7 @@ toc: collapse: false # true / false / auto # 编辑本文按钮 edit_this_page: # 从开头开始匹配替换 - '_posts/': https://github.com/xaoxuu/xaoxuu.com/blob/main/source/_posts/ + '_posts/': # https://github.com/xaoxuu/xaoxuu.com/blob/main/source/_posts/ 'wiki/stellar/': https://github.com/xaoxuu/hexo-theme-stellar-docs/blob/main/ # GitHub 用户信息 diff --git a/layout/_partial/widgets/components/edit.ejs b/layout/_partial/widgets/components/edit.ejs index 29dc76d..e045125 100644 --- a/layout/_partial/widgets/components/edit.ejs +++ b/layout/_partial/widgets/components/edit.ejs @@ -3,7 +3,7 @@ function parseURL() { const source = page.source || '' var url for (let id of Object.keys(map)) { - if (source.startsWith(id)) { + if (source.startsWith(id) && map[id]) { return source.replace(id, map[id]) } } diff --git a/source/css/_layout/widgets/timeline.styl b/source/css/_layout/widgets/timeline.styl index e3c944f..d14a669 100644 --- a/source/css/_layout/widgets/timeline.styl +++ b/source/css/_layout/widgets/timeline.styl @@ -1,10 +1,12 @@ .widget-wrapper.timeline .widget-body margin-top: 0.5rem + overflow hidden .body a trans1 all border-bottom: 1px solid var(--text) + word-break: break-all color: var(--text-p1) --fsp: $fsp2 &:hover diff --git a/source/css/_layout/widgets/widgets.styl b/source/css/_layout/widgets/widgets.styl index 9e862eb..b5533ca 100644 --- a/source/css/_layout/widgets/widgets.styl +++ b/source/css/_layout/widgets/widgets.styl @@ -67,14 +67,13 @@ .l_right .widgets .widget-wrapper margin-top: 8px + margin-bottom: 32px .widget-header padding-left: var(--gap-max) padding-right: var(--gap-max) &:not(.toc) margin-left: var(--gap-margin) margin-right: var(--gap-margin) - .widget-wrapper+.widget-wrapper - margin-top: 32px @media screen and (max-width: $device-laptop) .widget-wrapper margin-top: var(--gap-margin)