0.0.5 • Published 3 years ago

@emagining/sveltekit-pote v0.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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. :)

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago