PagePath.js 571 B

1234567891011121314151617181920212223242526272829
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. export default class PagePath extends React.Component {
  4. linkPath(path) {
  5. return path;
  6. }
  7. render() {
  8. const page = this.props.page;
  9. const shortPath = this.getShortPath(page.path);
  10. const pathPrefix = page.path.replace(new RegExp(shortPath + '(/)?$'), '');
  11. return (
  12. <span className="page-path">
  13. {pathPrefix}<strong>{shortPath}</strong>
  14. </span>
  15. );
  16. }
  17. }
  18. PagePath.propTypes = {
  19. page: PropTypes.object.isRequired,
  20. };
  21. PagePath.defaultProps = {
  22. page: {},
  23. };