frontity / step-by-step-tutorial

Step-by-step tutorial designed to help you learn website development with Frontity.
https://tutorial.frontity.org/
Apache License 2.0
15 stars 10 forks source link

Inconsistency in the evolution of the code in post.js #8

Closed juanmaguitar closed 3 years ago

juanmaguitar commented 3 years ago

In the step Formatting the date the final code makes use of "dayjs" to format the date

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

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

  const formattedDate = dayjs(post.date).format("DD MMMM YYYY")

  return (
    <div>
      <h2>{post.title.rendered}</h2>
      <p>
        <strong>Posted: </strong>
        {formattedDate}
      </p>
      <p>
        <strong>Author: </strong>
        {author.name}
      </p>
      <div dangerouslySetInnerHTML={{ __html: post.content.rendered }} />
    </div>
  )
}

export default connect(Post)

but later, in the step Styling the post this date formatting piece of code does not appear

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

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

  return (
    <div>
      <h2>{post.title.rendered}</h2>
      <PostInfo>
        <p>
          <strong>Posted: </strong>
          {post.date}
        </p>
        <p>
          <strong>Author: </strong>
          {author.name}
        </p>
      </PostInfo>
      <div dangerouslySetInnerHTML={{ __html: post.content.rendered }} />
    </div>
  )
}

I think the code should evolve and continue from how it was in the latest section that modified it

mburridge commented 3 years ago

I think the code should evolve and continue from how it was in the latest section that modified it

You're right, of course!

The date formatting was added later, so I overlooked adding it to code snippets later on in the tutorial.

Fixed now.

juanmaguitar commented 3 years ago

@mburridge the import dayjs from "dayjs" is still missing from the code example in Styling the post info

mburridge commented 3 years ago

Oops, fixed now.