Passed
Pull Request — develop (#758)
by Kevin Van
10:04 queued 05:43
created

src/pages/index.tsx   A

Complexity

Total Complexity 3
Complexity/F 0

Size

Lines of Code 219
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 131
mnd 3
bc 3
fnc 0
dl 0
loc 219
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { graphql, Link, useStaticQuery } from "gatsby"
2
import { GatsbyImage, StaticImage } from "gatsby-plugin-image"
3
import React from "react"
4
5
import { HomepageResponsePropsApi } from "../Types/Gatsby"
6
import { AltTitle } from "../components/AltTitle"
7
import { CardTeaser, CardTVTeaser } from "../components/Card"
8
import { MatchesOverview } from "../components/MatchesOverview"
9
import MatchesSlider from "../components/MatchesSlider"
10
import { MatchesTabs } from "../components/MatchesTabs"
11
import { Seo } from "../components/Seo"
12
import Layout from "../layouts"
13
import "./index.scss"
14
15
const IndexPage = () => {
16
  const { articles, videos }: HomepageResponsePropsApi = useStaticQuery(graphql`
17
    query {
18
      articles: allNodeArticle(
19
        filter: { status: { eq: true }, promote: { eq: true } }
20
        sort: { fields: created, order: DESC }
21
        limit: 13
22
      ) {
23
        edges {
24
          node {
25
            id
26
            path {
27
              alias
28
            }
29
            created(formatString: "D/M/YYYY")
30
            changed(formatString: "D/M/YYYY")
31
            timestamp: changed(formatString: "x")
32
            title
33
            promote
34
            status
35
            field_featured
36
            body {
37
              value
38
              format
39
              processed
40
              summary
41
            }
42
            relationships {
43
              field_media_article_image {
44
                ...ArticleImage
45
              }
46
              field_tags {
47
                name
48
                path {
49
                  alias
50
                }
51
              }
52
            }
53
            internal {
54
              type
55
            }
56
          }
57
        }
58
      }
59
      videos: allNodeKcvvTv(
60
        filter: { status: { eq: true }, promote: { eq: true } }
61
        sort: { fields: created, order: DESC }
62
        limit: 3
63
      ) {
64
        edges {
65
          node {
66
            created(formatString: "D/M/YYYY")
67
            title
68
            timestamp: created(formatString: "x")
69
            relationships {
70
              field_media_article_image {
71
                ...ArticleImage
72
              }
73
            }
74
            field_website {
75
              uri
76
            }
77
          }
78
        }
79
      }
80
    }
81
  `)
82
83
  const featuredArticle = articles.edges.slice(0, 1)
84
85
  return (
86
    <Layout>
87
      <Seo
88
        title="Er is maar één plezante compagnie"
89
        description="Startpagina van stamnummer 00055: KCVV Elewijt."
90
        path={`/`}
91
      />
92
93
      <section className="frontpage__wrapper page__section">
94
        <div className="frontpage__hero">
95
          <div className="frontpage__hero__inner">
96
            <div className="frontpage__hero__container">
97
              <div className="frontpage__hero__content">
98
                <article className="frontpage__hero__article">
99
                  <Link to={featuredArticle[0].node.path.alias}>
100
                    <div className="frontpage__hero__article__inner">
101
                      <header>
102
                        <h3>
103
                          {featuredArticle[0].node.relationships?.field_tags.map(({ name }, i) => (
104
                            <span className={`tag__label`} key={`tag-${i}`}>
105
                              #{name}
106
                            </span>
107
                          ))}
108
                        </h3>
109
                        <div className="frontpage__hero__article__title">
110
                          <h2>{featuredArticle[0].node.title}</h2>
111
                        </div>
112
                      </header>
113
                      <GatsbyImage
114
                        image={
115
                          featuredArticle[0].node.relationships.field_media_article_image.relationships
116
                            .field_media_image.localFile.childImageSharp.gatsbyImageData
117
                        }
118
                        alt={featuredArticle[0].node.title}
119
                      />
120
                    </div>
121
                  </Link>
122
                </article>
123
                <div className="frontpage__hero__sponsor">
124
                  <StaticImage
125
                    src="../images/rbfa-lukaku.jpg"
126
                    alt="RBFA VVF - Romelu Lukaku"
127
                    placeholder="blurred"
128
                    layout="constrained"
129
                    aspectRatio={0.7063758}
130
                  />
131
                </div>
132
              </div>
133
            </div>
134
          </div>
135
        </div>
136
      </section>
137
138
      <section className="frontpage__matches_carousel page__section">
139
        <AltTitle title="matches" variant="black" />
140
        <main className="frontpage__matches_carousel__content">
141
          <article className="frontpage__matches_carousel_item frontpage__matches_carousel_item--a">
142
            <header className="frontpage__matches_carousel_item__header">A Team</header>
143
            <MatchesTabs teamId={1} />
144
          </article>
145
          <article className="frontpage__matches_carousel_item frontpage__matches_carousel_item--b">
146
            <header className="frontpage__matches_carousel_item__header">B Team</header>
147
            <MatchesTabs teamId={2} />
148
          </article>
149
        </main>
150
      </section>
151
152
      <section className="frontpage__main_content page__section">
153
        {articles.edges.slice(1, 5).map(({ node }) => (
154
          <CardTeaser
155
            key={node.id}
156
            title={node.title}
157
            picture={
158
              node.relationships.field_media_article_image.relationships.field_media_image.localFile.childImageSharp
159
                .gatsbyImageData
160
            }
161
            link={node.path.alias}
162
            tags={node.relationships?.field_tags}
163
            createTime={node.created}
164
          />
165
        ))}
166
167
        <article className="frontpage__main_content__youth">
168
          <header className="frontpage__matches_carousel_item__header">Wedstrijden</header>
169
          <MatchesOverview exclude={[`1`, `2`]} action="next" />
170
        </article>
171
      </section>
172
173
      <section className="frontpage__kcvvtv page__section">
174
        <AltTitle title="KCVV TV" variant="black" />
175
        <div className="frontpage__kcvvtv__content">
176
          {videos.edges.map(({ node }, i) => (
177
            <CardTVTeaser
178
              key={i}
179
              title={node.title}
180
              picture={
181
                node.relationships.field_media_article_image.relationships.field_media_image.localFile.childImageSharp
182
                  .gatsbyImageData
183
              }
184
              link={node.field_website.uri}
185
              createTime={node.created}
186
            />
187
          ))}
188
        </div>
189
      </section>
190
191
      <section className="frontpage__main_content page__section">
192
        {articles.edges.slice(5, 11).map(({ node }) => (
193
          <CardTeaser
194
            key={node.id}
195
            title={node.title}
196
            picture={
197
              node.relationships.field_media_article_image.relationships.field_media_image.localFile.childImageSharp
198
                .gatsbyImageData
199
            }
200
            link={node.path.alias}
201
            tags={node.relationships?.field_tags}
202
            createTime={node.created}
203
          />
204
        ))}
205
      </section>
206
      {/*
207
      <section className="frontpage__slogan page__section">
208
        <AltTitle title="Er is maar één plezante compagnie" variant="green" />
209
      </section> */}
210
211
      <section className="frontpage__matches_slider page__section">
212
        <MatchesSlider />
213
      </section>
214
    </Layout>
215
  )
216
}
217
218
export default IndexPage
219