TryGhost / Source

The default theme for Ghost
https://source.ghost.io
MIT License
57 stars 112 forks source link

Pagination doesn't work when Ghost URL is set to a subpath #28

Closed trostli closed 10 months ago

trostli commented 10 months ago

I have configured my Ghost blog to be hosted on a subpath such as https://example.com/blog/.

However with the Source theme the link to see the next page of posts is linked as https://example.com/page/2

Whereas I believe it should link to as https://example.com/blog/page/2

Looks like the culprit is this line: https://github.com/TryGhost/Source/blob/0798ee6e48273ab912d8e8e7ceee287bf481a789/partials/components/post-list.hbs#L118

I've solved it for now by using the following Code injection in my admin panel:

<script>
  document.addEventListener('DOMContentLoaded', function () {
      var currentUrl = window.location.href; // Get current URL
      var appendUrl = "page/2"; 
      var newUrl = currentUrl + appendUrl;
      var link = document.querySelector('.gh-more a');

      link.href = newUrl; // Set the href attribute
  });
</script>
minimaluminium commented 10 months ago

Hey, thanks for reporting the issue! This is now fixed in https://github.com/TryGhost/Source/commit/d22775c1090066521702359ab4ba2e2046e6d535.

While the JS solution you've provided is great, there's a built-in setting {{@site.url}} which suits better in this situation.