Prismic Components 3.0.0-alpha

🤔 Something feels wrong with the components kit? Let us know in the ongoing Vue 3 Kit RFC!

The Components kit takes care of injecting helper components inside your Vue.js application.

Configuration

You can customize the behavior of some of the injected components through the kit configuration.

interface ComponentsOptions {
    link?: {
        anchorTag?: string;
        frameworkLink?: string;
        blankTargetRelAttribute?: string;
    };
}

interface PrismicPluginOptions {
    /* ... */
    components?: ComponentsOptions;
}
const prismic = createPrismic({
    /* ... */
    components: {
        link: {
            anchorTag: "a",
            frameworkLink: "router-link",
            blankTargetRelAttribute: "noopener",
        },
    },
});
const prismic = createPrismic({
    /* ... */
    components: false,
});
KeyTypeRequiredDefaultDescription
link.anchorTagstringNo"a"HTML tag to render external links
link.frameworkLinkstringNo"router-link"Vue component to use to render internal links, has to receive its href value through a to prop
link.blankTargetRelAttributestringNo"noopener"Value of the rel attribute on links with target="_blank"

Components

Injected components are made available globally! There's no need to import and register them manually.

Rich Text

The rich text component is a handy helper to display the content of a rich text field inside your application:

<prismic-rich-text :field="doc.richtext" />
<prismic-rich-text
    :field="doc.richtext"
    :link-resolver="anotherLinkResolver"
    :html-serializer="anotherHtmlSerializer"
    wrapper="article"
/>
PropTypeRequiredDefaultDescription
fieldRichTextFieldYesRich text field to display
linkResolverLinkResolverNoThe link resolver provided to @prismicio/vue or its default oneLink resolver to use when resolving links inside the provided field
htmlSerializerHtmlSerializer<string>NoThe HTML serializer provided to @prismicio/vue or its default oneHTML serializer to use when serializing the provided field
wrapperstringNo"div"Wrapper tag used to wrap output

The link component takes care of displaying with the right tag/component a link field inside your application:

<prismic-link :field="doc.link">My link</prismic-link>
<prismic-link :field="doc.link" :link-resolver="anotherLinkResolver">
    My link
</prismic-link>
<prismic-link :field="doc.link" v-slot="href"
    >My link to: {{ href }}</prismic-link
>
PropTypeRequiredDefaultDescription
fieldLinkFieldYesLink field to display
linkResolverLinkResolverNoThe link resolver provided to @prismicio/vue or its default oneLink resolver to use when resolving the provided link field

Image

The image component is a handy helper to display the content of an image field inside your application:

<prismic-image :field="doc.image" />
PropTypeRequiredDefaultDescription
fieldImageFieldYesImage field to display

Embed

The embed component is a handy helper to display the content of an embed field inside your application:

<prismic-embed :field="doc.embed" />
PropTypeRequiredDefaultDescription
fieldEmbedFieldYesEmbed field to display
Edit this page on GitHub Updated at Thu, Aug 12, 2021