以下修改,在8.0,8.2版本的handsome依然有效

keywords

当文章设置keywords字段时,替换html中的keywords,方便做搜索引擎优化

component/header.php

    <?php
    //修改点 keywords
    if($this->fields->keywords){
        $this->setKeywords($this->fields->keywords);
    }
    $this->header(Content::exportGeneratorRules($this));
    ?>

tag随机颜色

我这里选的颜色有点丑,得参考一下其他朋友的配色

component/sidebar.php

<?php while ($tags->next()): ?>
<?php //修改点 ?>
<a style="background-color:<?php echo Utils::randcolor();?>" href="<?php $tags->permalink();?>" class="label badge" title="<?php $tags->name(); ?>" data-toggle="tooltip"><?php $tags->name(); ?></a>
<?php endwhile; ?>

libs/Utils.php

    public static function randcolor(){
        $colorArr = array(
            "#8A2BE2",
            "#CC6633",
            "#333333",
            "#FF0066",
            "#996699",
            "#4B0082",
            "#191970",
            "#778899",
            "#006400",
            "#808000",
            "#8B4513",
            "#000000",
            "red",
            "green",
            "blue",
            "brown"
            );
        $k = array_rand($colorArr,1);
        return $colorArr[$k];
    }

导航栏自定义颜色

导航配置

{"name":"blog","feather":"book-open","link":"https://moozik.cn/blog/","target":"_self","style":"color: #ff9800;"},
{"name":"bilibili","feather":"tv","link":"https://moozik.cn/bilibili.html","target":"_self","style":"color: chartreuse;"},
{"name":"wiki","feather":"edit","link":"https://wiki.moozik.cn/","style":"color: cyan;","target":"__blank"},
{"name":"tools","feather":"tool","link":"https://tools.moozik.cn/","style":"color: white;","target":"__blank"},
{"name":"云顶之弈工具","feather":"star","link":"/yunding/","style":"color: yellow;","target":"__blank"},
{"name":"我的动态","feather":"heart","link":"https://moozik.cn/cross.html","target":"_self"},
{"name":"关于我","feather":"meh","link":"https://moozik.cn/about.html","target":"_self"},
{"name":"友链","feather":"users","link":"https://moozik.cn/links.html","target":"_self"}

libs/Contents.php

public static function returnLeftItem($asideItem, $haveSub, $subListHtml)
{

    $ret = "";
    @$itemName = $asideItem->name;
    @$itemStatus = $asideItem->status;
    @$itemLink = $asideItem->link;
    @$itemClass = $asideItem->class;
    @$itemFeather = $asideItem->feather;
    @$itemSub = $asideItem->sub;
    @$itemTarget = $asideItem->target;
    //修改点修改style
    @$itemStyle = empty($asideItem->style) ? '' : "style='{$asideItem->style}' ";


    if (@$itemTarget) {
        $linkStatus = 'target="' . $itemTarget . '"';
    } else {
        $linkStatus = 'target="_self"';
    }
    if (trim($itemFeather) == "") {
        if (count(mb_split(" ", $itemClass)) == 1 && strpos($itemClass,"fontello") === false && strpos($itemClass,"glyphicon") === false) {
            $itemFeather = $itemClass;
        }
    }

    $right_arrow = ($haveSub) ? '<span class="pull-right text-muted">
                <i class="fontello icon-fw fontello-angle-right text"></i>
                <i class="fontello icon-fw fontello-angle-down text-active"></i>
              </span>' : "";

    if (trim($itemFeather) !== "") {
        //修改点
        $ret = '<li> <a ' . $itemStyle . $linkStatus . ' href="' . $itemLink . '" 
class ="auto">' . $right_arrow . '<span class="nav-icon"><i data-feather="' . $itemFeather . '"></i></span><span>' . _mt
            ($itemName) . '</span></a>' . $subListHtml . '</li>';
    } else if (trim($itemClass) !== "") {
        $ret = '<li> <a ' . $linkStatus . ' href="' . $itemLink . '" class ="auto">' . $right_arrow . '<span class="nav-icon"><i class="'
            . $itemClass . '"></i></span><span>' . _mt($itemName) . '</span></a>' . $subListHtml . '</li>';
    }

    return $ret;
}

关闭阅读模式

page.php

<?php //echo Content::returnReadModeContent($this,$this->user->uid); ?>

post.php

<?php //echo Content::returnReadModeContent($this,$this->user->uid); ?>

github

修复某些情况下index.php错误永久链接重定向问题 #788
https://github.com/typecho/typecho/pull/788/commits/d4cb9361c13611ab3947b47d762ac5ba1575c39f

php8正式移除了类名相同的构造方法的支持 #1039
https://github.com/typecho/typecho/pull/1039/commits/f8d39927ce9fa8069f730f469bf22b1dd1896b14

最后修改:2021 年 06 月 21 日
如果觉得我的文章对你有用,请随意赞赏