From 23c8e8fed64c5995101cc9ceb08706d8849b0a3c Mon Sep 17 00:00:00 2001 From: BigCoke233 Date: Thu, 30 Jul 2020 23:45:41 +0800 Subject: =?UTF-8?q?:zap:=20Add:=20=E5=90=84=E7=A7=8D=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=81=E6=96=B0=E5=A2=9E=E5=92=8C=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增:支持自定义「导航栏图标按钮」 - 新增:文章目录(使用 `{:toc:}` 在文中插入目录) - 新增:归档页面中添加「文章分类」栏目 - 优化:将设置项「Pjax 完成后执行事件」更改为更准确的「Pjax 回调函数」 - 修复:一个存在了超久的拼写错误(`paresNav`=>`parseNav`) - 修复:archive 页面(即分类、标签、搜索等)文章头图问题 --- libs/Contents.php | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'libs/Contents.php') diff --git a/libs/Contents.php b/libs/Contents.php index d821b72..b1b8db9 100644 --- a/libs/Contents.php +++ b/libs/Contents.php @@ -32,7 +32,7 @@ class Contents //Links $text = Contents::parseLink($text); //toc - $text = preg_replace('/{:toc:}/s',Contents::tableOfContents($text),$text); + $text = preg_replace('/{:toc:}/s', '
'.Contents::tableOfContents($text).'
', $text); } return $text; } @@ -277,7 +277,7 @@ class Contents /** * 解析自定义导航栏 */ - static public function paresNav($data, $type) { + static public function parseNav($data, $type) { $de_json = json_decode($data, true); $count_json = count($de_json); for ($i = 0; $i < $count_json; $i++) { @@ -296,6 +296,46 @@ class Contents } } + static public function parseNavIcon($data, $type) { + $de_json = json_decode($data, true); + $count_json = count($de_json); + for ($i = 0; $i < $count_json; $i++) { + $icon = $de_json[$i]['icon']; + $link = $de_json[$i]['link']; + $action = $de_json[$i]['action']; + //定义 class + if($type=="top-nav"){ + $class = 'nav-icon-button'; + } + elseif($type=="drawer"){ + $class = 'drawer-icon'; + } + elseif($type=="mobile"){ + $class = 'nav-mobile-icon'; + } + else{ + $class= 'unknown'; + } + if($de_json[$i]['class']) $class.= ' '.$de_json[$i]['class'];//自定义 class + //计算 right 距离 + $right_more=$i*45; + $right=20+$right_more; + //添加 $other + if($type=="top-nav") $other=' style="right: '.$right.'px"'; + //输出导航图标按钮 + if($type=="top-nav"||$type=="drawer"){ + if(!$action): echo ''; + else: echo ''; + endif; + } + elseif($type=="mobile"){ + if(!$action): echo ''; + else: echo ''; + endif; + } + } + } + /** * 根据 id 返回对应的对象 * 此方法在 Typecho 1.2 以上可以直接调用 Helper::widgetById(); -- cgit v1.2.3