vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.17k stars 2.12k forks source link

Vue named slots don't work in Markdown #4223

Closed gorlanova closed 1 month ago

gorlanova commented 1 month ago

Describe the bug

I'm writing documentation for a component library. Some components have slots.

Did I miss something or am I trying to do this the wrong way ? If not, it would be greatly appreciated to implement named slots in the Markdown pages.

Reproduction

=> "i"m slotted" won't be rendered

Expected behavior

Named slots should be parsed and rendered correctly, we should see slotted content passed in a named slot

System Info

System:
    OS: macOS 15.0
    CPU: (8) arm64 Apple M2
    Memory: 357.16 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.2.5 - /usr/local/bin/npm
    pnpm: 8.9.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Safari: 18.0
  npmPackages:
    vitepress: ^1.3.4 => 1.3.4

Additional context

Screenshot 2024-09-23 at 11 46 25 Screenshot 2024-09-23 at 11 47 34

My carousel has no slide rendered

Validations

brc-dd commented 1 month ago

Seems to work fine - https://stackblitz.com/edit/vite-th6x3s?file=docs/index.md,docs/Foo.vue

Can you share a minimal reproducible example?

gorlanova commented 1 month ago

Oh my, I was using this:

  import { defineClientComponent } from 'vitepress'

  const Foo = defineClientComponent(() => {
    return import('./Foo.vue');
  })

But yeah if I use a classic import it works, and it also works with the <ClientOnly> component wrapping my custom component! I don't remember why I used the other syntax, maybe I tested sth and I actually don't need it anymore...

Though the problem remains: if someone needs to use that syntax AND named slots, it won't work. Demo: https://stackblitz.com/edit/vite-mn3qjy?file=docs%2Findex.md

But for what I need to do for now, it's all good :)

brc-dd commented 1 month ago

Duplicate of #3867