add 分类图片获取

This commit is contained in:
浪子 2024-07-04 20:02:06 +08:00
parent 2b595583c1
commit d1e6567cc9
3 changed files with 31 additions and 25 deletions

View File

@ -3,6 +3,9 @@
移植自 `bigfa `大大的 `hugo-theme-farallon` 原汁原味,可以直接使用 原主题的CSS
精简部分 JS.
- 2024.7.4
把分类图片以`mid.jpg`的形式在主题`img`目录下,自动匹配
- 2024.6.12
更新豆瓣API获取方式
@ -50,9 +53,9 @@ https://github.com/bigfa/hugo-theme-farallon
### 已知问题
由于typecho分类并无图片,所以默认使用
`bigfa``https://static.fatesinger.com/2021/12/vhp6eou5x2wqh2zy.jpg`
可以自行替换或者删除
~~由于typecho分类并无图片,所以默认使用~~
~~`bigfa``https://static.fatesinger.com/2021/12/vhp6eou5x2wqh2zy.jpg` ~~
~~可以自行替换或者删除~~
### 豆瓣观影

View File

@ -43,7 +43,6 @@
<?php $this->comments()->to($comments); ?>
<?php if($this->allow('comment')): ?>
<?php if ($this->is('attachment')) : ?>
<?php _e(''); ?>
<?php else: ?>
<h3 class="comments--title" id="comments">
<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">
</path>
</g>
</svg><?php $this->commentsNum(_t('0'), _t('1'), _t('%d')); ?>
</h3>
</svg>
<?php $this->commentsNum(_t('0'), _t('1'), _t('%d')); ?>
</h3>
<ol class="commentlist sulliComment--list"></ol>
<div id="<?php $this->respondId(); ?>" class="comment-respond">
<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">
@ -76,7 +77,6 @@
<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>
</p>
<p class="form-submit">
<button type="submit" class="submit" id="misubmit"><?php _e('提交评论Ctrl+Enter'); ?></button>
</p>
@ -84,9 +84,8 @@
</div>
<?php endif; ?>
<?php else: ?>
<?php _e(''); ?>
<?php endif; ?>
<ol class="commentlist sulliComment--list"></ol>
<?php if ($comments->have()): ?>
<?php $comments->listComments(); ?>
<?php
@ -161,8 +160,3 @@ function threadedComments($comments, $options) {
<?php } ?>
</li>
<?php } ?>
<ol class="commentlist">
<?php $this->comments()->to($comments); ?>
<?php while($comments->next()): ?>
<?php endwhile; ?>
</ol>

View File

@ -12,17 +12,26 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<h2 class="post--single__subtitle"><?php $this->content(); ?> </h2>
</header>
<section class="category--list">
<?php $this->widget('Widget_Metas_Category_List')->parse('
<div class="category--item">
<img src="https://static.fatesinger.com/2021/12/vhp6eou5x2wqh2zy.jpg" class="category--cover"/>
<div class="category--content">
<a href="{permalink}" class="category--card">{name}
<span>({count})</span>
</a>
<div class="category--desc">{description}</div>
</div>
</div>
'); ?>
<?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 . 'img/' . $categoryId . '.jpg';
?>
<div class="category--item">
<img class="category--cover" src="<?php echo $categoryImage; ?>" loading="lazy" alt="<?php $categories->name(); ?>">
<div class="category--content">
<a class="category--card" href="<?php $categories->permalink(); ?>"><?php $categories->name(); ?>
<span>(<?php $categories->count(); ?>)</span></a>
<div class="category--desc"> <?php $categories->description(); ?>
</div>
</div>
</div>
<?php endwhile; ?>
</section>
</div>
<?php $this->need('footer.php'); ?>