Hi there!
After spending a couple days reading through the documentation, I thought I'd write a post to explain a simple need that I've not seen demonstrated in a way that would allow me to begin formatting text with Prismic.
I will need to use Prismic's serializers to format my content text, and need a simple example of introducing line breaks into content rendered by PrismicRichText from @prismicio/react.
I'm just "not getting it".
Text content appears in my site as a single block of uninterrupted words, but the CMS content contains line breaks to distinguish paragraphs (see attached screen capture). I would like to understand this simple use case of introducing line breaks to text that contains them in the editor. I think this will help me grasp more complex ways of formatting.
I enjoy adopting complex implementations when they offer power and versatility, which this system seems to offer. However I feel that people need to be introduced to the very basics first. I have seen a lack of this kind of content in the documentation.
For me, introducing simple line breaks is this starting point.
Here is the code for my slice:
import styles from "@/styles/slices/AboutRichText/AboutRichText.module.scss";
import { PrismicRichText } from "@prismicio/react";
/**
* @typedef {import("@prismicio/client").Content.AboutRichTextSlice} AboutRichTextSlice
* @typedef {import("@prismicio/react").SliceComponentProps<AboutRichTextSlice>} AboutRichTextProps
* @param {AboutRichTextProps}
*/
const AboutRichText = ({ slice }) => {
return (
<section
data-slice-type={slice.slice_type}
data-slice-variation={slice.variation}
>
<div className={styles.contentWrapper}>
<div className={styles.textWrapper}>
{/* This text uses line breaks to separate content into paragraphs. */}
<PrismicRichText field={slice.primary.about_text} />
</div>
</div>
</section>
);
};
export default AboutRichText;
Thanks in advance, and I apologize if this post makes it seem as if an effort hasn't been made to document how to format text. It's obvious it has; I just can't find a starting point from which to ease into this system of formatting text.