PagePath.js 579 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}
  14. <strong>{shortPath}</strong>
  15. </span>
  16. );
  17. }
  18. }
  19. PagePath.propTypes = {
  20. page: PropTypes.object.isRequired,
  21. };
  22. PagePath.defaultProps = {
  23. page: {},
  24. };