Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 05f7e60

Browse files
committed
feat(Donations): link to ContributorsPage from DonatePage
1 parent 359d8dd commit 05f7e60

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

src/templates/DonatePage.js

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import { graphql } from 'gatsby'
3+
import { graphql, Link } from 'gatsby'
44
import Img from 'gatsby-image'
55
import { media } from '@/theme'
66
import MainLayout from '@/components/MainLayout'
7-
import TitledCopy from '@/components/TitledCopy'
87
import { SupportWidget } from '@/components/Shared'
98

9+
const calcTotalAmount = x =>
10+
x.edges.reduce((acc, val) => acc + val.node.amount, 0)
11+
1012
const DonatePage = props => {
11-
const { page } = props.data
13+
const { page, contributions } = props.data
1214
return (
1315
<MainLayout {...props}>
1416
<div
@@ -30,22 +32,33 @@ const DonatePage = props => {
3032
margin: 2rem auto 0;
3133
${media.greaterThan(`medium`)} {
3234
margin-right: 1rem;
33-
max-width: 60%;
35+
max-width: 56%;
3436
}
3537
`}
3638
/>
3739

3840
<div>
3941
<h1>{page.frontmatter.intro.title}</h1>
40-
{page.frontmatter.intro.text.map(x => (
41-
<div
42-
key={x}
43-
dangerouslySetInnerHTML={{ __html: x }}
44-
css={`
45-
line-height: 1.8rem;
46-
`}
47-
/>
48-
))}
42+
<div>
43+
{page.frontmatter.intro.text.map(x => (
44+
<div
45+
key={x}
46+
dangerouslySetInnerHTML={{ __html: x }}
47+
css={`
48+
line-height: 1.8rem;
49+
`}
50+
/>
51+
))}
52+
</div>
53+
<div
54+
css={`
55+
margin-top: 1rem;
56+
`}
57+
>
58+
Thanks to our <Link to="/en/contributors">supporters</Link> for
59+
donating {calcTotalAmount(contributions)}
60+
61+
</div>
4962
</div>
5063
</div>
5164

@@ -68,6 +81,7 @@ const DonatePage = props => {
6881
DonatePage.propTypes = {
6982
data: PropTypes.shape({
7083
page: PropTypes.object,
84+
contributions: PropTypes.object,
7185
SiteMeta: PropTypes.object,
7286
SupportWidget: PropTypes.object,
7387
}),
@@ -76,7 +90,7 @@ DonatePage.propTypes = {
7690
export default DonatePage
7791

7892
export const query = graphql`
79-
query($lang: String!, $slug: String!) {
93+
query($lang: String!, $url: String!) {
8094
...siteData
8195
...SiteMeta
8296
...languages
@@ -86,7 +100,7 @@ export const query = graphql`
86100
...Accounts
87101
...SupportWidget
88102
89-
page: javascriptFrontmatter(frontmatter: { slug: { eq: $slug } }) {
103+
page: javascriptFrontmatter(fields: { url: { eq: $url } }) {
90104
...PageTranslations
91105
fields {
92106
url
@@ -111,5 +125,13 @@ export const query = graphql`
111125
}
112126
}
113127
}
128+
129+
contributions: allPayPalJson {
130+
edges {
131+
node {
132+
amount
133+
}
134+
}
135+
}
114136
}
115137
`

0 commit comments

Comments
 (0)