import data from './data.json';
const URL = `${data.resources.map((el, index) => el.url)}`;
// data + "resources" + map(el, index) => element + "url"
data.json
{ "resources": [ { "title": "", "link": "", "url": "https://site.com/folder" } ] }
// add / at the end => /folder/ ===OR=== remove / from the end => /folder
{[...Array(n)].map((el, index) => (
<div key={index} className=''>{el}</div>
))}
// ...Array above can be used to repeat [0] element n times
// remove duplicates within a map function =>
<div class="tags">
{posts.map(post =>
[...new Set(post.frontmatter.tags)].map(tag => (
<Link
key={tag + `tag`}
to={`/tags/${kebabCase(tag)}/`}
className="tag is light"
>
{tag}
</Link>
))
)}
</div>
https://stackoverflow.com/questions/65512907/remove-duplicates-within-a-map-function
No comments:
Post a Comment