昨天(2019/12/11),感觉自己博客速度实在是太慢了,而主题太复杂则是我觉得速度太慢的主要原因.于是心血来潮,想给博客换一个主题,也找到了比较喜欢的(哎,我真是一个喜新厌旧的人.),无奈是hugo的,那还能怎么办,只好换了,还好二者兼容性很好.下面记下折腾中遇到的一些坑..
例如categories: ["技术"]
,原先hexo没有这个要求,写了一个py轻松解决
import os
for md in os.listdir("./"):
if(md.endswith(".md")):
with open(md) as f:
tmp = f.read()
tmp = tmp.replace('categories: 技术','categories: ["技术"]')
tmp = tmp.replace('categories: 生活','categories: ["生活"]')
with open(md,'w') as f1:
f1.write(tmp)
(当时写的已经删除了,这个随便写的 不保证能用- -)
原先用hexo时候目录路径是完全按照自己的标题生成的,而hugo则转换成小写.好不容易有了几篇文章被收录,这样不就完蛋了.评论也是用的gitalk,路径变了,评论也丢了.同样的还有使用busuanzi的访客统计,也丢了. 解决办法:至于gitalk和busuanzi我是没办法了.
<script>
var currenturl=location.href.toLocaleLowerCase().replace("%20","-");
if(currenturl!=location.href){
location.href=currenturl;
}
</script>
async function handleRequest(request) {
let requestURL = new URL(request.url)
let path = decodeURIComponent(requestURL.pathname)
let location = path.toLowerCase().replace("%20","-")
if (location != path) {
return Response.redirect("https://huai.pub/"+location, 301)
}
return fetch(request)
}
addEventListener('fetch', async event => {
event.respondWith(handleRequest(event.request))
})
这个…没有解决..等以后有时间了再扣
其他 估计 也许 没了吧..