After reading and trying everything I could, I decided to ask you for help! I just can't handle it...
I have blog posts that looks like this:
const posts = [
{
section: 'one',
title: [ 'third', 'fourth' ],
description: [ 'third', 'fourth' ],
slug: [ '/third', '/fourth' ]
},
{
section: 'three',
title: [ 'second' ],
description: [ 'second' ],
slug: [ '/second' ]
},
{
section: 'two',
title: [ 'first', 'fifth' ],
description: [ 'first', 'fifth' ],
slug: [ '/first', '/fifth' ]
}
]
The goal is to render them in a react component most likely and look like this:
<div>
<h2>one</h2>
<div>
<h3>third</h3>
<p>third</p>
<a href="#">/third</a>
</div>
<div>
<h3>fourth</h3>
<p>fourth</p>
<a href="#">/fourth</a>
</div>
</div>
Just proper render of posts inside corresponding sections. They will be more. This is just an example :)
The best I've come up with (and it doesn't work for me) is this:
{posts.map(x =>
<div key={x.section}>
<h2 key={x.section}>{x.section}</h2>
<div>
<h3>{x.title}</h3>
<p>{x.description}</p>
<a href={x.slug}>{x.slug}</a>
</div>
</div>
)}
Thank you in advance !!!