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