All Projects → movingbrands → svelte-portable-text

movingbrands / svelte-portable-text

Licence: MIT license
Svelte component for rendering block content

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to svelte-portable-text

svelte-inview
A Svelte action that monitors an element enters or leaves the viewport.🔥
Stars: ✭ 358 (+1093.33%)
Mutual labels:  svelte
sveltekit-blog-template
A SvelteKit blog template
Stars: ✭ 79 (+163.33%)
Mutual labels:  svelte
sdk-for-svelte
Appwrite SDK for Svelte 🧡 ⚠️ Warning - this SDK was designed to support Appwrite 0.9 and is not compatible with the latest Appwrite versions. We are planing to refactor it as part of the SDK Generator for better support and maintenance.
Stars: ✭ 69 (+130%)
Mutual labels:  svelte
BeatHub
Small, simple, and fast custom beatmap browser & downloader built with Svelte
Stars: ✭ 13 (-56.67%)
Mutual labels:  svelte
curl2ab
Convert cURL command line to ab (apache bench)
Stars: ✭ 22 (-26.67%)
Mutual labels:  svelte
sveltekit-blog
Sveltekit blog starter project created with sveltekit, typescript, tailwindcss, postcss, husky, and storybook. The project has the structure set up for the scaleable web application.
Stars: ✭ 100 (+233.33%)
Mutual labels:  svelte
SvelteTetris
Basic Tetris game created with Svelte
Stars: ✭ 21 (-30%)
Mutual labels:  svelte
kahi-ui
Straight-forward Svelte UI for the Web
Stars: ✭ 169 (+463.33%)
Mutual labels:  svelte
svelte-datagrid
Svelte data grid spreadsheet best best features and performance from excel
Stars: ✭ 48 (+60%)
Mutual labels:  svelte
hagura-sveltekit
A minimal markdown blog template built using SvelteKit
Stars: ✭ 51 (+70%)
Mutual labels:  svelte
visualisation-lab
An experimental visualisation workbench built using Svelte
Stars: ✭ 17 (-43.33%)
Mutual labels:  svelte
svelte-leaflet
Svelte component for leaflet.
Stars: ✭ 37 (+23.33%)
Mutual labels:  svelte
svelte-color-picker
A color picker component for svelte
Stars: ✭ 96 (+220%)
Mutual labels:  svelte
launchlet
Make the web yours.
Stars: ✭ 34 (+13.33%)
Mutual labels:  svelte
svelte-writable-derived
Two-way data-transforming stores for Svelte
Stars: ✭ 65 (+116.67%)
Mutual labels:  svelte
spellbook
Spellbook is a bookmark extension for Chrome and Firefox
Stars: ✭ 19 (-36.67%)
Mutual labels:  svelte
svelte-portal
Svelte component for rendering outside the DOM of parent component
Stars: ✭ 261 (+770%)
Mutual labels:  svelte
svelte-typescript-setups
Examples and tests of different bundler setups for Svelte with Typescript and PostCSS (Tailwind)
Stars: ✭ 50 (+66.67%)
Mutual labels:  svelte
ctx-core
A composable monorepo web-service/front-end toolkit
Stars: ✭ 25 (-16.67%)
Mutual labels:  svelte
vscode
Builder.io for VSCode - turn designs into code!
Stars: ✭ 139 (+363.33%)
Mutual labels:  svelte

svelte-portable-text

Note: this package is in active development, will likely change and may contain errors.

Install

At the moment, it seems the best approach is to install @sanity/block-content-to-hyperscript alongside this component.

Installing Svelte components as a devDependency seems to address this issue.

npm install @movingbrands/svelte-portable-text @sanity/block-content-to-hyperscript --save-dev

Usage example

<script>
  import BlockContent from "@movingbrands/svelte-portable-text";
  
  import Image from "./Image";
  import Link from "./Link";

  export let content;
  export const customSerializers = {
    types: {
      image: props => {
        return {
          component: Image,
          childNodes: props.children,
          props: {
            url: props.node.url
          }
        };
      }
    },
    marks: {
      link: props => {
        return {
          component: Link,
          childNodes: props.children,
          props: props.mark
        };
      }
    }
  };
  </script>

  <BlockContent blocks={content} serializers={customSerializers} />

Consuming components

With Svelte apps (recommended approach)

This package.json has a "svelte" field pointing to src/index.svelte, which allows Svelte apps to import the source code directly, if they are using a bundler plugin like rollup-plugin-svelte or svelte-loader (where resolve.mainFields in your webpack config includes "svelte").

Apps which aren't using Svelte elsewhere

npm run build will bundle your component's source code into a plain JavaScript module (index.mjs) and a UMD script (index.js).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].