mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 21:19:37 +08:00
site: refactor with bisheng-plugin-toc/description
This commit is contained in:
parent
a97e54e253
commit
6bd299000a
@ -1,7 +1,11 @@
|
||||
module.exports = {
|
||||
source: ['./components', './docs'],
|
||||
theme: './site/theme',
|
||||
plugins: ['./site/bisheng-plugin-antd'],
|
||||
plugins: [
|
||||
'bisheng-plugin-description',
|
||||
'bisheng-plugin-toc?maxDepth=2',
|
||||
'./site/bisheng-plugin-antd',
|
||||
],
|
||||
webpackConfig(config) {
|
||||
config.resolve.alias = {
|
||||
antd: process.cwd(),
|
||||
|
@ -76,6 +76,8 @@
|
||||
"babel-jest": "^12.0.2",
|
||||
"babel-plugin-antd": "^0.4.0",
|
||||
"bisheng": "^0.3.0",
|
||||
"bisheng-plugin-description": "^0.1.1",
|
||||
"bisheng-plugin-toc": "0.1.0-beta.0",
|
||||
"dom-scroll-into-view": "^1.1.0",
|
||||
"enquire.js": "^2.1.1",
|
||||
"es6-shim": "^0.35.0",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { Children, cloneElement } from 'react';
|
||||
import DocumentTitle from 'react-document-title';
|
||||
import { Link } from 'react-router';
|
||||
import { getTagName, getChildren } from 'jsonml.js/lib/utils';
|
||||
import { getChildren } from 'jsonml.js/lib/utils';
|
||||
import { Timeline } from 'antd';
|
||||
import * as utils from '../utils';
|
||||
|
||||
@ -42,9 +42,7 @@ export default class Article extends React.Component {
|
||||
}
|
||||
render() {
|
||||
const { content, location } = this.props;
|
||||
const jumper = content.content.filter((node) => {
|
||||
return getTagName(node) === 'h2';
|
||||
}).map((node) => {
|
||||
const jumper = content.toc.map((node) => {
|
||||
return (
|
||||
<li key={getChildren(node)[0]}>
|
||||
<Link to={{ pathname: location.pathname, query: { scrollTo: getChildren(node)[0] } }}>
|
||||
@ -54,7 +52,7 @@ export default class Article extends React.Component {
|
||||
);
|
||||
});
|
||||
|
||||
const { meta, intro } = content;
|
||||
const { meta, description } = content;
|
||||
const { title, chinese, english } = meta;
|
||||
return (
|
||||
<DocumentTitle title={`${title || chinese || english} - Ant Design`}>
|
||||
@ -67,11 +65,10 @@ export default class Article extends React.Component {
|
||||
}
|
||||
</h1>
|
||||
{
|
||||
!intro ? null :
|
||||
utils.jsonmlToComponent(
|
||||
location.pathname,
|
||||
['section', { className: 'markdown' }].concat(intro)
|
||||
)
|
||||
!description ? null :
|
||||
this.props.utils.toReactComponent(
|
||||
['section', { className: 'markdown' }].concat(getChildren(description))
|
||||
)
|
||||
}
|
||||
{
|
||||
(jumper.length > 0 && meta.toc !== false) ?
|
||||
|
Loading…
Reference in New Issue
Block a user