Fix preview templates

This commit is contained in:
alxshelepenok 2018-11-13 17:14:46 +03:00
parent 0338cd2844
commit bd0677dfd3
3 changed files with 10 additions and 8 deletions

View File

@ -2,5 +2,5 @@ import CMS from 'netlify-cms';
import PagePreview from './preview-templates/page-preview';
import PostPreview from './preview-templates/post-preview';
CMS.registerPreviewTemplate('page', PagePreview);
CMS.registerPreviewTemplate('post', PostPreview);
CMS.registerPreviewTemplate('pages', PagePreview);
CMS.registerPreviewTemplate('posts', PostPreview);

View File

@ -1,14 +1,14 @@
import React from 'react';
import { Page } from '../../components/Page';
const PagePreview = ({ entry, widgetFor }) => {
const body = widgetFor(['body']);
const title = entry.getIn(['data', 'title']);
return (
<Page title={title}>
<div dangerouslySetInnerHTML={{ __html: body }} />
</Page>
<div className="page">
<h1 className="page__title">{title}</h1>
<div className="page__body" dangerouslySetInnerHTML={{ __html: body }} />
</div>
);
};

View File

@ -1,12 +1,14 @@
import React from 'react';
import { Content } from '../../components/Post/Content';
const PostPreview = ({ entry, widgetFor }) => {
const body = widgetFor(['body']);
const title = entry.getIn(['data', 'title']);
return (
<Content body={body} title={title} />
<div className="post">
<h1 className="post__title">{title}</h1>
<div className="post__body" dangerouslySetInnerHTML={{ __html: body }} />
</div>
);
};