import React from 'react';
import moment from 'moment';

import { Link } from 'react-router';


const DATE_FORMAT = 'YYYY-MM-DD HH:mm';

const formatDate = (date) => moment(date).format(DATE_FORMAT);

const NewsPost = ({ post }) => (
    <article>
        <h2><Link to={`/news/${post._id}`}>{post.title}</Link></h2>
        <small>by {post.author.email} | {moment(post.updatedAt).fromNow()} | {post.categories.map(c => c.name).join(', ')}</small>
        <p>{post.body}</p>
        {post.eventData && <EventsPartial {...post.eventData} />}
    </article>
);

const EventsPartial = ({ from, to, rsvp, location }) => (
    <div className="event-partial">
        <span>{formatDate(from)} {formatDate(to)}</span>
        {rsvp && (<a href={rsvp} className="button">RSVP!</a>)}
        <GoogleMapsLink {...location} />
    </div>
);


const GoogleMapsLink = ({ lat, lng, name }) => (
    <a href={`https://www.google.com/maps/preview/@${lat},${lng},13z`} target="_blank">{name}</a>
);

export default NewsPost;
@@ -239,16 +239,41 @@
 %3Carticle
+ className=%22news-article%22
 %3E%0A      
@@ -306,11 +306,12 @@
 ost.
-_id
+slug
 %7D%60%7D%3E
@@ -365,16 +365,31 @@
 t.author
+ && post.author
 .email%7D 
@@ -491,18 +491,51 @@
       %3Cp
-%3E%7B
+ dangerouslySetInnerHTML=%7B%7B__html: 
 post.bod
@@ -536,16 +536,18 @@
 st.body%7D
+%7D%3E
 %3C/p%3E%0A   
@@ -737,16 +737,24 @@
  %3Cspan%3E%7B
+from && 
 formatDa
@@ -764,16 +764,22 @@
 from)%7D %7B
+to && 
 formatDa
@@ -865,16 +865,30 @@
         
+%7Blocation && (
 %3CGoogleM
@@ -911,16 +911,18 @@
 tion%7D /%3E
+)%7D
 %0A    %3C/d

Use slug as post url