# @growthops/ext-datocms

> DatoCMS library for the GO Digital modern stack

Latest version **1.0.3** (published 2021-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @growthops/ext-datocms
pnpm add @growthops/ext-datocms
yarn add @growthops/ext-datocms
bun add @growthops/ext-datocms
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-06-21 |
| First published | 2021-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | 28keish, go-tristan |

## Links

- npm: https://www.npmjs.com/package/@growthops/ext-datocms
- Repository: https://github.com/growthops-digital/ext-datocms
- Homepage: https://github.com/growthops-digital/ext-datocms#readme
- Issues: https://github.com/growthops-digital/ext-datocms/issues
- npm.io page: https://npm.io/package/@growthops/ext-datocms

## Recent versions

- 1.0.3 (latest) — 2021-06-21
- 1.0.2 — 2021-06-15
- 1.0.1 — 2021-06-09
- 1.0.0 — 2021-06-08
- 0.0.1 — 2021-06-08

## README

# GrowthOps Ext DatoCMS

[![codecov](https://codecov.io/gh/growthops-digital/ext-datocms/branch/main/graph/badge.svg?token=WS0PJ3QQRW)](https://codecov.io/gh/growthops-digital/ext-datocms)

A collection of useful extensions built for [DatoCMS](https://www.datocms.com/).

## Functions

### renderBlocks

Renders out a collection of blocks as part of a DatoCMS modular field. This function requires that the collection of blocks include `_modelApiKey` as it will be utilised as the primary key for matching a block with its renderer.

**Example**
```js
import {renderBlocks} from '@growthops/ext-datocms';

// Example data from GraphQL query
const data = [
	{
		_modelApiKey: 'text',
		content: 'Lorem Ipsum Dolor Sit Amet Consectetur'
	},
	{
		_modelApiKey: 'image',
		url: 'https://example.com/image.jpg',
		alt: 'Dolor Sit Amet'
	}
];

const renderTextBlock = data => <p>{data.content}</p>;

const renderImageBlock = data => <img src={data.url} alt={data.alt}/>;

const App = () => (
	<div>
		{renderBlocks({
			text: renderTextBlock,
			image: renderImageBlock
		}, data)}
	</div>
);

// Rendered DOM:
// <div>
// 	<p>Lorem Ipsum Dolor Sit Amet Consectetur</p>
//  <img src="https://example.com/image.jpg" alt="Dolor Sit Amet"/>
// </div>
```

---
_Source: https://npm.io/package/@growthops/ext-datocms · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
