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