fix: find p tag content

This commit is contained in:
ycjcl868 2019-09-08 11:39:51 +08:00 committed by 偏右
parent 35c537ee2d
commit 50606289d7
2 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,6 @@
import React, { Children, cloneElement } from 'react';
import { FormattedMessage, injectIntl } from 'react-intl';
import { Helmet } from 'react-helmet';
import flatten from 'lodash/flatten';
import { getChildren } from 'jsonml.js/lib/utils';
import { Timeline, Alert, Affix } from 'antd';
import EditButton from './EditButton';
@ -74,7 +73,10 @@ class Article extends React.Component {
const { title, subtitle, filename } = meta;
const isNotTranslated = locale === 'en-US' && typeof title === 'object';
const helmetTitle = `${title[locale] || title} - Ant Design`;
const contentChild = flatten(getChildren(content.content));
const contentChild = getChildren(content.content).find(jml => {
const [tag] = jml;
return tag === 'p';
});
return (
/* eslint-disable-next-line */
<article className="markdown" onClick={this.onResourceClick}>

View File

@ -3,7 +3,6 @@ import { Helmet } from 'react-helmet';
import { FormattedMessage, injectIntl } from 'react-intl';
import classNames from 'classnames';
import { Row, Col, Icon, Affix, Tooltip } from 'antd';
import flatten from 'lodash/flatten';
import { getChildren } from 'jsonml.js/lib/utils';
import Demo from './Demo';
import EditButton from './EditButton';
@ -108,7 +107,11 @@ class ComponentDoc extends React.Component {
'show-riddle-button': showRiddleButton,
});
const helmetTitle = `${subtitle || ''} ${title[locale] || title} - Ant Design`;
const contentChild = flatten(getChildren(content));
const contentChild = getChildren(content.content).find(jml => {
const [tag] = jml;
return tag === 'p';
});
return (
<article className={articleClassName}>
<Helmet>