slidevjs / slidev

Presentation Slides for Developers
https://sli.dev
MIT License
32.81k stars 1.33k forks source link

only one slot is allowed in components #1701

Open zillionare opened 3 months ago

zillionare commented 3 months ago

Describe the bug multiple slots in layout is ok, but if we put more than one slots in customized compoents, it raises error:

Plugin: vite:vue
  File: /@slidev/slides/1.md:7:1
  5  |  <template v-slot:first="slotProps">
  6  |  </template>
  7  |  <template v-slot:second="slotProps">
     |   ^
  8  |  </Comparison>
  9  |  </template>
      at createCompilerError (.../slidev/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:1328:17)
      at emitError (.../slidev/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2812:5)
      at Object.onclosetag (.../slidev/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2179:13)

To Reproduce

the markdown:

---
layout: fact
---

this is test

<Comparison>

::first::

::second::

</Comparison>

the component (Comparison.vue):

<template>
    <div>
        <div class="container">
            <div class="box-1">
                <div class="triangle-right" />
                <div class="text-left">
                    {{ left }}
                </div>
            </div>
            <div class="box-2">
                <div class="triangle-left" />
                <div class="text-right">
                    {{ right }}
                </div>
            </div>
            <div>
                <slot />
            </div>
            <div>
                <slot name="first" />
            </div>
            <div>
                <slot name="second" />
            </div>

        </div>
    </div>
</template>

Desktop (please complete the following information):

KermanX commented 3 months ago

The ::slot-name:: syntax sugar seems to only work with slide-level slots currently🤔 We may improve this behavior in the future.

zillionare commented 3 months ago

Thanks for quick response and glad to know we'll have this enhancement in the future.

Really love slidev.