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

81 lines
2.0 KiB
TypeScript
Raw Normal View History

2020-07-19 13:31:27 +02:00
import { graphql, PageProps } from 'gatsby'
2021-02-28 02:21:28 +01:00
import React, { ReactElement } from 'react'
import SEO from '../components/atoms/SEO'
2020-07-19 13:31:27 +02:00
import PostTeaser from '../components/molecules/PostTeaser'
2021-02-28 02:21:28 +01:00
import { PhotoThumb } from '../components/templates/Photos'
2020-07-19 13:31:27 +02:00
import PostMore from '../components/templates/Post/More'
import * as styles from './index.module.css'
2020-07-08 01:31:03 +02:00
export default function Home(
props: PageProps<Queries.HomePageQuery>
): ReactElement {
2020-07-08 01:31:03 +02:00
return (
2020-07-19 13:31:27 +02:00
<>
2021-02-28 02:21:28 +01:00
<SEO />
<section className={styles.section}>
<div className={styles.articles}>
{props.data.latestArticles.edges.slice(0, 2).map(({ node }) => (
<PostTeaser key={node.id} post={node} hideDate />
))}
2021-02-28 02:21:28 +01:00
</div>
<div className={`${styles.articles} ${styles.articlesLast}`}>
{props.data.latestArticles.edges.slice(2, 8).map(({ node }) => (
<PostTeaser key={node.id} post={node} hideDate />
))}
2020-07-19 13:31:27 +02:00
</div>
2021-02-28 23:13:31 +01:00
<PostMore to="/archive">All Articles</PostMore>
2020-07-19 13:31:27 +02:00
</section>
<section className={styles.section}>
<div className={styles.photos}>
{props.data.latestPhotos.edges.map(({ node }) => (
2021-02-28 04:09:56 +01:00
<PhotoThumb key={node.id} photo={node} />
))}
2020-07-19 13:31:27 +02:00
</div>
2021-02-28 23:13:31 +01:00
<PostMore to="/photos">All Photos</PostMore>
2020-07-19 13:31:27 +02:00
</section>
</>
2020-07-08 01:31:03 +02:00
)
}
export const homeQuery = graphql`
query HomePage {
2020-07-11 11:42:37 +02:00
latestArticles: allMarkdownRemark(
2021-02-28 04:50:05 +01:00
filter: { fields: { type: { ne: "photo" } } }
sort: { fields: { date: DESC } }
2021-03-04 22:53:35 +01:00
limit: 8
2020-07-08 01:31:03 +02:00
) {
edges {
node {
2020-07-19 13:31:27 +02:00
...PostTeaser
2020-07-08 01:31:03 +02:00
}
}
}
latestPhotos: allMarkdownRemark(
2021-02-28 04:50:05 +01:00
filter: { fields: { type: { eq: "photo" } } }
sort: { fields: { date: DESC } }
2021-02-28 02:21:28 +01:00
limit: 12
2020-07-08 01:31:03 +02:00
) {
edges {
node {
id
frontmatter {
title
image {
childImageSharp {
2020-07-19 13:31:27 +02:00
...PhotoFluidThumb
2020-07-08 01:31:03 +02:00
}
}
}
fields {
slug
2021-02-28 22:14:36 +01:00
type
2020-07-08 01:31:03 +02:00
}
}
}
}
}
`