content: import React from 'react';
  import config from '../../lib/config';
  import Parser from 'html-react-parser';
  
  import './css/style-single.css';
  
  class Single extends React.Component
  {
    constructor(props)
    {
      super(props);
      this.state = {
        title: '',
        content: '',
        featuredImage: '',
      }
      this.getDataFromWP = this.getDataFromWP.bind(this);
      this.getDataFromWP(this.props.slug);
    }
  
    getDataFromWP(slug)
    {
      config.wp.posts()
        .slug( slug )
        .embed()
        .perPage(1)
        .then( posts => {
          if( posts[0] )
          {
            this.setState({title: posts[0].title.rendered, content: posts[0].content.rendered});
            document.getElementById('loading').classList.remove('loading');
          }
        });
    }
  
    componentWillReceiveProps(nextProps)
    {
      this.getDataFromWP(nextProps.slug)
    }
  
    render()
    {
      return(
        <div className="single">
          <div id="loading" className="loading">
              <img src="/../img/logo-400x400.png" alt=""></img>
              <h2>Loading content from WordPress...</h2>
          </div>
  
          <h1>{this.state.title}</h1>
          <div className="post-container">{Parser(this.state.content)}</div>
        </div>
      );
    }
  }
  export default Single;
  