import React from 'react';
import './index.scss';
export default (props) => {
  const { list } = props;

  function itemClick(item) {
    item.url && window.open(item.url);
  }

  return (

    list.map((item, i) => {
      return (
        <div className="search-item" key={item.id}>
          <div className="search-item-tit">
            <h3 className="search-item-title" dangerouslySetInnerHTML={{ __html: item.title }} onClick={() => { itemClick(item) }}></h3>

            {item.type == 1 && <p>
              <span className="search-icon"><i className="iconfont icon-dianjiliang mr3 font-12" />{item.watchersCount}</span>
              <span className="search-icon"><i className="iconfont icon-kongxing mr3 font-16" />{item.praisesCount}</span>
              <span className="search-icon"><i className="iconfont icon-fork mr3 font-16" />{item.forkedCount}</span>
            </p>}

          </div >
          <p className="search-item-content" dangerouslySetInnerHTML={{ __html: item.content }}></p>
          <div>{item.updateTime}</div>
        </div>
      )
    })
  )
}