All files / client/components/PageList PagePath.tsx

0% Statements 0/6
100% Branches 0/0
0% Functions 0/1
0% Lines 0/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                                                     
import React from 'react'
import { Page } from 'client/types/crowi'
import path2name from 'common/functions/path2name'
 
interface Props {
  page: Page
  excludePathString: string
}
 
export default class PagePath extends React.Component<Props> {
  static defaultProps = { page: {}, excludePathString: '' }
 
  render() {
    const page = this.props.page
    const pagePath = page.path.replace(this.props.excludePathString.replace(/^\//, ''), '')
    const shortPath = path2name(pagePath)
    const pathPrefix = pagePath.slice(0, -shortPath.length)
 
    return (
      <span className="page-path">
        {pathPrefix}
        <strong>{shortPath}</strong>
      </span>
    )
  }
}