Skip to content

Commit eb14d4f

Browse files
author
Sergei Orlow
committed
✨ Add Top Tags section
1 parent 07f0070 commit eb14d4f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/pages/index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Layout } from '../layout'
77
import { PostPreview } from '../components/post-preview'
88
import Seo from '../components/seo'
99
import SubscriptionForm from '../components/subscription-form'
10+
import { Labels } from '../components/labels'
1011

1112
const List = styled.ul`
1213
list-style: none;
@@ -17,7 +18,16 @@ const Index = ({ data }) => (
1718
<Layout>
1819
<Seo />
1920
<Centralise>
20-
<h1 itemProp='name headline'>Recent Posts</h1>
21+
<div>
22+
<h2>Top Tags</h2>
23+
<Labels
24+
from={data.tagsGroup.group
25+
.sort((a, b) => b.totalCount - a.totalCount)
26+
.slice(0, 5)
27+
.map((tag) => tag.fieldValue)}
28+
/>
29+
</div>
30+
<h2 itemProp='name headline'>Recent Posts</h2>
2131
<List itemScope itemType='https://schema.org/ItemList'>
2232
{data.allMarkdownRemark.edges.map(({ node }, i) => (
2333
<li
@@ -56,5 +66,11 @@ export const query = graphql`
5666
}
5767
}
5868
}
69+
tagsGroup: allMarkdownRemark {
70+
group(field: frontmatter___tags) {
71+
fieldValue
72+
totalCount
73+
}
74+
}
5975
}
6076
`

0 commit comments

Comments
 (0)