1
1
import React from 'react'
2
2
import PropTypes from 'prop-types'
3
- import { graphql } from 'gatsby'
3
+ import { graphql , Link } from 'gatsby'
4
4
import Img from 'gatsby-image'
5
5
import { media } from '@/theme'
6
6
import MainLayout from '@/components/MainLayout'
7
- import TitledCopy from '@/components/TitledCopy'
8
7
import { SupportWidget } from '@/components/Shared'
9
8
9
+ const calcTotalAmount = x =>
10
+ x . edges . reduce ( ( acc , val ) => acc + val . node . amount , 0 )
11
+
10
12
const DonatePage = props => {
11
- const { page } = props . data
13
+ const { page, contributions } = props . data
12
14
return (
13
15
< MainLayout { ...props } >
14
16
< div
@@ -30,22 +32,33 @@ const DonatePage = props => {
30
32
margin: 2rem auto 0;
31
33
${ media . greaterThan ( `medium` ) } {
32
34
margin-right: 1rem;
33
- max-width: 60 %;
35
+ max-width: 56 %;
34
36
}
35
37
` }
36
38
/>
37
39
38
40
< div >
39
41
< 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
+ m²
61
+ </ div >
49
62
</ div >
50
63
</ div >
51
64
@@ -68,6 +81,7 @@ const DonatePage = props => {
68
81
DonatePage . propTypes = {
69
82
data : PropTypes . shape ( {
70
83
page : PropTypes . object ,
84
+ contributions : PropTypes . object ,
71
85
SiteMeta : PropTypes . object ,
72
86
SupportWidget : PropTypes . object ,
73
87
} ) ,
@@ -76,7 +90,7 @@ DonatePage.propTypes = {
76
90
export default DonatePage
77
91
78
92
export const query = graphql `
79
- query($lang: String!, $slug : String!) {
93
+ query($lang: String!, $url : String!) {
80
94
...siteData
81
95
...SiteMeta
82
96
...languages
@@ -86,7 +100,7 @@ export const query = graphql`
86
100
...Accounts
87
101
...SupportWidget
88
102
89
- page: javascriptFrontmatter(frontmatter : { slug : { eq: $slug } }) {
103
+ page: javascriptFrontmatter(fields : { url : { eq: $url } }) {
90
104
...PageTranslations
91
105
fields {
92
106
url
@@ -111,5 +125,13 @@ export const query = graphql`
111
125
}
112
126
}
113
127
}
128
+
129
+ contributions: allPayPalJson {
130
+ edges {
131
+ node {
132
+ amount
133
+ }
134
+ }
135
+ }
114
136
}
115
137
`
0 commit comments