summaryrefslogtreecommitdiff
path: root/single.php
diff options
context:
space:
mode:
authorEltrac Koalar <hi@guhub.cn>2022-08-28 00:53:12 +0800
committerEltrac Koalar <hi@guhub.cn>2022-08-28 00:53:12 +0800
commit4c9b13dd4754aa3758439c6831f41448774df95e (patch)
tree8a1bd1c5124e01c6d4858db66de104448d744269 /single.php
parent6e5a75d1eac52a34335c6f1eac7ff9ed1fd97db7 (diff)
:newspaper: Add: 用 tocbot 实现文章目录
Diffstat (limited to 'single.php')
-rw-r--r--single.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/single.php b/single.php
index 32cb3ca..1e8af1b 100644
--- a/single.php
+++ b/single.php
@@ -4,7 +4,14 @@
<div class="col-12" id="main" role="main">
<article class="post post-atpage" itemscope itemtype="http://schema.org/BlogPosting">
<div class="post-header">
- <h1 class="post-title post-title-atpage<?php if($this->is('page')): ?> page-title-atpage<?php endif; ?>" itemprop="name headline"><?php $this->title() ?></h1>
+ <h1 class="post-title post-title-atpage<?php
+ if($this->is('post') && $this->fields->showTOC){ ?> post-title-withtoc<?php }
+ if($this->is('page')){ ?> page-title-atpage<?php }
+ ?>" itemprop="name headline"><span><?php
+ $this->title();?></span><?php
+ if($this->is('post') && $this->fields->showTOC){
+ ?><button title="开关文章目录" id="post-toc-toggle"><span class="iconfont">&#xe650;</span></button><?php }
+ ?></h1>
<?php if($this->is('post')): ?>
<ul class="post-meta post-meta-atpage">
<li><time datetime="<?php $this->date('c'); ?>" itemprop="datePublished"><?php echo Matcha::date($this->created); ?></time></li>
@@ -16,6 +23,7 @@
</ul>
<?php endif; ?>
</div>
+ <?php if($this->is('post') && $this->fields->showTOC){ ?><div id="toc"></div><?php } ?>
<div class="post-content" itemprop="articleBody">
<?php $this->content(); ?>
</div>