Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starlight is incompatible with the Astro build.format preserve option #1781

Closed
1 task
lschierer opened this issue Apr 23, 2024 · 1 comment · Fixed by #1913
Closed
1 task

Starlight is incompatible with the Astro build.format preserve option #1781

lschierer opened this issue Apr 23, 2024 · 1 comment · Fixed by #1913
Labels
🐛 bug Something isn't working

Comments

@lschierer
Copy link

What version of starlight are you using?

0.21.5

What version of astro are you using?

4.6.3

What package manager are you using?

pnpm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

when I add the options

    trailingSlash: 'always',
    build: {
      format: 'preserve',
    },

to an existing otherwise working starlight project, it stops working with the error

13:16:42 [ERROR] Cannot read properties of undefined (reading 'addBase')
  Stack trace:
    at formatPath (/home/projects/withastro-starlight-7ibewh/node_modules/@astrojs/starlight/utils/createPathFormatter.ts:25:25)
    [...] See full stack trace in the browser, or rerun with --verbose.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-starlight-7ibewh?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@delucis
Copy link
Member

delucis commented Apr 23, 2024

Thank you for the bug report @lschierer! I think this is probably related to the 'preserve' setting — that was added to Astro after our logic for paths was added, so we’re likely not accounting for it in the createPathFormatter utility where that error is being logged.

Our formatting strategies account for the 'file' and 'directory' configurations, but not the newer 'preserve':

const formatStrategies = {
file: {
addBase: fileWithBase,
handleExtension: (href: string) => ensureHtmlExtension(href),
},
directory: {
addBase: pathWithBase,
handleExtension: (href: string) => stripHtmlExtension(href),
},
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants