-
Notifications
You must be signed in to change notification settings - Fork 159
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
feat: v-markdown directive #470
Comments
I love the idea of using the |
As I checked Vue directive API, providing slot for a component using directive seems tricky and may not possible in Vue2 at all. We could keep <SectionButton
to="#"
size="md"
class="bg-primary text-gray-800 hover:bg-green-300 focus:bg-green-300"
aria-label="test"
>
<Markdown use="cta" unwrap="span" />
<!-- OR -->
<Markdown :use="$scopedSlots.cta" unwrap="span" />
</SectionButton> Also using directive limits the usage. It will supports only one slot. But <SectionButton
to="#"
size="md"
class="bg-primary text-gray-800 hover:bg-green-300 focus:bg-green-300"
aria-label="test"
>
<template slot="title"><Markdown use="title" unwrap="span" /></template>
<template slot="subtitle"><Markdown use="subtitle" unwrap="span" /></template>
</SectionButton> |
I really like |
The I know for sure that Vue 3 adds new hooks and features to directives, and also an improved support for SSR for them. Maybe we could reconsider that directive then. 😄 |
When trying to inject content into nested slots, we encounter a problem where a named slot declared this way:
Will conflict with default slot from
SectionButton
.SectionButton will so receive
cta
slot instead of default one.This is related to the usage of
slot
key, which is a reserved word for Vue.This problem can be resolved by changing the
slot
props key on the Markdown component to anything else.This also makes me wonder if we could have a directive (which is an amazing feature from Vue) equivalent to
v-html
but calledv-markdown
that would mimic the behaviour of Markdown component by injecting it in default slot for the component.Here is an example of the possible end result:
In my opinion, this could be easily lightening the size of our templates by a lot, and would be really pleasing to use from a DX perspective.
Note:
We can also solve that
slot
naming problem using this syntax:<Markdown :node="$scopedSlots.cta" unwrap="p"/>
Thanks to @farnabaz for all the clarification on this subject. 😄
What do you think @atinux? 😄
The text was updated successfully, but these errors were encountered: