Skip to content
This repository was archived by the owner on Jan 7, 2024. It is now read-only.
This repository was archived by the owner on Jan 7, 2024. It is now read-only.

An Astro native portable text solution #27

Open
@runeb

Description

@runeb

Thank you for this project! I have one request regarding the portable text handling in this project. The way it is currently handled is by rendering to html via @portabletext/[email protected] and setting the html string directly on a fragment.

There is an Astro native way to do this which lets you emit Astro components instead: https://github.com/theisel/astro-portabletext. Would you consider updating your project to leverage this module instead?

It then becomes

---
import { PortableText } from "astro-portabletext";
import Code from "./Code.astro";
const {portableText} = Astro.props;

const components = {
  type: {
    code: Code
  },
}
---

<PortableText
  value={portableText}
  components={components}
/>

And you can write proper Astro components for your custom types

---
import { Prism } from '@astrojs/prism';
const {node} = Astro.props;
const {code, language} = node;
---

<Prism lang={language} code={code}></Prism>

Thanks again for the work on this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions