dopry/netlify-cms

View on GitHub
src/components/Widgets/Markdown/MarkdownPreview/index.js

Summary

Maintainability
A
0 mins
Test Coverage
import PropTypes from 'prop-types';
import React from 'react';
import { markdownToHtml } from '../serializers';
import previewStyle from '../../defaultPreviewStyle';

const MarkdownPreview = ({ value, getAsset }) => {
  if (value === null) {
    return null;
  }
  const html = markdownToHtml(value, getAsset);
  return <div style={previewStyle} dangerouslySetInnerHTML={{__html: html}}></div>;
};

MarkdownPreview.propTypes = {
  getAsset: PropTypes.func.isRequired,
  value: PropTypes.string,
};

export default MarkdownPreview;