Coder Social home page Coder Social logo

frontity / step-by-step-tutorial Goto Github PK

View Code? Open in Web Editor NEW
15.0 1.0 10.0 6.04 MB

Step-by-step tutorial designed to help you learn website development with Frontity.

Home Page: https://tutorial.frontity.org/

License: Apache License 2.0

frontity tutorial react wordpress

step-by-step-tutorial's Issues

Inconsistency in the evolution of the code in post.js

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

Some <Link> use "href" attribute instead of "link"

The first time the <Link> component is introduced in the tutorial in the Use the component they're properly using the link attribute

 <nav>
        <Link link="/">Home</Link>
        <br />
        <Link link="/page/2">More posts</Link>
        <br />
        <Link link="/about-us">About Us</Link>
      </nav>

But from the Styled components there are some links that use the href attribute that makes these links fail

 <nav>
    <Link href="/">Home</Link>
    <Link href="/page/2">More posts</Link>
    <Link link="/about-us">About Us</Link>
  </nav>

ServerError: post type from endpoints "posts,pages,media" with slug "hello-frontity" not found

In the Step "Creating a Custom Theme > Connect the component to the state"
When accessing http://localhost:3000/hello-frontity
The terminal returns an error

ServerError: post type from endpoints "posts,pages,media" with slug "hello-frontity" not found
    at Object.eval (webpack-internal:///./node_modules/@frontity/wp-source/src/libraries/handlers/postType.ts:37:21)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at eval (webpack-internal:///./node_modules/@frontity/wp-source/src/actions.ts:24:1) {
  status: 404,
  statusText: 'post type from endpoints "posts,pages,media" with slug "hello-frontity" not found'
}

I suggest to change that URL example for "http://localhost:3000/about-us/" that is an URL that actually exists in https://test.frontity.org/about-us/

Add an overview of Frontity docs structure in the HomePage

Something like what we have at https://docs.frontity.org/

👋 Hi! Welcome to Frontity, and to our.....

Our documentation is distributed across three separate sites:
- docs.frontity.org - Introduction, concepts and guides
- api.frontity.org - API Reference
- tutorial.frontity.org - Step by Step guide

This site (XXXX.frontity.org) is where you will find ....

The "Using a single component for both posts and pages" subsection adds inconsistency to the tutorial

I would remove the subsection Using a single component for both posts and pages because I think it creates some confusion about how the file /packages/my-first-theme/src/components/post.js should be

The /packages/my-first-theme/src/components/index.js is also affected depending on the way to manage posts & pages

So, for the sake of simplicity I would just stick the tutorial to using different components (<Page> & <Post>) to manage these different types of content

This would make no need of the warning info at the end of Display posts and pages separately and continuing the code from Styling the post info would be easier to follow

Snippets Could Be Standardized

The snippets in this tutorial seem a bit inconsistent and confusing. I guess i'm just putting this up to see if it's just my style, or if others are a bit confused by the snippets.

Sometimes the imports in their entirety are shown, sometimes not.

Sometimes ellipses are used, sometimes not.

I dunno, anyone else little bit thrown off?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.