今天更新了最新的 pb, 发现能够自定义 tags 模板页面了,但是页面标题里面不包含 tag 名,感觉不美观,就在 tags.html 里面加了段 js,修改页面的标题。
由于tag 页面链接变成了 https://savalone.com/tag/软件/ 这样,所以我们要匹配到第四个和第五个“/”符号之间的“软件”,而结果匹配到的是“%E8%BD%AF%E4%BB%B6”,所以我们要 decode 解码一下。
js 代码如下:
<script>
window.onload = function(){
var url = '{pboot:pageurl}';
var decode = (decodeURI((url.split(///)[4]))); // 正则提取链接的第四和第五个'/'符号之间的参数,并解码
var sitetitle = '{pboot:sitetitle}';
document.title = decode + '-' + sitetitle;
}
</script>
或者 jq:
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
$(function(){
var url = '{pboot:pageurl}';
var decode = (decodeURI((url.split(///)[4]))); // 正则提取链接的第四和第五个'/'符号之间的参数,并解码
var sitetitle = '{pboot:sitetitle}';
$('title').html(decode + '-' + sitetitle);
})
</script>
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有