Localize date in single post template

This commit is contained in:
ponas committed 2019-05-04 00:29:07 +02:00
1 parent fd29279401
commit 9fc324ded9
1 file changed
+8 -3
+8 -3
View File
@@ -5,6 +5,10 @@ import { graphql, Link } from 'gatsby'
import Layout from '../components/Layout' import Layout from '../components/Layout'
import Img from 'gatsby-image' import Img from 'gatsby-image'
import moment from 'moment'
import 'moment/locale/nb'
moment.locale('nb')
export const BlogPostTemplate = ({ export const BlogPostTemplate = ({
content, content,
categories, categories,
@@ -26,7 +30,8 @@ export const BlogPostTemplate = ({
<h1>{title}</h1> <h1>{title}</h1>
<div className="post-meta"> <div className="post-meta">
<p> <p>
{date} av <Link to={`/author/${author.slug}`}>{author.name}</Link> {moment(date).format('dddd D. MMMM YYYY')} av{' '}
<Link to={`/author/${author.slug}`}>{author.name}</Link>
</p> </p>
</div> </div>
</div> </div>
@@ -88,7 +93,7 @@ export const pageQuery = graphql`
id id
slug slug
content content
date(formatString: "MMMM DD, YYYY") date
title title
} }
query BlogPostByID($id: String!) { query BlogPostByID($id: String!) {
@@ -97,7 +102,7 @@ export const pageQuery = graphql`
title title
slug slug
content content
date(formatString: "MMMM DD, YYYY") date
categories { categories {
name name
slug slug