0.10.0 • Published 3 days ago

astro-portabletext v0.10.0

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

astro-portabletext

license npm

 

Render Portable Text with Astro.

Open in StackBlitz Open with CodeSandbox

 

Table of Contents

 

Getting Started

Install

$ npm install astro-portabletext
# $ pnpm add astro-portabletext
# $ yarn add astro-portabletext

Usage

ImportDescription
astro-portabletextFor PortableText component. See PortableText Component for details.
astro-portabletext/componentsFor Block, List, ListItem and Mark components. See Extending Components for details.
astro-portabletext/typesFor Typescript types
astro-portabletext/utilsFor utility functions
/* .astro file */
---
import { PortableText } from "astro-portabletext";
---

<PortableText
  value=/* Required */
  components=/* Optional */
  onMissingComponent=/* Optional */
  listNestingMode=/* Optional */
/>

astro-portabletext components will render the following:

{
  type: {
    /* custom types go here */
  },
  block: {
    h1: /* <h1 {...attrs}><slot /></h1> */,
    h2: /* <h2 {...attrs}><slot /></h2> */,
    h3: /* <h3 {...attrs}><slot /></h3> */,
    h4: /* <h4 {...attrs}><slot /></h4> */,
    h5: /* <h5 {...attrs}><slot /></h5> */,
    h6: /* <h6 {...attrs}><slot /></h6> */,
    blockquote: /* <blockquote {...attrs}><slot /></blockquote> */,
    normal: /* <p {...attrs}><slot /></p> */
  },
  list: {
    bullet: /* <ul {...attrs}><slot /></ul> */,
    number: /* <ol {...attrs}><slot /></ol> */,
    menu: /* <menu {...attrs}><slot /></menu> */,
  },
  listItem: {
    bullet: /* <li {...attrs}><slot /></li> */,
    number: /* <li {...attrs}><slot /></li> */,
    menu: /* <li {...attrs}><slot /></li> */,
  },
  mark: {
    code: /* <code {...attrs}><slot /></code> */,
    em: /* <em {...attrs}><slot /></em> */,
    link: /* <a {...attrs} href="..."><slot /></a> */,
    'strike-through': /* <del {...attrs}><slot /></del> */,
    strong: /* <strong {...attrs}><slot /></strong> */,
    underline: /* <span {...attrs} style="text-decoration: underline;"><slot /></span> */
  },
  hardBreak: /* <br /> */,
}

 

Documentation

Refer to docs page for advanced usage and examples, including implementation with Sanity.

 

License

ISC

0.10.0

3 days ago

0.9.9

18 days ago

0.9.8

27 days ago

0.9.7

2 months ago

0.9.4

9 months ago

0.9.6

7 months ago

0.9.5

7 months ago

0.9.0-next.2

12 months ago

0.9.0-next.1

12 months ago

0.9.0-next.4

12 months ago

0.9.0-next.3

12 months ago

0.9.0

12 months ago

0.9.1

12 months ago

0.9.0-next.0

1 year ago

0.8.1

1 year ago

0.8.0-next.0

1 year ago

0.8.0

1 year ago

0.7.0-next.1

2 years ago

0.7.0-next.2

2 years ago

0.7.0-next.3

2 years ago

0.7.0-next.4

2 years ago

0.7.0-next.0

2 years ago

0.5.0

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.4.0-next.2

2 years ago

0.4.0-next.3

2 years ago

0.4.0-next.4

2 years ago

0.4.0-next.5

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.0-next.0

2 years ago

0.4.0-next.1

2 years ago

0.2.3-next.1

2 years ago

0.2.3-next.0

2 years ago

0.3.0

2 years ago

0.3.0-next.0

2 years ago

0.2.3

2 years ago

0.2.4

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.1-next.2

2 years ago

0.2.1-next.1

2 years ago

0.2.1-next.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago