修复文章目录
This commit is contained in:
parent
5ab2179898
commit
8ed2e647a1
14
footer.php
14
footer.php
|
@ -2,10 +2,22 @@
|
|||
<footer id="footer" class="footer">
|
||||
<?php echo allwords(); ?>
|
||||
<div class="copyright">
|
||||
<span>© <?php $this->options->title() ?> | Powered by <a href="https://typecho.org" target="_blank">Typecho</a> | Theme by <a href="https://github.com/Siricee" target="_blank">hexo-theme-Chic</a> | 移植 by <a href="https://imsun.org" target="_blank">Sun</a> </span>
|
||||
<span>© <?php $this->options->title() ?> | Powered by <a href="https://typecho.org" target="_blank">Typecho</a> & <a href="https://github.com/Siricee/hexo-theme-Chic" target="_blank">Chic</a>| Theme by <a href="https://imsun.org" target="_blank">Sun</a> </span>
|
||||
</div>
|
||||
<?php $this->options->tongji(); ?>
|
||||
</footer>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var defaultLanguage = 'javascript'; // 设置默认语言
|
||||
document.querySelectorAll('pre code').forEach(function (block) {
|
||||
if (!block.classList.length) {
|
||||
block.classList.add('language-' + defaultLanguage);
|
||||
}
|
||||
});
|
||||
Prism.highlightAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -84,7 +84,6 @@ function timer_start() {
|
|||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
/*
|
||||
* 全站字数
|
||||
*/
|
||||
|
@ -148,4 +147,14 @@ function allwords() {
|
|||
echo '全站共 '.$chars.' 字,写完一本我国著名的四大名著了!';}
|
||||
elseif ($chars>1000000){
|
||||
echo '全站共 '.$chars.' 字,已写一本列夫·托尔斯泰的《战争与和平》了!';}
|
||||
}
|
||||
}
|
||||
//文章目录功能-给文章内标题加上id
|
||||
function addHeaderLinks($text)
|
||||
{
|
||||
return preg_replace_callback('/<h([1-6])>(.*?)<\/h\1>/', function ($matches) {
|
||||
$level = $matches[1];
|
||||
$title = $matches[2];
|
||||
$id = htmlspecialchars(strip_tags($title), ENT_QUOTES, 'UTF-8');
|
||||
return sprintf('<h%s id="%s"><a href="#%s" class="headerlink" title="%s">%s</a></h%s>', $level, $id, $id, $title, $title, $level);
|
||||
}, $text);
|
||||
}
|
|
@ -22,6 +22,8 @@
|
|||
<script src="<?php $this->options->themeUrl('script.js'); ?>"></script>
|
||||
<?php $this->header("generator=&template=&pingback=&wlw=&xmlrpc=&rss1=&atom=&rss2=/feed"); ?>
|
||||
<?php $this->options->addhead(); ?>
|
||||
<script src="//cdnjs.sgcd.net/code-highlight/js/prism.js"></script>
|
||||
<link rel="stylesheet" href="//cdnjs.sgcd.net/code-highlight/css/prism.css" />
|
||||
<?php $this->header(); ?>
|
||||
</head>
|
||||
<body>
|
||||
|
|
11
post.php
11
post.php
|
@ -2,6 +2,9 @@
|
|||
<?php $this->need('header.php'); ?>
|
||||
<div class="main">
|
||||
<div class="container">
|
||||
<?php if ($this->options->showtoc): ?>
|
||||
<?php $this->need('toc.php'); ?>
|
||||
<?php endif; ?>
|
||||
<article class="post-wrap">
|
||||
<header class="post-header">
|
||||
<h1 class="post-title"><?php $this->title() ?></h1>
|
||||
|
@ -12,9 +15,8 @@
|
|||
<span class="post-category">
|
||||
所属分类:
|
||||
</span><?php $this->category(','); ?> <span class="dot"></span>
|
||||
<span> 浏览:</span><?php get_post_view($this) ?>次<span class="dot"></span>
|
||||
<span> 浏览:</span><?php get_post_view($this) ?>次
|
||||
<?php if($this->user->hasLogin() && $this->user->pass('editor', true)): ?>
|
||||
<span><span class="dot"></span>
|
||||
<a href="<?php $this->options->adminUrl('write-post.php?cid=' . $this->cid); ?>" target="_blank" title="编辑文章">
|
||||
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16">
|
||||
<path
|
||||
|
@ -24,7 +26,7 @@
|
|||
</div>
|
||||
</header>
|
||||
<div class="post-content">
|
||||
<?php $this->content(); ?>
|
||||
<?php $content = $this->content; echo addHeaderLinks($content); ?>
|
||||
</div>
|
||||
<section class="post-copyright">
|
||||
<p class="copyright-item">
|
||||
|
@ -71,8 +73,5 @@
|
|||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($this->options->showtoc): ?>
|
||||
<?php $this->need('toc.php'); ?>
|
||||
<?php endif; ?>
|
||||
<?php $this->need('footer.php'); ?>
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue