|
19 | 19 | } |
20 | 20 | } |
21 | 21 |
|
22 | | - const response = await fetch('https://api.patreon.com/platform/users?filter[patreon_url]=https://www.patreon.com/MonoGame'); |
23 | | - const data = await response.json(); |
24 | | - |
25 | | - if(data.included && data.included.length > 0) { |
26 | | - const attributes = data.included[0].attributes; |
27 | | - const patron_count = attributes.patron_count; |
28 | | - let pledge_sum = attributes.pledge_sum; |
29 | | - |
30 | | - // HACK: Add in a few things from other services. |
31 | | - { |
32 | | - // Re-logic's monthly donation. |
33 | | - pledge_sum += 100000; |
34 | | - |
35 | | - // TODO: Get GitHub sponsors and merge them with this. |
36 | | - // Requires a personal access token to do so. |
37 | | - } |
38 | | - |
39 | | - const total_patrons = document.getElementById('total-patrons'); |
40 | | - countUp(total_patrons, patron_count, (x) => x); |
41 | | - |
42 | | - const per_month = document.getElementById('per-month'); |
43 | | - countUp(per_month, pledge_sum, (x) => (x / 100).toLocaleString('en-US', { |
44 | | - style: 'currency', |
45 | | - currency: attributes.pledge_sum_currency |
46 | | - })); |
47 | | - } |
| 22 | + // We have the GH Sponsors data updated from a workflow. |
| 23 | + let patron_count = gh_sponsor_count; |
| 24 | + let pledge_sum = gh_sponsor_sum; |
| 25 | + |
| 26 | + // Fetch Patreon data. |
| 27 | + { |
| 28 | + const response = await fetch('https://api.patreon.com/platform/users?filter[patreon_url]=https://www.patreon.com/MonoGame'); |
| 29 | + const data = await response.json(); |
| 30 | + if(data.included && data.included.length > 0) |
| 31 | + { |
| 32 | + const attributes = data.included[0].attributes; |
| 33 | + patron_count += attributes.patron_count; |
| 34 | + pledge_sum += attributes.pledge_sum; |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + // Re-logic's fixed monthly donation. |
| 39 | + pledge_sum += 100000; |
| 40 | + |
| 41 | + // Animate the results. |
| 42 | + const total_patrons = document.getElementById('total-patrons'); |
| 43 | + countUp(total_patrons, patron_count, (x) => x); |
| 44 | + |
| 45 | + const per_month = document.getElementById('per-month'); |
| 46 | + countUp(per_month, pledge_sum, (x) => (x / 100).toLocaleString('en-US', { |
| 47 | + style: 'currency', |
| 48 | + currency: 'USD' |
| 49 | + })); |
48 | 50 |
|
49 | 51 | })(); |
0 commit comments