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

docs/.vitepress >> custom base path & root #34

Open
bx-shef opened this issue Sep 13, 2024 · 2 comments
Open

docs/.vitepress >> custom base path & root #34

bx-shef opened this issue Sep 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@bx-shef
Copy link

bx-shef commented Sep 13, 2024

Hello.

Project Structure
error-whyframe

The documentation is created using VitePress and is located in the /docs folder.

The project documentation will be published at https://demo.com/my-demo-folder/
In other words, the path is built relative to the '/my-demo-folder/' folder.

Config docs/.vitepress/config.mts

import {defineConfig} from 'vitepress'
import { whyframe } from '@whyframe/core'
import { whyframeVue } from '@whyframe/vue'

export default defineConfig({
  base: '/my-demo-folder/',
  vite: {
    plugins: [
      whyframe({
        defaultSrc: '/my-demo-folder/frames/default'
      }),
      whyframeVue({
        include: /\.(?:vue|md)$/
      })
    ]
  }
})

With this configuration, there is an issue
error-whyframe-2

If you build the project and view it, everything works
error-whyframe-3

The essence of the problem is in this code
error-whyframe-fix

With this approach, it will work
error-whyframe-4

@bluwy
Copy link
Owner

bluwy commented Sep 13, 2024

Amazing repro and description! That makes sense to me. So we need to prepend the base here:

attrs.push({
type: 'static',
name: isComponent ? '_why?.id' : 'data-why-id',
value: `/@id/__${entryId}`
})

And I think we can borrow the base from the Vite config using the configResolved hook in the same file, where c.base exposes it. That should fix it.

Would you like to send a PR? I'm able to fix this later too if not.

@bluwy bluwy added the bug Something isn't working label Sep 13, 2024
@bx-shef
Copy link
Author

bx-shef commented Sep 14, 2024

I'm sorry, but I can't do it in the near future

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

No branches or pull requests

2 participants