-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTechTags.js
More file actions
49 lines (41 loc) · 1.16 KB
/
TechTags.js
File metadata and controls
49 lines (41 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from "react"
import TechTag from "../tags/TechTag"
const TechTags = (props) => {
const labels = props.labels
const posts = props.posts
const labelCount = labels.map(label => {
let count = 0;
posts.forEach(post => {
if (post.node.frontmatter.tags.includes(label.tag)) {
count = count + 1
}
})
return [label.tag, count]
})
const categories = labelCount.filter(label => {
return label[1] > 0
})
const tags = categories.map(category => {
return category[0]
})
const getTechTags = (tags) => {
const techTags = []
tags.forEach((tag, i) => {
labels.forEach((label) => {
if (tag === label.tag) {
techTags.push(<TechTag key={i} tag={label.tag} tech={label.tech} name={label.name} size={label.size} color={label.color} />)
}
})
})
return techTags
}
return (
<>
<h4>Tech Topics</h4>
<div className="d-block">
{getTechTags(tags)}
</div>
</>
)
}
export default TechTags