1
|
|
|
import React from "react" |
2
|
|
|
import Link from "gatsby-link" |
3
|
|
|
import Layout from "../layouts/index" |
4
|
|
|
import SEO from "../components/seo" |
5
|
|
|
|
6
|
|
|
import { graphql } from "gatsby" |
7
|
|
|
|
8
|
|
|
import "./newsoverview.scss" |
9
|
|
|
import { NewsItemCardRatio } from "../components/news-item" |
10
|
|
|
|
11
|
|
|
const NavLink = ({ test, url, text }) => { |
12
|
|
|
if (!test) { |
13
|
|
|
return <Link to={url}>{text}</Link> |
14
|
|
|
} else { |
15
|
|
|
return <span>{text}</span> |
16
|
|
|
} |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
const NewsOverviewPage = ({ pageContext, data }) => { |
20
|
|
|
const { group, index, first, last, pathPrefix } = pageContext |
21
|
|
|
let previousUrl = index - 1 === 1 ? "/" : (index - 1).toString() |
22
|
|
|
let nextUrl = (index + 1).toString() |
23
|
|
|
if (pathPrefix) { |
24
|
|
|
previousUrl = `${pathPrefix}/${previousUrl}` |
25
|
|
|
nextUrl = `${pathPrefix}/${nextUrl}` |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
const { categoryTags } = data |
29
|
|
|
|
30
|
|
|
const pathName = `/${pathPrefix}/${index}` |
31
|
|
|
|
32
|
|
|
return ( |
33
|
|
|
<Layout> |
34
|
|
|
<SEO |
35
|
|
|
lang="nl-BE" |
36
|
|
|
title={`Nieuwsarchief - Pagina ${index}`} |
37
|
|
|
path={pathName} |
38
|
|
|
/> |
39
|
|
|
|
40
|
|
|
<div className="grid-container site-content"> |
41
|
|
|
<div className="grid-x grid-margin-x"> |
42
|
|
|
<h2>Nieuwsarchief KCVV Elewijt</h2> |
43
|
|
|
<header className={"archive__filter_wrapper"}> |
44
|
|
|
<h5>Filter op categorie</h5> |
45
|
|
|
<section className={"archive__filter_filters"}> |
46
|
|
|
<Link to={"/news/"} className={"btn btn--small"}> |
47
|
|
|
Alles |
48
|
|
|
</Link> |
49
|
|
|
{categoryTags.edges.map(({ node, i }) => ( |
50
|
|
|
<Link to={node.path.alias} className={"btn btn--small"} key={i}> |
51
|
|
|
{node.name} |
52
|
|
|
</Link> |
53
|
|
|
))} |
54
|
|
|
</section> |
55
|
|
|
</header> |
56
|
|
|
|
57
|
|
|
<main |
58
|
|
|
className={"news_overview__wrapper news_overview__wrapper--archive"} |
59
|
|
|
> |
60
|
|
|
{group.map(({ node, i }) => ( |
61
|
|
|
<NewsItemCardRatio node={node} teaser={false} key={i} /> |
62
|
|
|
))} |
63
|
|
|
</main> |
64
|
|
|
<footer className={"archive__navigation_wrapper cell"}> |
65
|
|
|
<div className={"archive__navigation--previous"}> |
66
|
|
|
<NavLink test={first} url={previousUrl} text="« Vorige" /> |
67
|
|
|
</div> |
68
|
|
|
<div className={"archive__navigation--next"}> |
69
|
|
|
<NavLink test={last} url={nextUrl} text="Volgende »" /> |
70
|
|
|
</div> |
71
|
|
|
</footer> |
72
|
|
|
</div> |
73
|
|
|
</div> |
74
|
|
|
</Layout> |
75
|
|
|
) |
76
|
|
|
} |
77
|
|
|
export default NewsOverviewPage |
78
|
|
|
|
79
|
|
|
export const query = graphql` |
80
|
|
|
query { |
81
|
|
|
categoryTags: allTaxonomyTermCategory( |
82
|
|
|
sort: { fields: name, order: ASC } |
83
|
|
|
filter: { |
84
|
|
|
status: { eq: true } |
85
|
|
|
relationships: { |
86
|
|
|
node__article: { elemMatch: { drupal_internal__nid: { gte: 1 } } } |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
) { |
90
|
|
|
edges { |
91
|
|
|
node { |
92
|
|
|
path { |
93
|
|
|
alias |
94
|
|
|
} |
95
|
|
|
name |
96
|
|
|
relationships { |
97
|
|
|
node__article { |
98
|
|
|
drupal_internal__nid |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
` |
106
|
|
|
|