import hljs from 'highlight.js';
import React, { Component } from 'react';
import Icon from 'react-fontawesome';
import Markdown from 'react-markdown';
import { Link } from 'react-router-dom';
import slugify from 'slugify';
import { ListLink } from './Nav';
class Article extends Component {
render() {
let body = "";
let readMore = "";
if (this.props.blurb) {
body = this.props.article.blurb;
readMore = (read more);
} else {
body = this.props.article.body;
}
return (
{ this.props.article.title }
{ this.meta() }
{ readMore }
);
}
componentDidMount() {
document.querySelectorAll('pre code').forEach(elm => {
hljs.highlightBlock(elm);
});
}
postLink() {
let date = new Date(this.props.article.date);
let year = date.getUTCFullYear();
let month = date.getUTCMonth() + 1;
let slug = this.props.article.slug;
if (!slug) {
slug = slugify(this.props.article.title);
}
return `/${year}/${month}/${slug}`;
}
meta() {
// Also should this be hidden for pages? That will require some CSS tweaks
let time_text = "Posted"
if (this.props.is_page) {
time_text = "Updated"
}
return (