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

48 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-05-22 14:38:19 +02:00
import React, { ReactElement } from 'react'
2023-01-29 22:58:19 +01:00
import { PageProps, graphql } from 'gatsby'
import HeadMeta, { HeadMetaProps } from '../components/atoms/HeadMeta'
2019-11-08 15:31:43 +01:00
import Tag from '../components/atoms/Tag'
2023-01-29 22:58:19 +01:00
import Page from '../components/templates/Page'
import * as styles from './tags.module.css'
2019-11-08 15:31:43 +01:00
2022-11-19 16:09:13 +01:00
const meta: Partial<HeadMetaProps> = {
title: 'Tags',
description: 'All the tags being used.'
2019-11-08 15:31:43 +01:00
}
2022-11-19 16:09:13 +01:00
const TagsPage = ({ data }: PageProps<Queries.TagsPageQuery>): ReactElement => (
<Page title={meta.title}>
<ul className={styles.tags}>
{Array.from(data.allMarkdownRemark.group)
2019-11-08 15:31:43 +01:00
.sort((a, b) => b.totalCount - a.totalCount)
.map((tag) => (
2019-11-08 15:31:43 +01:00
<li key={tag.fieldValue}>
<Tag
name={tag.fieldValue || ''}
2020-07-11 11:42:37 +02:00
url={`/archive/${tag.fieldValue}/`}
2019-11-08 15:31:43 +01:00
count={tag.totalCount}
style={{ fontSize: `${100 + tag.totalCount * 2}%` }}
/>
</li>
))}
</ul>
</Page>
)
export default TagsPage
2022-11-19 16:09:13 +01:00
export function Head(props: PageProps) {
return <HeadMeta {...meta} slug={props.location.pathname} />
}
2019-11-08 15:31:43 +01:00
export const tagsPageQuery = graphql`
query TagsPage {
2019-11-08 15:31:43 +01:00
allMarkdownRemark {
group(field: { frontmatter: { tags: SELECT } }) {
2019-11-08 15:31:43 +01:00
fieldValue
totalCount
}
}
}
`