Skip to content

Commit

Permalink
added dummy posts, fixed post-item image and link
Browse files Browse the repository at this point in the history
  • Loading branch information
maxschwarzmueller committed Feb 17, 2021
1 parent 2932037 commit 171b5f1
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 9 deletions.
15 changes: 9 additions & 6 deletions components/home-page/featured-posts.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import PostsGrid from '../posts/posts-grid';
import classes from './featured-posts.module.css';

function FeaturedPosts() {
return <section className={classes.latest}>
<h2>Featured Posts</h2>

</section>
function FeaturedPosts(props) {
return (
<section className={classes.latest}>
<h2>Featured Posts</h2>
<PostsGrid posts={props.posts} />
</section>
);
}

export default FeaturedPosts;
export default FeaturedPosts;
11 changes: 9 additions & 2 deletions components/posts/post-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ function PostItem(props) {
});

const imagePath = `/images/posts/${slug}/${image}`;
const linkPath = `/posts/${slug}`;

return (
<li className={classes.post}>
<Link>
<Link href={linkPath}>
<a>
<div className={classes.image}>
<Image src={imagePath} alt={title} width={300} height={200} />
<Image
src={imagePath}
alt={title}
width={300}
height={200}
layout='responsive'
/>
</div>
<div className={classes.content}>
<h3>{title}</h3>
Expand Down
2 changes: 1 addition & 1 deletion components/posts/posts-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function PostsGrid(props) {
return (
<ul className={classes.grid}>
{posts.map((post) => (
<PostItem />
<PostItem key={post.slug} post={post} />
))}
</ul>
);
Expand Down
37 changes: 37 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
import { Fragment } from 'react';

import FeaturedPosts from '../components/home-page/featured-posts';
import Hero from '../components/home-page/hero';

const DUMMY_POSTS = [
{
slug: 'getting-started-with-nextjs',
title: 'Getting Started with NextJS',
image: 'getting-started-nextjs.png',
excerpt:
'NextJS is a the React framework for production - it makes building fullstack React apps and sites a breeze and ships with built-in SSR.',
date: '2022-02-10',
},
{
slug: 'getting-started-with-nextjs2',
title: 'Getting Started with NextJS',
image: 'getting-started-nextjs.png',
excerpt:
'NextJS is a the React framework for production - it makes building fullstack React apps and sites a breeze and ships with built-in SSR.',
date: '2022-02-10',
},
{
slug: 'getting-started-with-nextjs3',
title: 'Getting Started with NextJS',
image: 'getting-started-nextjs.png',
excerpt:
'NextJS is a the React framework for production - it makes building fullstack React apps and sites a breeze and ships with built-in SSR.',
date: '2022-02-10',
},
{
slug: 'getting-started-with-nextjs4',
title: 'Getting Started with NextJS',
image: 'getting-started-nextjs.png',
excerpt:
'NextJS is a the React framework for production - it makes building fullstack React apps and sites a breeze and ships with built-in SSR.',
date: '2022-02-10',
},
];

function HomePage() {
return (
<Fragment>
<Hero />
<FeaturedPosts posts={DUMMY_POSTS} />
</Fragment>
);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 171b5f1

Please sign in to comment.