Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Static Site With Built Components #35

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/components/About.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";

const imageDefault = "https://via.placeholder.com/215"

function About ({image = imageDefault, about}){
return (
<aside>
<img src={image} alt="blog logo"></img>
<p>{about}</p>
</aside>
)
}

export default About
10 changes: 6 additions & 4 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from "react";
import blogData from "../data/blog";

console.log(blogData);
import Header from "./Header.js"
import About from "./About.js"
import ArticleList from "./ArticleList";

function App() {
return (
<div className="App">
You're on your own from here! Follow the deliverables; test things out in
the browser as you write your code; and good luck!
<Header name={blogData.name} />
<About image={blogData.image} about={blogData.about} />
<ArticleList posts={blogData.posts} />
</div>
);
}
Expand Down
13 changes: 13 additions & 0 deletions src/components/Article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from "react";

function Article ({title, date = "January 1, 1970", preview}) {
return (
<article>
<h3>{title}</h3>
<small>{date}</small>
<p>{preview}</p>
</article>
)
}

export default Article
22 changes: 22 additions & 0 deletions src/components/ArticleList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import Article from "./Article";

function ArticleList ({posts}) {
console.log(posts)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(posts)

const articles = posts.map((post) => {
return (
<Article
key={post.id}
title={post.title}
preview={post.preview}
date={post.date}
/>
)
})

return (
<main>{articles}</main>
)
}

export default ArticleList
11 changes: 11 additions & 0 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

function Header ({name}) {
return (
<header>
<h1>{name}</h1>
</header>
)
}

export default Header