import React, {Component} from 'react'
import kCss from './item.scss'
import getHighLightText from '../../../../utils/getHighLightText'

export default class KnowledgeItem extends Component {

  //定义tab标签
  constructor(props) {
    super(props);
    this.state = {}

  }

  componentDidMount() {

  }


  unescapeHTML = (content) => {
    content = "" + content;
    return content.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
  }


  render() {
    let {title, content, url} = this.props.data;
    content = typeof content === 'undefined' ? '' : this.unescapeHTML(content);

    return (
      <li className={kCss["k-item"]}>
        <a href={url} className="s-link" target="view_window">
          <p className={`${kCss["k-ques"]}`}>{getHighLightText(title)}</p>
        </a>
        <p className={kCss["k-answ"]}>{getHighLightText(content)}</p>
      </li>
    )


  }


}

