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

84 lines
2.1 KiB
TypeScript
Raw Normal View History

2021-02-28 02:21:28 +01:00
import React, { ReactElement } from 'react'
2023-01-29 22:58:19 +01:00
import { PageProps, graphql } from 'gatsby'
2022-11-19 16:09:13 +01:00
import HeadMeta from '../components/atoms/HeadMeta'
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
<>
<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
)
}
2022-11-19 16:09:13 +01:00
export function Head() {
return <HeadMeta slug="/" />
}
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
}
}
}
}
}
`