withastro / starlight

🌟 Build beautiful, accessible, high-performance documentation websites with Astro
https://starlight.astro.build
MIT License
4.68k stars 504 forks source link

Setting 'base' in configuration and build.format: 'file' causes header link to point at incorrect url. #2383

Open davidguo12345 opened 1 week ago

davidguo12345 commented 1 week ago

What version of starlight are you using?

0.28.2

What version of astro are you using?

4.15.8

What package manager are you using?

pnpm, npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

When 'base' is set in 'astro.config.mjs' to a subpath such as 'some/path/', and when 'build.format' is 'file', the headers on generated doc pages will link to 'some/path.html' instead of 'some/path/index.html' as expected. This same issue does not occur if we set 'base' for vite in 'astro/config.mjs' via:

vite { 
    base: 'some/path'
}

Example document structure:

└── src/
    └── content/
        └── docs/
            ├── index.mdx
            ├── folder1/
            │   ├── page1.md
            └── folder2/
                └── page2.md

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-tcvntm?file=astro.config.mjs

Participation

unional commented 1 week ago

I also not able to get starlight to work in astro build with base.

I'm using the latest (0.28.2), and I have tried both build.format: 'file' | 'directory':

export default defineConfig({
  // neither of these work with `starlight`
  base: ...,
  vite: {
    base: ...
  },
  integrations: [
    starlight({
      sidebar: [
        {
          label: 'Getting Started',
          items: [{ 
             slug: 'guides/getting-started' // the resulting link is not adjusted
          }]
        }
      ]
    )}
  ]
})

related: https://github.com/withastro/astro/pull/5693#issuecomment-2372620390