iTimeTraveler/hexo-theme-hiker

Path to totop.js is hard-coded

ytakashina opened this issue · 0 comments

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.

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

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.