ZTL-UwU / shadcn-docs-nuxt

Effortless and beautiful docs template built with Nuxt Content & shadcn-vue.
https://shadcn-docs-nuxt.vercel.app/
MIT License
221 stars 32 forks source link

cannot find files in the public folder #30

Closed xarthurx closed 2 months ago

xarthurx commented 2 months ago

I tried to provide downloadable files in the public folder. But it seems the link always lead to a empty page.

How are links handled when they are directed to the public folder?

Tried both:

  1. [:icon{name="lucide:cloud-download"}](/ghDemo/BAL_soilDemoPart1.gh)
  2. [Linked File](/ghDemo/BAL_soilDemoPart1.gh)

Neither worked,

FYI, it was fine when I use docus. So I guess there's something wrong here with your template...

ZTL-UwU commented 2 months ago

For now you can set external to true.

xarthurx commented 2 months ago

For now you can set external to true.

  • [:icon{name="lucide:cloud-download"}](/ghDemo/BAL_soilDemoPart1.gh){external=true}
  • [Linked File](/ghDemo/BAL_soilDemoPart1.gh){external=true}

Nope.

 WARN  [Vue warn]: Invalid prop: type check failed for prop "external". Expected Boolean, got String with value "true".
  at <NuxtLink href="/public/ghDemo/BAL_soilDemoPart1Separates.gh" target=undefined class="font-semibold underline underline-offset-4"  ... >
  at <ProseA href="/public/ghDemo/BAL_soilDemoPart1Separates.gh" external="true" >
  at <AsyncComponentWrapper href="/public/ghDemo/BAL_soilDemoPart1Separates.gh" external="true" >
  at <ProseP >
  at <AsyncComponentWrapper >
  at <MDCRenderer body= { type: 'root',

Cannot send a boolean value to the external.

xarthurx commented 2 months ago

Is this caused by some extra optimization in your template that blocked the access of public folder?

ZTL-UwU commented 2 months ago

It's because the routes of files in the public folder are caught by the [...slug].vue page.

xarthurx commented 2 months ago

It's because the routes of files in the public folder are caught by the [...slug].vue page.

It shoulden't... public are by default exposable for nuxt or nuxt content project and should be excluded for webpage route auto-generation. It was all fine for docus template, so I assume something you did reverted the function.

ZTL-UwU commented 2 months ago

No, I dont believe that docus has a [...slug].vue page. Also, if you refresh the empty page, I think you can see the files after.

It shoulden't... public are by default exposable for nuxt or nuxt content project and should be excluded for webpage route auto-generation.

I don't think it should either. I'm not sure why it is caught.

xarthurx commented 2 months ago

No, I dont believe that docus has a [...slug].vue page. Also, if you refresh the empty page, I think you can see the files after.

It shoulden't... public are by default exposable for nuxt or nuxt content project and should be excluded for webpage route auto-generation.

I don't think it should either. I'm not sure why it is caught.

Refresh doesn't make it work.

ZTL-UwU commented 2 months ago

perhaps it works differently in a nuxt layer

xarthurx commented 2 months ago

I got this warning from the cmd when I clicked the link:

 WARN  [Vue warn]: Extraneous non-props attributes (data-v-inspector) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
  at <ToastProvider label=undefined duration=undefined swipeDirection=undefined  ... >
  at <ToastProvider data-v-inspector="node_modules/shadcn-docs-nuxt/app.vue:18:3" >
  at <Toaster data-v-inspector="node_modules/shadcn-docs-nuxt/app.vue:18:3" >
  at <App data-v-inspector="node_modules/nuxt/dist/app/components/nuxt-root.vue:16:5" >
  at <NuxtRoot>
ZTL-UwU commented 2 months ago

This is not relevant

ZTL-UwU commented 2 months ago

It's because the routes of files in the public folder are caught by the [...slug].vue page.

It shoulden't... public are by default exposable for nuxt or nuxt content project and should be excluded for webpage route auto-generation. It was all fine for docus template, so I assume something you did reverted the function.

Actually, I think this is expected behavior from nuxt. see https://stackblitz.com/edit/nuxt-starter-1rvxlv?file=app.vue,pages%2F[...slug].vue

I'll add the external prop to proseA and it should work.

xarthurx commented 2 months ago

I'm also testing and realized that if I just click, it has the problem. But if I right-click and "open in new tab", similar to sending a _blank to the html and open a new page, then I can download the file.

ZTL-UwU commented 2 months ago

@xarthurx Please try upgrading to v0.5.4 and use [:icon{name="lucide:cloud-download"}](/ghDemo/BAL_soilDemoPart1.gh){external=true}. See if it fixes it for you.

ZTL-UwU commented 2 months ago

I'm also testing and realized that if I just click, it has the problem. But if I right-click and "open in new tab", similar to sending a _blank to the html and open a new page, then I can download the file.

Yes, that's equivalent to refreshing and the external prop which triggers a a full-page reload.

xarthurx commented 2 months ago

I'm also testing and realized that if I just click, it has the problem. But if I right-click and "open in new tab", similar to sending a _blank to the html and open a new page, then I can download the file.

Yes, that's equivalent to refreshing and the external prop which triggers a a full-page reload.

[:icon{name="lucide:cloud-download"}](/public/ghDemo/BAL_soilDemoPart1Separates.gh)  <-- not working
[LinkX](/ghDemo/BAL_soilDemoPart1Separates.gh){external=true} <-- working

I think theere is some mechanism in your component that has made the #title already a <a> and won't allow additional <a> inside an <a>.

xarthurx commented 2 months ago

BTW, I'm using the card component like: image

xarthurx commented 2 months ago

Nevermind. I finally overcome this by writing a customized component. Thank you for the effort.