1
|
|
|
import { graphql, Link } from "gatsby" |
2
|
|
|
import { GatsbyImage, getSrc, StaticImage } from "gatsby-plugin-image" |
3
|
|
|
import React from "react" |
4
|
|
|
import { Seo } from "../components/Seo" |
5
|
|
|
import Layout from "../layouts" |
6
|
|
|
import { StaffQuery } from "../Types/Player" |
7
|
|
|
import "./Player.scss" |
8
|
|
|
|
9
|
|
|
const Staff = ({ data: { nodeStaff } }: StaffQuery) => { |
10
|
|
|
const cleanBody = |
11
|
|
|
(nodeStaff?.body && |
12
|
|
|
nodeStaff?.body?.processed?.replaceAll(`/sites/default/`, `${process.env.GATSBY_API_DOMAIN}/sites/default/`)) || |
13
|
|
|
`` |
14
|
|
|
const picture = nodeStaff?.relationships?.field_image?.localFile?.childImageSharp?.gatsbyImageData && ( |
15
|
|
|
<GatsbyImage |
16
|
|
|
image={nodeStaff?.relationships?.field_image?.localFile?.childImageSharp?.gatsbyImageData} |
17
|
|
|
alt={`${nodeStaff.field_firstname} ${nodeStaff.field_lastname}`} |
18
|
|
|
/> |
19
|
|
|
) |
20
|
|
|
|
21
|
|
|
return ( |
22
|
|
|
<Layout> |
23
|
|
|
<div className="player__details__top"> |
24
|
|
|
<header className="page_header__wrapper player__header__wrapper"> |
25
|
|
|
<div className="page_header page_header--max player__header"> |
26
|
|
|
<div className="player__header__inner"> |
27
|
|
|
<div className="player__header__inner_text"> |
28
|
|
|
<h1 className={`player__detail__name`}> |
29
|
|
|
<span className={`player__detail__name_first`}>{nodeStaff.field_firstname}</span> |
30
|
|
|
<span className={`player__detail__name_last`}>{nodeStaff.field_lastname}</span> |
31
|
|
|
</h1> |
32
|
|
|
<p |
33
|
|
|
className={`player__detail__shirt_number`} |
34
|
|
|
aria-hidden="true" |
35
|
|
|
title={nodeStaff.field_position_staff || ``} |
36
|
|
|
> |
37
|
|
|
{nodeStaff?.field_position_short || ``} |
38
|
|
|
</p> |
39
|
|
|
</div> |
40
|
|
|
<div className="player__header__inner_image"> |
41
|
|
|
{picture || ( |
42
|
|
|
<StaticImage |
43
|
|
|
src={`../images/kcvv-player-bg.png`} |
44
|
|
|
alt={`${nodeStaff.field_firstname} ${nodeStaff.field_lastname}`} |
45
|
|
|
placeholder={`tracedSVG`} |
46
|
|
|
/> |
47
|
|
|
)} |
48
|
|
|
</div> |
49
|
|
|
</div> |
50
|
|
|
</div> |
51
|
|
|
</header> |
52
|
|
|
</div> |
53
|
|
|
<main className="player__details__middle"> |
54
|
|
|
{renderMeta(nodeStaff)} |
55
|
|
|
{cleanBody && <div dangerouslySetInnerHTML={{ __html: cleanBody }} className="player__details__intro" />} |
56
|
|
|
</main> |
57
|
|
|
{/* <PlayerDetail player={nodePlayer} /> */} |
58
|
|
|
</Layout> |
59
|
|
|
) |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
export const Head = ({ data: { nodeStaff } }: StaffQuery) => { |
63
|
|
|
const pathUrl = nodeStaff?.path?.alias || `` |
64
|
|
|
const heroImage = nodeStaff?.relationships?.field_image?.localFile?.childImageSharp?.gatsbyImageData |
65
|
|
|
|
66
|
|
|
const ogImage = heroImage && { |
67
|
|
|
src: getSrc(heroImage) || ``, |
68
|
|
|
width: heroImage.width, |
69
|
|
|
height: heroImage.height, |
70
|
|
|
} |
71
|
|
|
return ( |
72
|
|
|
<Seo |
73
|
|
|
title={nodeStaff?.title || ``} |
74
|
|
|
path={pathUrl} |
75
|
|
|
image={ogImage} |
76
|
|
|
description={nodeStaff?.title + ` - Staflid van KCVV Elewijt`} |
77
|
|
|
/> |
78
|
|
|
) |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
export default Staff |
82
|
|
|
|
83
|
|
|
const renderMeta = (nodeStaff: Queries.node__staff) => { |
84
|
|
|
return ( |
85
|
|
|
<div className="player__details__meta"> |
86
|
|
|
<div className="player__details__meta__item player__details__meta__item--birthdate"> |
87
|
|
|
<span className="player__details__meta__item__label">Geboortedatum</span> |
88
|
|
|
<span className="player__details__meta__item__data">{nodeStaff.field_birth_date || `Onbekend`}</span> |
89
|
|
|
</div> |
90
|
|
|
<div className="player__details__meta__item player__details__meta__item--position"> |
91
|
|
|
<span className="player__details__meta__item__data">{nodeStaff.field_position_staff}</span> |
92
|
|
|
<span className="player__details__meta__item__label"> |
93
|
|
|
{nodeStaff?.relationships?.node__team && ( |
94
|
|
|
<Link to={nodeStaff?.relationships?.node__team[0]?.path?.alias || ``}> |
95
|
|
|
{nodeStaff?.relationships?.node__team[0]?.title} |
96
|
|
|
</Link> |
97
|
|
|
)} |
98
|
|
|
</span> |
99
|
|
|
</div> |
100
|
|
|
<div className="player__details__meta__item player__details__meta__item--joindate"> |
101
|
|
|
<span className="player__details__meta__item__label">Aangesloten bij KCVV sinds</span> |
102
|
|
|
<span className="player__details__meta__item__data">{nodeStaff.field_join_date || `Onbekend`}</span> |
103
|
|
|
</div> |
104
|
|
|
</div> |
105
|
|
|
) |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
export const query = graphql` |
109
|
|
|
query StaffQuery($slug: String!) { |
110
|
|
|
nodeStaff(path: { alias: { eq: $slug } }) { |
111
|
|
|
path { |
112
|
|
|
alias |
113
|
|
|
} |
114
|
|
|
body { |
115
|
|
|
processed |
116
|
|
|
} |
117
|
|
|
title |
118
|
|
|
field_join_date |
119
|
|
|
field_lastname |
120
|
|
|
field_position_staff |
121
|
|
|
field_firstname |
122
|
|
|
field_birth_date |
123
|
|
|
field_position_short |
124
|
|
|
relationships { |
125
|
|
|
node__article { |
126
|
|
|
title |
127
|
|
|
path { |
128
|
|
|
alias |
129
|
|
|
} |
130
|
|
|
timestamp: created(formatString: "x") |
131
|
|
|
relationships { |
132
|
|
|
field_media_article_image { |
133
|
|
|
...ArticleImage |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
node__team { |
138
|
|
|
title |
139
|
|
|
relationships { |
140
|
|
|
field_media_article_image { |
141
|
|
|
...ArticleImage |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
path { |
145
|
|
|
alias |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
field_image { |
149
|
|
|
localFile { |
150
|
|
|
...KCVVFixedPlayerTeaser |
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
` |
157
|
|
|
|