@@ -723,14 +746,14 @@ const CommunityPage: React.FC = () => { "RippleX’s Bug Bounty, part of Ripple's 1 Billion XRP pledge, strengthens XRP Ledger security and supports its ecosystem." )}
- { - translate("Use this program to report bugs in RippleX/rippled. Send a detailed report of a qualifying bug to ") - } - bugs@ripple.com - { - translate(" and use the ") - } - Public Key. + {translate( + "Use this program to report bugs in RippleX/rippled. Send a detailed report of a qualifying bug to " + )} + bugs@ripple.com + {translate(" and use the ")} + + Public Key. +
{translate( diff --git a/community/index.server.ts b/community/index.server.ts new file mode 100644 index 0000000000..fccb64fb30 --- /dev/null +++ b/community/index.server.ts @@ -0,0 +1,55 @@ +import type { PageRouteDetails } from '@redocly/realm/dist/server/plugins/types'; + +const cache = { + response: null, + expiresAt: 0, +}; + +async function fetchGql(query: string) { + return fetch(`https://graphql.contentful.com/content/v1/spaces/${process.env.PUBLIC_CONTENTFUL_SPACE_ID}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${process.env.CONTENTFUL_ACCESS_TOKEN}`, + }, + body: JSON.stringify({ query, variables: {}, operationName: 'GetEvents' }), + }).then(res => res.json()); +} + +const GET_EVENTS = ` + query GetEvents { + eventsCollection(order: startDate_ASC) { + items { + _id + name + description + category + link + location + startDate + endDate + community + image { + url + } + } + } + } +`; + + +export default async function getServerProps(route: PageRouteDetails, data: { props: any }) { + try { + if (cache.expiresAt <= Date.now()) { + cache.response = await fetchGql(GET_EVENTS); + cache.expiresAt = Date.now() + 1000 * 60 * 5; // 5 minutes naive cache + } + } catch (e) { + console.error('Failed to fetch events', e); + } + + return { + ...data.props, + contentfulEvents: cache.response, + }; +}