1
0
Fork 0
blog/src/pages/tags.tsx

57 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-11-08 15:31:43 +01:00
import React from 'react'
import { graphql } from 'gatsby'
import Page from '../templates/Page'
import Tag from '../components/atoms/Tag'
import styles from './tags.module.scss'
const page = {
frontmatter: {
title: 'Tags',
description: 'All the tags being used.'
}
}
interface Tag {
fieldValue: string
totalCount: number
}
interface TagsPageProps {
data: {
allMarkdownRemark: { group: Tag[] }
}
location: Location
}
const TagsPage = ({ data, location }: TagsPageProps) => (
<Page title={page.frontmatter.title} location={location} post={page}>
<ul className={styles.tags}>
{data.allMarkdownRemark.group
.sort((a, b) => b.totalCount - a.totalCount)
.map((tag: Tag) => (
<li key={tag.fieldValue}>
<Tag
name={tag.fieldValue}
url={`/tags/${tag.fieldValue}/`}
count={tag.totalCount}
style={{ fontSize: `${100 + tag.totalCount * 2}%` }}
/>
</li>
))}
</ul>
</Page>
)
export default TagsPage
export const tagsPageQuery = graphql`
query {
allMarkdownRemark {
group(field: frontmatter___tags) {
fieldValue
totalCount
}
}
}
`