@emagining/sveltekit-pote
v0.0.5
Published
Provides a way to render [Portable Text](http://www.portabletext.org) in Svelte / SvelteKit applications.
Downloads
2
Maintainers
Readme
Portable Text for Svelte & SvelteKit
Provides a way to render Portable Text in Svelte / SvelteKit applications.
Based on @arzidava/svelte-portable-text but removes the wrapping <div>
around blocks (paragraphs)
=> "p" blocks will be wrapped in <p> {paragraph} </p>
instead of <div><p><span> {paragraph} </span></p></div>
Install
npm add --save-dev @emagining/sveltekit-pote
Usage
<script>
import BlockContent from '@emagining/sveltekit-pote'
import Image from '$lib/Image.svelte'
import Link from '$lib/Link.svelte'
export let content;
export const customSerializers = {
types: {
image: props => {
return {
component: Image,
props: {
url: props.node.url,
},
};
},
},
marks: {
link: props => {
return {
component: Link,
props: props.mark,
};
},
},
};
</script>
<BlockContent blocks="{content}" serializers="{customSerializers}" />
Work in Progress
This package was created to serve my own needs. Have a look at these libs to see if they better serve your need:
Contribute
Open an issue or make a pull req. :)