Renderer for the strapi CMS blocks text content element.
npm install nuxt-strapi-blocks-renderer

[![Github Actions][github-actions-src]][github-actions-href]
[![NPM version][npm-version-src]][npm-version-href]
[![NPM last update][npm-last-update-src]][npm-last-update-href]
[![License][license-src]][license-href]
Fully customizable module for Nuxt 3 & 4 to render the "Blocks" rich text editor element from Strapi CMS.
The implementation is based on Strapi's Blocks React Renderer.
- ✨ Release notes
- 🏀 Online stackblitz playground
To install the Nuxt Strapi Blocks Renderer module, run the following command:
``bash`
npx nuxt@latest module add nuxt-strapi-blocks-renderer
Or install it manually
1. Install the module:
`bash`
npm install nuxt-strapi-blocks-renderer
2. Add the module to nuxt.config.{ts|js}:
`typescript`
export default defineNuxtConfig({
modules: [ 'nuxt-strapi-blocks-renderer' ]
})
To render text, use the StrapiBlocksText component:
`vue`
In this example, the blockNodes are taken from the JSON response which Strapi provides when using the Blocks rich
text editor element:
`vue
`
To use the useStrapi composable, install the Strapi Nuxt module.
`html
`
This pattern also extends to the h3, h4, h5 and h6 tags.
Lists
Custom list tags (
, and ):`html
`
Blockquotes and Codes
Custom blockquote and code tags (
,):`html`
Inline text nodes
Custom inline text nodes (
,,,,):`html`
Links
Custom link tag (
):`html`urlWhen rendering a link tag, the url gets passed as the
component property.
Images
Custom image tag (
):`html`
class="my-custom-class-for-img"
:src="props.image.url"
:alt="props.image.alternativeText"
:width="props.image.width"
:height="props.image.height"
>imageWhen rendering an image tag, the image object gets passed as the
component property.NuxtImg
You can also use different image components here, i.e.or others.installDevelopment
$3
To install the dependencies, run the
command:`bash`
npm install`The project requires Node.js and NPM to run.
You can either install these manually on your system or if you have the nix package manager installed, use the
provided nix-shell with the following command:bash`
nix-shelldev:prepareThis will automatically install the needed software and start up a shell.
$3
To generate the type stubs for the nuxt module, run the
command:`bash`
npm run dev:preparedev$3
To start the development server with the provided text components, run the
command:`bash`
npm run devdev:customThis will boot up the playground with the default text components.
To start the development server using custom text components, overriding the provided components,
use thecommand:`bash`
npm run dev:custom`$3
#### Linter
To run ESLint, use the following command:
bash`
npm run lint:es`#### Type checks
To run the TypeScript type checks, use the following command:
bash`
npm run lint:types`#### Unit Tests
To run the Vitest unit tests, run the following command:
bash``
npm run test`$3
To build the module, first install all dependencies and generate the type stubs.
Then run the build script:bash`
npm run builddistThe module files will be output to the
folder.package.json$3
To release a new version of the strapi blocks renderer nuxt module, take the following steps:
1. Increment version number in the
file`
2. Add changelog entry for the new version number
3. Run linters and unit tests
4. Build the nuxt module
bash`
npm run build
release5. Log in to NPM using your access token
6. Run thecommand`
bash``
npm run release
[github-actions-src]: https://github.com/freb97/nuxt-strapi-blocks-renderer/actions/workflows/ci.yml/badge.svg
[github-actions-href]: https://github.com/freb97/nuxt-strapi-blocks-renderer/actions[npm-version-src]: https://img.shields.io/npm/v/nuxt-strapi-blocks-renderer/latest.svg?style=flat&colorA=18181B&colorB=31C553
[npm-version-href]: https://npmjs.com/package/nuxt-strapi-blocks-renderer[npm-last-update-src]: https://img.shields.io/npm/last-update/nuxt-strapi-blocks-renderer.svg?style=flat&colorA=18181B&colorB=31C553
[npm-last-update-href]: https://npmjs.com/package/nuxt-strapi-blocks-renderer[license-src]: https://img.shields.io/github/license/freb97/nuxt-strapi-blocks-renderer.svg?style=flat&colorA=18181B&colorB=31C553
[license-href]: https://github.com/freb97/nuxt-strapi-blocks-renderer/blob/main/LICENSE