# elasticpress/4.5.2/assets/js/blocks/comments/transforms.js

ElasticPress, version 4.5.2. 30 lines.

- Page: https://pluginprobe.com/plugins/elasticpress/4.5.2/code/assets/js/blocks/comments/transforms.js
- Raw: https://pluginprobe.com/plugins/elasticpress/4.5.2/raw/assets/js/blocks/comments/transforms.js
- Modified: 2022-11-29T18:22:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/elasticpress/4.5.2/code/assets/js/blocks/comments/transforms.js#L10-L20`.

```javascript
/**
 * WordPress dependencies.
 */
import { createBlock } from '@wordpress/blocks';

/**
 * Facet widget block transforms.
 */
export default {
	from: [
		{
			type: 'block',
			blocks: ['core/legacy-widget'],
			isMatch: ({ idBase }) => idBase === 'ep-comments',
			transform: ({ instance }) => {
				const { title = null, post_type: postTypes } = instance.raw;

				if (!title) {
					return createBlock('elasticpress/comments', { postTypes });
				}

				return [
					createBlock('core/heading', { content: title }),
					createBlock('elasticpress/comments', { postTypes }),
				];
			},
		},
	],
};

```
