import React from 'react'
import PropTypes from 'prop-types'
import niceTime from 'src/util/nice-time'
import classNames from 'classnames'

import styles from './ResultItem.css'

const ResultItem = props => (
    <div className={classNames(styles.result, styles[props.searchEngine])}>
        <a
            className={styles.title}
            href={props.url}
            onClick={props.onLinkClick}
            target="_blank"
        >
            {props.title}
        </a>
        <p className={styles.url}>{props.url}</p>
        <div className={styles.displayTime}>
            {' '}
            {niceTime(+props.displayTime)}{' '}
        </div>
    </div>
)

ResultItem.propTypes = {
    searchEngine: PropTypes.string.isRequired,
    displayTime: PropTypes.number.isRequired,
    url: PropTypes.string.isRequired,
    title: PropTypes.string.isRequired,
    onLinkClick: PropTypes.func.isRequired,
}
export default ResultItem

import React from 'react'
import PropTypes from 'prop-types'
import niceTime from 'src/util/nice-time'
import classNames from 'classnames'

import styles from './ResultItem.css'

const ResultItem = props => (
    <div className={classNames(styles.result, styles[props.searchEngine])}>
        <a
            className={styles.title}
            href={props.url}
            onClick={props.onLinkClick}
            target="_blank"
        >
            {props.title || props.url}
        </a>
        <p className={styles.url}>{props.url}</p>
        <div className={styles.displayTime}>
            {' '}
            {niceTime(+props.displayTime)}{' '}
        </div>
    </div>
)

ResultItem.propTypes = {
    searchEngine: PropTypes.string.isRequired,
    displayTime: PropTypes.number.isRequired,
    url: PropTypes.string.isRequired,
    title: PropTypes.string.isRequired,
    onLinkClick: PropTypes.func.isRequired,
}
export default ResultItem

Allow google/DDG results to fall back to URL if no title
Allow google/DDG results to fall back to URL if no title

- in some cases, where a page's title cannot be extracted (most websites work fine, PDFs depend on how the pdf metadata was set up) overview will fallback to displaying URL for title
- search injection result views didn't have this fallback, leading to minor inconsistencies
