iTimeTraveler / hexo-theme-hiker

An attractive theme for Hexo. called "Hiker", short for "HikerNews".
https://itimetraveler.github.io/hexo-theme-hiker/
MIT License
368 stars 85 forks source link

Path to totop.js is hard-coded #129

Open ytakashina opened 5 years ago

ytakashina commented 5 years ago

When I put my web page in a sub directory on my server, the rocket was not displayed, raising the 404 error.

GET http://example.com/js/totop.js?v=1.0.0 net::ERR_ABORTED 404 (Not Found

This happens because the path to totop.js is hard-coded in layout/layout.ejs.

https://github.com/iTimeTraveler/hexo-theme-hiker/blob/eff78fa8f8642e4288c5b89c966ff3f3974805b2/layout/layout.ejs#L38

I propose to use theme.root defined in _config.yml in the hexo startar:

  <script type="text/javascript" src="<%- theme.root %>js/totop.js?v=1.0.0" async=""></script>

Since the default value of theme.root is /, I think the above modification is safe for conventional users who put their web pages in the site root. I'm willing to create a PR for this issue if requested.