1
|
|
|
import { NewsOverviewCategoryResponsePropsApi, NewsOverviewQuery } from "../Types/Article" |
2
|
|
|
import { CardTeaser } from "../components/Card" |
3
|
|
|
import { Seo } from "../components/Seo" |
4
|
|
|
import Layout from "../layouts" |
5
|
|
|
import "./NewsOverview.scss" |
6
|
|
|
import { graphql, Link, useStaticQuery } from "gatsby" |
7
|
|
|
import React from "react" |
8
|
|
|
|
9
|
|
|
const NewsOverviewPage = ({ pageContext }: NewsOverviewQuery) => { |
10
|
|
|
const { group, index, first, last, pathPrefix } = pageContext |
11
|
|
|
const { categoryTags }: NewsOverviewCategoryResponsePropsApi = useStaticQuery(graphql` |
12
|
|
|
query { |
13
|
|
|
categoryTags: allTaxonomyTermCategory( |
14
|
|
|
sort: { fields: name, order: ASC } |
15
|
|
|
filter: { |
16
|
|
|
status: { eq: true } |
17
|
|
|
relationships: { node__article: { elemMatch: { drupal_internal__nid: { gte: 1 } } } } |
18
|
|
|
} |
19
|
|
|
) { |
20
|
|
|
edges { |
21
|
|
|
node { |
22
|
|
|
path { |
23
|
|
|
alias |
24
|
|
|
} |
25
|
|
|
name |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
`) |
31
|
|
|
|
32
|
|
|
const previousUrl = index - 1 === 1 ? `/${pathPrefix}/` : `/${pathPrefix}/${(index - 1).toString()}` |
33
|
|
|
const nextUrl = `/${pathPrefix}/${(index + 1).toString()}` |
34
|
|
|
|
35
|
|
|
return ( |
36
|
|
|
<Layout> |
37
|
|
|
<header className="page_header__wrapper"> |
38
|
|
|
<div className="page_header"> |
39
|
|
|
<h1>Nieuwsarchief KCVV Elewijt</h1> |
40
|
|
|
</div> |
41
|
|
|
</header> |
42
|
|
|
|
43
|
|
|
<div className="newsoverview__wrapper page__wrapper"> |
44
|
|
|
<section className={`archive__filter_wrapper`}> |
45
|
|
|
<h5>Filter op categorie</h5> |
46
|
|
|
<section className={`archive__filter_filters`}> |
47
|
|
|
<Link to={`/news/`}>Alles</Link> |
48
|
|
|
{categoryTags.edges.map(({ node }) => ( |
49
|
|
|
<Link to={node.path.alias} key={node.name}> |
50
|
|
|
{node.name} |
51
|
|
|
</Link> |
52
|
|
|
))} |
53
|
|
|
</section> |
54
|
|
|
</section> |
55
|
|
|
<main className={`newsoverview__content__wrapper newsoverview__content__wrapper--archive`}> |
56
|
|
|
{group.map(({ node }) => ( |
57
|
|
|
<CardTeaser |
58
|
|
|
key={node.id} |
59
|
|
|
title={node.title} |
60
|
|
|
picture={ |
61
|
|
|
node.relationships.field_media_article_image.relationships.field_media_image.localFile.childImageSharp |
62
|
|
|
.gatsbyImageData |
63
|
|
|
} |
64
|
|
|
link={node.path.alias} |
65
|
|
|
tags={node.relationships?.field_tags} |
66
|
|
|
createTime={node.created} |
67
|
|
|
/> |
68
|
|
|
))} |
69
|
|
|
</main> |
70
|
|
|
<footer className={`archive__navigation_wrapper cell`}> |
71
|
|
|
<div className={`archive__navigation--previous`}> |
72
|
|
|
<NavLink test={first} url={previousUrl} text="« Vorige" /> |
73
|
|
|
</div> |
74
|
|
|
<div className={`archive__navigation--next`}> |
75
|
|
|
<NavLink test={last} url={nextUrl} text="Volgende »" /> |
76
|
|
|
</div> |
77
|
|
|
</footer> |
78
|
|
|
</div> |
79
|
|
|
</Layout> |
80
|
|
|
) |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
export default NewsOverviewPage |
84
|
|
|
|
85
|
|
|
export const Head = ({ pageContext }: NewsOverviewQuery) => { |
86
|
|
|
const { index, pathPrefix } = pageContext |
87
|
|
|
const pathName = `/${pathPrefix}/${index}` |
88
|
|
|
return <Seo title={`Nieuwsarchief - Pagina ${index}`} path={pathName} /> |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
interface NavLinkProps { |
92
|
|
|
test: boolean |
93
|
|
|
url: string |
94
|
|
|
text: string |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
const NavLink = ({ test, url, text }: NavLinkProps) => { |
98
|
|
|
if (!test) { |
99
|
|
|
return ( |
100
|
|
|
<Link to={url} className="rich-link-center"> |
101
|
|
|
{text} |
102
|
|
|
</Link> |
103
|
|
|
) |
104
|
|
|
} else { |
105
|
|
|
return <span>{text}</span> |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|