tufu9441 / maupassant-hexo

A simple Hexo theme forked from icylogic.
https://www.haomwei.com
MIT License
2.61k stars 670 forks source link

博客部署在子路径时,静态资源读取到错误的位置 #518

Closed counter2015 closed 2 years ago

counter2015 commented 2 years ago

当 hexo 项目不是直接部署在对应域名下时,css/js 静态资源会从错误的位置读取

比如说,我的 hexo 的 配置文件里

url: https://counter2015.github.io/blog

copyright.css 的样式文件会读取到 https://counter2015.com/css/copyright.css

而正确的位置应该是 https://counter2015.com/blog/css/copyright.css

对应代码 https://github.com/tufu9441/maupassant-hexo/blob/85997d43cbf23cf032d0e95e40c974acf78299fa/layout/_widget/copyright.pug#L2-L3

要修改比较简单

div.post-copyright
    script(type='text/javascript',src=url_for(theme.js) + '/copyright.js',successtext=__('copy_success_text'))
    link(rel='stylesheet', type='text/css', href=url_for(theme.css) + '/copyright.css')

这个应该涉及到多个文件,没有详细去统计, copycode.css, copyright.css, love.css 都有这个问题

tufu9441 commented 2 years ago

谢谢!已经修复了。