HiDeoo / starlight-blog

Starlight plugin to add a blog to your documentation
https://starlight-blog-docs.vercel.app
MIT License
126 stars 17 forks source link

Blog Links do not respect Astro Base url setting #26

Closed emeraldsquirrel closed 6 months ago

emeraldsquirrel commented 6 months ago

Describe the bug

If I have my base setting in Astro's astro.config.mjs defineConfig({}) of base: 'mysite',, then starlight-blog should generate links that use that config. But all links in starlight-blog are / instead.

For example base: 'mysite' should make the "blog" link in the navbar be localhost:port/mysite/blog but instead it's localhost:port/blog. Same for any links within the blog pages (if you know the url to access them and type them by hand).

I should mention my site is on Github Pages, to be colocated near my github project and since I don't want to shell out for a domain name. Github page urls are always my-account.github.io/my-repo/ so I always need to use the base for astro sites on it. I was hoping to use the blog module just for site update news.

Thanks for the nice module, hopefully I get to use it soon!

P.S. I would love the i18n #9 issue to get some love too but that's not nearly as high priority.

To Reproduce

set base setting in defineConfig(), load your site, click on any links generated by starlight-blog to get a bad link.

Expected behavior

It should take base into account.

How often does this bug happen?

Every time

System Info

No response

Additional Context

Adam M and Fryuni in Discord #starlight helped me out to make sure this wasn't just my noobness. They looked into it a bit and mentioned you may need to look at these files, but I don't know the project myself:

They also mentioned https://github.com/withastro/astro/issues/10303 which is a similar problem elsewhere but documents the solution, using import.meta.env.BASE_URL to get the prefix that should be added.

HiDeoo commented 6 months ago

Thanks for your report, super appreciated. :raised_hands:

I just published version 0.5.1 which should fix this issue.

Note: I also posted an update to the i18n issue with a link to the relevant Starlight proposal.