Styling the post info

In this lesson we'll highlight the author and date info in our <Post> component so that they stand out from the rest of the post content.

Import styled into post.js and create and use a <PostInfo> component.

// File: /packages/my-first-theme/src/components/post.js

import React from "react"
import { connect, styled } from "frontity"
import dayjs from "dayjs"

const Post = ({ state }) => {
  const data = state.source.get(
  const post = state.source[data.type][]
  const author =[]

  const formattedDate = dayjs("DD MMMM YYYY")

  return (
          <strong>Posted: </strong>
          <strong>Author: </strong>
      <div dangerouslySetInnerHTML={{ __html: post.content.rendered }} />

export default connect(Post)

const PostInfo = styled.div`
  background-image: linear-gradient(to right, #f4f4f4, #fff);
  margin-bottom: 1em;
  padding: 0.5em;
  border-left: 4px solid lightseagreen;
  font-size: 0.8em;

  & > p {
    margin: 0;

Visit one of the posts now and the date and author info are pleasingly highlighted.

For reference, this is what your site should be looking like now:

Check you're on the right track by comparing your changes with the ones in this commit.

Last updated