blocks-svelte-renderer Svelte Themes

Blocks Svelte Renderer

A Svelte renderer for the Strapi's Blocks rich text editor

Blocks Svelte Renderer

A Svelte implementation of Strapi's blocks-react-renderer, adapted for Svelte 5. This library allows you to render Strapi's new Blocks rich text editor seamlessly within your Svelte applications.

Installation

You can install this package via npm:

npm install blocks-svelte-renderer

Usage

Here's a basic example of how to use the Svelte Blocks Renderer in your Svelte application:

<script>
  import BlockRenderer from 'blocks-svelte-renderer';

  const contentBlocks = [
    { type: 'heading', level: 2, children: [{ text: 'Hello World' }] },
    { type: 'paragraph', children: [{ text: 'This is a paragraph.' }] },
    // Add more content blocks as needed
  ];
</script>

<BlockRenderer content={contentBlocks} />

Default Components

The following default components are included:

  • Heading
  • Paragraph
  • Image
  • Link
  • List
  • ListItem
  • Quote
  • Code

You can customize these components according to your application's requirements.

License

This project is licensed under the MIT Expat License. Portions of the code are derived from Strapi's blocks-react-renderer, which is also licensed under the MIT Expat License.

Acknowledgements

  • Strapi for their original blocks-react-renderer, which inspired this implementation.

Top categories

Loading Svelte Themes