Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c6e080c4d | |||
| b480c78344 | |||
| 0e216a2a2a | |||
| 5fa7c00a23 | |||
| 9a5d995ca5 | |||
| 5d8d1cbfc8 | |||
| b2bb437f59 | |||
| 907ade4b7f | |||
| a006880f58 | |||
| a065f44da4 | |||
| 372828a290 | |||
| 87be98f196 | |||
| 4ab2a62d99 | |||
| 1aad58e012 | |||
| 09e8e9e8a5 | |||
| ce9ae76e8a | |||
| d1e6567cc9 |
@@ -3,6 +3,9 @@
|
|||||||
移植自 `bigfa `大大的 `hugo-theme-farallon` 原汁原味,可以直接使用 原主题的CSS
|
移植自 `bigfa `大大的 `hugo-theme-farallon` 原汁原味,可以直接使用 原主题的CSS
|
||||||
精简部分 JS.
|
精简部分 JS.
|
||||||
|
|
||||||
|
- 2024.7.4
|
||||||
|
把分类图片以`mid`.jpg 的形式在主题`/dist/img`目录下,自动匹配
|
||||||
|
|
||||||
- 2024.6.12
|
- 2024.6.12
|
||||||
|
|
||||||
更新豆瓣API获取方式
|
更新豆瓣API获取方式
|
||||||
@@ -42,32 +45,13 @@ https://github.com/gogobody/typecho-whisper
|
|||||||
## 原项目地址
|
## 原项目地址
|
||||||
https://github.com/bigfa/hugo-theme-farallon
|
https://github.com/bigfa/hugo-theme-farallon
|
||||||
|
|
||||||
## 移植进度
|
|
||||||
|
|
||||||
96%
|
|
||||||
|
|
||||||
## 功能
|
## 功能
|
||||||
|
|
||||||
### 已知问题
|
|
||||||
|
|
||||||
由于typecho分类并无图片,所以默认使用
|
|
||||||
`bigfa` 的 `https://static.fatesinger.com/2021/12/vhp6eou5x2wqh2zy.jpg`
|
|
||||||
可以自行替换或者删除
|
|
||||||
|
|
||||||
|
|
||||||
### 豆瓣观影
|
### 豆瓣观影
|
||||||
|
|
||||||
更新 获取方式
|
更新 获取方式
|
||||||
|
|
||||||
~~使用原版的获取方式~~
|
|
||||||
|
|
||||||
~~豆瓣收藏使用方法~~
|
|
||||||
~~微信扫码登录https://node.wpista.com/~~
|
|
||||||
~~输入你的豆瓣数字 id,点击保存即可自动同步豆瓣记录。~~
|
|
||||||
~~点击 Get integration token 会生成一个 token。~~
|
|
||||||
|
|
||||||
~~获取`token`之后填入主题设置项中~~
|
|
||||||
|
|
||||||
### 友情链接
|
### 友情链接
|
||||||
|
|
||||||
基于 `links` 插件实现
|
基于 `links` 插件实现
|
||||||
@@ -90,15 +74,16 @@ https://github.com/bigfa/hugo-theme-farallon
|
|||||||
|
|
||||||
### 说说 by Mastodon
|
### 说说 by Mastodon
|
||||||
|
|
||||||
根据 https://www.imsun.org/archives/1643.html#toc3
|
根据 https://www.imsun.org/archives/1643.html
|
||||||
获得API地址
|
获得API地址
|
||||||
|
|
||||||
在自定义字段中填入`tooot`值为Mastodon API 地址
|
在自定义字段中填入`tooot`值为Mastodon API 地址
|
||||||
|
|
||||||
### 好物 by memos
|
### 好物 by memos
|
||||||
|
|
||||||
|
在自定义字段中填入`memos`值为memos地址
|
||||||
|
在自定义字段中填入`memosID`默认值为`1`,不为`1`时才需要设置
|
||||||
|
在自定义字段中填入`memostag`默认值为`好物`,不为`好物`时才需要设置
|
||||||
## 预览地址
|
## 预览地址
|
||||||
|
|
||||||
https://www.imsun.org
|
https://www.imsun.org
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
<?php $this->comments()->to($comments); ?>
|
<?php $this->comments()->to($comments); ?>
|
||||||
<?php if($this->allow('comment')): ?>
|
<?php if($this->allow('comment')): ?>
|
||||||
<?php if ($this->is('attachment')) : ?>
|
<?php if ($this->is('attachment')) : ?>
|
||||||
<?php _e(''); ?>
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<h3 class="comments--title" id="comments">
|
<h3 class="comments--title" id="comments">
|
||||||
<svg viewBox="0 0 24 24" class="icon" aria-hidden="true" width="16" height="16">
|
<svg viewBox="0 0 24 24" class="icon" aria-hidden="true" width="16" height="16">
|
||||||
@@ -52,8 +51,10 @@
|
|||||||
d="M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z">
|
d="M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z">
|
||||||
</path>
|
</path>
|
||||||
</g>
|
</g>
|
||||||
</svg><?php $this->commentsNum(_t('0'), _t('1'), _t('%d')); ?>
|
</svg>
|
||||||
|
<?php $this->commentsNum(_t('0'), _t('1'), _t('%d')); ?>
|
||||||
</h3>
|
</h3>
|
||||||
|
<ol class="commentlist sulliComment--list"></ol>
|
||||||
<div id="<?php $this->respondId(); ?>" class="comment-respond">
|
<div id="<?php $this->respondId(); ?>" class="comment-respond">
|
||||||
<div class="cancel-comment-reply cancel-comment-reply-link"><?php $comments->cancelReply(); ?></div>
|
<div class="cancel-comment-reply cancel-comment-reply-link"><?php $comments->cancelReply(); ?></div>
|
||||||
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form" class="comment-form">
|
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form" class="comment-form">
|
||||||
@@ -76,7 +77,6 @@
|
|||||||
<p class="comment-form-comment">
|
<p class="comment-form-comment">
|
||||||
<textarea rows="8" cols="50" name="text" id="textarea" class="textarea" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('misubmit').click();return false};" placeholder="<?php _e('评论审核后显示,请勿重复提交...'); ?>" required ><?php $this->remember('text'); ?></textarea>
|
<textarea rows="8" cols="50" name="text" id="textarea" class="textarea" onkeydown="if(event.ctrlKey&&event.keyCode==13){document.getElementById('misubmit').click();return false};" placeholder="<?php _e('评论审核后显示,请勿重复提交...'); ?>" required ><?php $this->remember('text'); ?></textarea>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="form-submit">
|
<p class="form-submit">
|
||||||
<button type="submit" class="submit" id="misubmit"><?php _e('提交评论(Ctrl+Enter)'); ?></button>
|
<button type="submit" class="submit" id="misubmit"><?php _e('提交评论(Ctrl+Enter)'); ?></button>
|
||||||
</p>
|
</p>
|
||||||
@@ -84,9 +84,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php _e(''); ?>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<ol class="commentlist sulliComment--list"></ol>
|
|
||||||
<?php if ($comments->have()): ?>
|
<?php if ($comments->have()): ?>
|
||||||
<?php $comments->listComments(); ?>
|
<?php $comments->listComments(); ?>
|
||||||
<?php
|
<?php
|
||||||
@@ -161,8 +160,3 @@ function threadedComments($comments, $options) {
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<ol class="commentlist">
|
|
||||||
<?php $this->comments()->to($comments); ?>
|
|
||||||
<?php while($comments->next()): ?>
|
|
||||||
<?php endwhile; ?>
|
|
||||||
</ol>
|
|
||||||
|
|||||||
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 244 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 206 KiB |
|
After Width: | Height: | Size: 25 KiB |
@@ -17,7 +17,7 @@
|
|||||||
is_single = false;
|
is_single = false;
|
||||||
post_id = 0;
|
post_id = 0;
|
||||||
is_archive = false;
|
is_archive = false;
|
||||||
VERSION = "0.5.4.1";
|
VERSION = "0.5.6";
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.initCopyright();
|
this.initCopyright();
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ function themeConfig($form) {
|
|||||||
$form->addInput($logoUrl);
|
$form->addInput($logoUrl);
|
||||||
$icoUrl = new Typecho_Widget_Helper_Form_Element_Text('icoUrl', NULL, NULL, _t('站点 Favicon 地址'));
|
$icoUrl = new Typecho_Widget_Helper_Form_Element_Text('icoUrl', NULL, NULL, _t('站点 Favicon 地址'));
|
||||||
$form->addInput($icoUrl);
|
$form->addInput($icoUrl);
|
||||||
$jzyear = new Typecho_Widget_Helper_Form_Element_Text('jzyear', NULL, NULL, _t('建站年份'), _t('eg. 2006'));
|
$sticky = new Typecho_Widget_Helper_Form_Element_Text('sticky', NULL, NULL, _t('置顶文章cid'), _t('多篇文章以`|`符号隔开'), _t('会在首页展示置顶文章。'));
|
||||||
|
$form->addInput($sticky);
|
||||||
|
$jzyear = new Typecho_Widget_Helper_Form_Element_Text('jzyear', NULL, NULL, _t('建站年份'), _t('eg. 2006'), _t('会在页脚显示。'));
|
||||||
$form->addInput($jzyear);
|
$form->addInput($jzyear);
|
||||||
$showProfile = new Typecho_Widget_Helper_Form_Element_Radio('showProfile',
|
$showProfile = new Typecho_Widget_Helper_Form_Element_Radio('showProfile',
|
||||||
array('0'=> _t('否'), '1'=> _t('是')),
|
array('0'=> _t('否'), '1'=> _t('是')),
|
||||||
@@ -47,10 +49,6 @@ function themeConfig($form) {
|
|||||||
array('0'=> _t('否'), '1'=> _t('是')),
|
array('0'=> _t('否'), '1'=> _t('是')),
|
||||||
'0', _t('是否显示复制链接'), _t('选择“是”将在文章页面显示复制链接。'));
|
'0', _t('是否显示复制链接'), _t('选择“是”将在文章页面显示复制链接。'));
|
||||||
$form->addInput($showshare);
|
$form->addInput($showshare);
|
||||||
$showtoc = new Typecho_Widget_Helper_Form_Element_Radio('showtoc',
|
|
||||||
array('0'=> _t('否'), '1'=> _t('是')),
|
|
||||||
'0', _t('是否显示文章目录'), _t('选择“是”将在文章页面显示文章目录(仅在宽度大于1400px的设备中显示)。'));
|
|
||||||
$form->addInput($showtoc);
|
|
||||||
$showtime = new Typecho_Widget_Helper_Form_Element_Radio('showtime',
|
$showtime = new Typecho_Widget_Helper_Form_Element_Radio('showtime',
|
||||||
array('0'=> _t('否'), '1'=> _t('是')),
|
array('0'=> _t('否'), '1'=> _t('是')),
|
||||||
'0', _t('是否显示页面加载时间'), _t('选择“是”将在页脚显示加载时间。'));
|
'0', _t('是否显示页面加载时间'), _t('选择“是”将在页脚显示加载时间。'));
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||||||
'date' => _t('在<span> %s </span>发布的文章'),
|
'date' => _t('在<span> %s </span>发布的文章'),
|
||||||
'author' => _t('%s 发布的文章')
|
'author' => _t('%s 发布的文章')
|
||||||
), '', ' - '); ?><?php if ($this->is('post')) $this->category(',', false);?><?php if ($this->is('post')) echo ' - ';?><?php $this->options->title(); ?><?php if ($this->is('index')) echo ' - '; ?><?php if ($this->is('index')) $this->options->description() ?></title>
|
), '', ' - '); ?><?php if ($this->is('post')) $this->category(',', false);?><?php if ($this->is('post')) echo ' - ';?><?php $this->options->title(); ?><?php if ($this->is('index')) echo ' - '; ?><?php if ($this->is('index')) $this->options->description() ?></title>
|
||||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/style.css'); ?>">
|
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/style.min.css'); ?>">
|
||||||
<?php if ($this->options->icoUrl): ?>
|
<?php if ($this->options->icoUrl): ?>
|
||||||
<link rel='icon' href='<?php $this->options->icoUrl() ?>' type='image/x-icon' />
|
<link rel='icon' href='<?php $this->options->icoUrl() ?>' type='image/x-icon' />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* 移植自HUGO主题 farallon 原作者 bigfa
|
* 移植自HUGO主题 farallon 原作者 bigfa
|
||||||
* @package farallon
|
* @package Farallon
|
||||||
* @author 老孙
|
* @author 老孙
|
||||||
* @version 0.5.5
|
* @version 0.5.7
|
||||||
* @link https://imsun.org
|
* @link https://www.imsun.org
|
||||||
*/
|
*/
|
||||||
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||||
$this->need('header.php');
|
$this->need('header.php');
|
||||||
|
|||||||
@@ -12,17 +12,26 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|||||||
<h2 class="post--single__subtitle"><?php $this->content(); ?> </h2>
|
<h2 class="post--single__subtitle"><?php $this->content(); ?> </h2>
|
||||||
</header>
|
</header>
|
||||||
<section class="category--list">
|
<section class="category--list">
|
||||||
<?php $this->widget('Widget_Metas_Category_List')->parse('
|
<?php $this->widget('Widget_Metas_Category_List')->to($categories); ?>
|
||||||
|
<?php while($categories->next()): ?>
|
||||||
|
<?php
|
||||||
|
// 获取分类 ID
|
||||||
|
$categoryId = $categories->mid;
|
||||||
|
// 获取主题URL
|
||||||
|
$themeUrl = $this->options->themeUrl;
|
||||||
|
// 为每个分类生成图片地址
|
||||||
|
$categoryImage = $themeUrl . '/dist/img/' . $categoryId . '.jpg';
|
||||||
|
?>
|
||||||
<div class="category--item">
|
<div class="category--item">
|
||||||
<img src="https://static.fatesinger.com/2021/12/vhp6eou5x2wqh2zy.jpg" class="category--cover"/>
|
<img class="category--cover" src="<?php echo $categoryImage; ?>" loading="lazy" alt="<?php $categories->name(); ?>">
|
||||||
<div class="category--content">
|
<div class="category--content">
|
||||||
<a href="{permalink}" class="category--card">{name}
|
<a class="category--card" href="<?php $categories->permalink(); ?>"><?php $categories->name(); ?>
|
||||||
<span>({count})</span>
|
<span>(<?php $categories->count(); ?>)</span></a>
|
||||||
</a>
|
<div class="category--desc"> <?php $categories->description(); ?>
|
||||||
<div class="category--desc">{description}</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
'); ?>
|
</div>
|
||||||
|
<?php endwhile; ?>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<?php $this->need('footer.php'); ?>
|
<?php $this->need('footer.php'); ?>
|
||||||
@@ -1,5 +1,13 @@
|
|||||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||||
<?php $this->need('header.php'); ?>
|
<?php $this->need('header.php'); ?>
|
||||||
|
<style>
|
||||||
|
#toc {font-size:14px;padding:10px 15px;background-color:var(--farallon-background-gray);border-radius:10px;margin-bottom:20px}
|
||||||
|
#toc summary{cursor:pointer}
|
||||||
|
#toc toc-title{font-weight:600}
|
||||||
|
#toc ul{padding-left:10px;margin-bottom:10px}
|
||||||
|
#toc ul li::before{content:"·";margin-right:5px}
|
||||||
|
#toc ul li>ul{margin-left:10px;font-size:12px}
|
||||||
|
</style>
|
||||||
<main class="site--main">
|
<main class="site--main">
|
||||||
<article class="post--single">
|
<article class="post--single">
|
||||||
<ul class="meta">
|
<ul class="meta">
|
||||||
@@ -36,8 +44,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<h2 class="post--single__title"><?php $this->title() ?></h2>
|
<h2 class="post--single__title"><?php $this->title() ?></h2>
|
||||||
<div class="post--single__content graph" ><?php $this->content(); ?></div>
|
<div class="post--single__content graph" ><?php $this->content(); ?></div>
|
||||||
<!--打赏 -->
|
|
||||||
<?php if($this->options->donate): ?>
|
<?php if($this->options->donate): ?>
|
||||||
|
<!--打赏 -->
|
||||||
<div class="post--single__action">
|
<div class="post--single__action">
|
||||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/donate.css'); ?>">
|
<link rel="stylesheet" href="<?php $this->options->themeUrl('/dist/css/donate.css'); ?>">
|
||||||
<script type="text/javascript" src="<?php $this->options->themeUrl('/dist/js/donate.js'); ?>"></script>
|
<script type="text/javascript" src="<?php $this->options->themeUrl('/dist/js/donate.js'); ?>"></script>
|
||||||
@@ -150,33 +158,39 @@
|
|||||||
</nav>
|
</nav>
|
||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
<?php if($this->options->showtoc): ?>
|
</main>
|
||||||
<!--TOC 在宽度大于1400px时才会显示-->
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', (event) => {
|
document.addEventListener('DOMContentLoaded', (event) => {
|
||||||
|
const targetClassElement = document.querySelector('.post--single__title');
|
||||||
const postContent = document.querySelector('.post--single__content');
|
const postContent = document.querySelector('.post--single__content');
|
||||||
if (!postContent) return;
|
if (!postContent) return;
|
||||||
|
|
||||||
let found = false;
|
let found = false;
|
||||||
for (let i = 1; i <= 6 && !found; i++) {
|
for (let i = 1; i <= 6 &&!found; i++) {
|
||||||
if (postContent.querySelector(`h${i}`)) {
|
if (postContent.querySelector(`h${i}`)) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) return;
|
if (!found) return;
|
||||||
|
|
||||||
const heads = postContent.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
const heads = postContent.querySelectorAll('h1, h2, h3, h4, h5, h6');
|
||||||
const toc = document.createElement('div');
|
const toc = document.createElement('div');
|
||||||
toc.id = 'toc';
|
toc.id = 'toc';
|
||||||
toc.innerHTML = '<strong>目录</strong><ul></ul>';
|
toc.innerHTML = '<details class="toc" open><summary class="toc-title">目录</summary><nav id="TableOfContents"><ul></ul></nav></details>';
|
||||||
document.body.appendChild(toc);
|
|
||||||
|
// 插入到指定 class 元素之后
|
||||||
|
if (targetClassElement) {
|
||||||
|
targetClassElement.parentNode.insertBefore(toc, targetClassElement.nextSibling);
|
||||||
|
}
|
||||||
|
|
||||||
let currentLevel = 0;
|
let currentLevel = 0;
|
||||||
let currentList = toc.querySelector('ul');
|
let currentList = toc.querySelector('ul');
|
||||||
let levelCounts = [0]; // 初始化层级计数器
|
let levelCounts = [0];
|
||||||
|
|
||||||
heads.forEach((head, index) => {
|
heads.forEach((head, index) => {
|
||||||
const level = parseInt(head.tagName.substring(1));
|
const level = parseInt(head.tagName.substring(1));
|
||||||
if (levelCounts[level] === undefined) {
|
if (levelCounts[level] === undefined) {
|
||||||
levelCounts[level] = 1; // 初始化该层级计数
|
levelCounts[level] = 1;
|
||||||
} else {
|
} else {
|
||||||
levelCounts[level]++;
|
levelCounts[level]++;
|
||||||
}
|
}
|
||||||
@@ -187,53 +201,33 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
|||||||
}
|
}
|
||||||
while (level > currentLevel) {
|
while (level > currentLevel) {
|
||||||
let newList = document.createElement('ul');
|
let newList = document.createElement('ul');
|
||||||
if(!currentList.lastElementChild) {
|
if (!currentList.lastElementChild) {
|
||||||
currentList.appendChild(newList);
|
currentList.appendChild(newList);
|
||||||
} else {
|
} else {
|
||||||
currentList.lastElementChild.appendChild(newList);
|
currentList.lastElementChild.appendChild(newList);
|
||||||
}
|
}
|
||||||
currentList = newList;
|
currentList = newList;
|
||||||
currentLevel++;
|
currentLevel++;
|
||||||
levelCounts[currentLevel] = 1; // 初始化下一层级的计数器
|
levelCounts[currentLevel] = 1;
|
||||||
}
|
}
|
||||||
while (level < currentLevel) {
|
while (level < currentLevel) {
|
||||||
currentList = currentList.parentElement;
|
currentList = currentList.parentElement;
|
||||||
if(currentList.tagName.toLowerCase() === 'li') {
|
if (currentList.tagName.toLowerCase() === 'li') {
|
||||||
currentList = currentList.parentElement;
|
currentList = currentList.parentElement;
|
||||||
}
|
}
|
||||||
currentLevel--;
|
currentLevel--;
|
||||||
}
|
}
|
||||||
const numbers = levelCounts.slice(1, level + 1).join(' ') ;
|
const anchor = head.textContent.trim().replace(/\s+/g, '-');
|
||||||
const item = document.createElement('li');
|
|
||||||
item.classList.add('toc-item'); // 添加基本类
|
|
||||||
item.classList.add(`level-${level}`); // 根据级别添加类
|
|
||||||
const anchor = `toc${index}`;
|
|
||||||
head.id = anchor;
|
head.id = anchor;
|
||||||
|
const item = document.createElement('li');
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = `#${anchor}`;
|
link.href = `#${anchor}`;
|
||||||
link.textContent = `${numbers}. ${head.textContent}`; // 序号+标题文本
|
link.textContent = `${head.textContent}`;
|
||||||
|
link.style.textDecoration = 'none';
|
||||||
item.appendChild(link);
|
item.appendChild(link);
|
||||||
currentList.appendChild(item);
|
currentList.appendChild(item);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style>
|
|
||||||
#toc {
|
|
||||||
position: fixed;
|
|
||||||
top: 100px;
|
|
||||||
right: 50px;
|
|
||||||
max-width: 200px;
|
|
||||||
background-color: var(--farallon-background-gray);
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
/* 其他样式... */
|
|
||||||
}
|
|
||||||
@media screen and (max-width: 1400px) {
|
|
||||||
#toc {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<?php endif; ?>
|
|
||||||
</main>
|
|
||||||
<?php $this->need('footer.php'); ?>
|
<?php $this->need('footer.php'); ?>
|
||||||
@@ -1,10 +1,75 @@
|
|||||||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
<?php
|
||||||
|
//确保退出安全
|
||||||
|
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
|
||||||
|
|
||||||
|
/** 文章置顶 */
|
||||||
|
$sticky = $this->options->sticky ; //置顶的文章id,多个用|隔开
|
||||||
|
|
||||||
|
if ($sticky) {
|
||||||
|
$sticky_cids = array_filter(explode('|', $sticky)); //分割文本并过滤空值
|
||||||
|
$sticky_html = " <span class=sticky--post> 置顶 </span> "; //置顶标题的 html
|
||||||
|
|
||||||
|
$db = Typecho_Db::get();
|
||||||
|
$pageSize = $this->options->pageSize;
|
||||||
|
|
||||||
|
// 构建置顶文章的查询
|
||||||
|
$selectSticky = $this->select()->where('type = ?', 'post');
|
||||||
|
foreach ($sticky_cids as $i => $cid) {
|
||||||
|
if($i == 0)
|
||||||
|
$selectSticky->where('cid = ?', $cid);
|
||||||
|
else
|
||||||
|
$selectSticky->orWhere('cid = ?', $cid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清空原有文章的列队
|
||||||
|
$this->row = [];
|
||||||
|
$this->stack = [];
|
||||||
|
$this->length = 0;
|
||||||
|
|
||||||
|
// 只在首页第一页展示置顶文章
|
||||||
|
if (($this->_currentPage || $this->currentPage) == 1) {
|
||||||
|
$stickyPosts = $db->fetchAll($selectSticky);
|
||||||
|
foreach ($stickyPosts as $stickyPost) {
|
||||||
|
$stickyPost['title'] = $stickyPost['title'] . $sticky_html;
|
||||||
|
$this->push($stickyPost); //压入列队
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建普通文章的查询,排除置顶文章的 CID
|
||||||
|
$selectNormal = $this->select()
|
||||||
|
->where('type = ?', 'post')
|
||||||
|
->where('status = ?', 'publish')
|
||||||
|
->where('created < ?', time())
|
||||||
|
->order('created', Typecho_Db::SORT_DESC)
|
||||||
|
->page($this->_currentPage, $pageSize);
|
||||||
|
|
||||||
|
foreach ($sticky_cids as $cid) {
|
||||||
|
$selectNormal->where('table.contents.cid != ?', $cid);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 登录用户显示私密文章
|
||||||
|
if ($this->user->hasLogin()) {
|
||||||
|
$uid = $this->user->uid;
|
||||||
|
if ($uid) {
|
||||||
|
$selectNormal->orWhere('authorId = ? AND status = ?', $uid, 'private');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$normalPosts = $db->fetchAll($selectNormal);
|
||||||
|
foreach ($normalPosts as $normalPost) {
|
||||||
|
$this->push($normalPost); //压入列队
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置总数(减去置顶文章数量,以进行正确的分页)
|
||||||
|
$total = $this->getTotal() - count($sticky_cids);
|
||||||
|
$this->setTotal(max($total, 0)); // 确保总数不为负数
|
||||||
|
}
|
||||||
|
?>
|
||||||
<?php while($this->next()): ?>
|
<?php while($this->next()): ?>
|
||||||
<article class="post--item">
|
<article class="post--item">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h2 class="post--title">
|
<h2 class="post--title">
|
||||||
<a href="<?php $this->permalink() ?>">
|
<a href="<?php $this->permalink() ?>">
|
||||||
<!--三天内显示火苗-->
|
|
||||||
<?php $this->title() ?>
|
<?php $this->title() ?>
|
||||||
<?php if((time() - $this->created) < 60*60*24*3): ?>
|
<?php if((time() - $this->created) < 60*60*24*3): ?>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
|
||||||
|
|||||||