joyent-portal/ui/docs/containers/item/index.js

34 lines
651 B
JavaScript
Raw Normal View History

2016-10-25 16:01:42 +03:00
const get = require('lodash.get');
const InnerHTML = require('dangerously-set-inner-html');
const React = require('react');
const titleCase = require('title-case');
const Docs = require('../../../src/docs');
2016-10-25 22:15:33 +03:00
const Item = ({
2016-10-25 16:01:42 +03:00
params
}) => {
const path = (params.parent !== 'undefined')
? `${titleCase(params.parent)}.${titleCase(params.name)}`
: `${titleCase(params.name)}`;
const body = get(Docs, path);
const item = body ? (
<InnerHTML html={body} />
) : (
<h1>{path} Not Found</h1>
);
return (
2016-10-26 19:32:38 +03:00
<div>
2016-10-25 16:01:42 +03:00
{item}
</div>
);
};
2016-10-25 22:15:33 +03:00
Item.propTypes = {
params: React.PropTypes.object
};
module.exports = Item;