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