mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-17 18:25:50 +00:00
adds new workflow logic and sync pages with contentful logix
This commit is contained in:
19
.github/workflows/update-contentful-data.yml
vendored
19
.github/workflows/update-contentful-data.yml
vendored
@@ -2,7 +2,7 @@ name: Update Contentful Data
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
types: [contentful_update] # This should match the event type sent by the webhook
|
types: [contentful_update]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-data:
|
update-data:
|
||||||
@@ -30,14 +30,29 @@ jobs:
|
|||||||
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_ACCESS_TOKEN }}
|
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_ACCESS_TOKEN }}
|
||||||
run: node scripts/fetchContentfulData.cjs
|
run: node scripts/fetchContentfulData.cjs
|
||||||
|
|
||||||
|
- name: Check for changes
|
||||||
|
id: check_changes
|
||||||
|
run: |
|
||||||
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
|
echo "no_changes=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "no_changes=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: No changes found
|
||||||
|
if: steps.check_changes.outputs.no_changes == 'true'
|
||||||
|
run: echo "No changes found. Skipping commit and pull request steps."
|
||||||
|
|
||||||
- name: Commit and Push Changes
|
- name: Commit and Push Changes
|
||||||
|
if: steps.check_changes.outputs.no_changes == 'false'
|
||||||
uses: stefanzweifel/git-auto-commit-action@v4
|
uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
with:
|
with:
|
||||||
commit_message: 'Update data from Contentful'
|
commit_message: 'Update data from Contentful'
|
||||||
branch: ${{ env.BRANCH_NAME }}
|
branch: ${{ env.BRANCH_NAME }}
|
||||||
create_branch: true
|
create_branch: true
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
|
if: steps.check_changes.outputs.no_changes == 'false'
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { useState, useMemo } from "react";
|
import { useState, useMemo } from "react";
|
||||||
import { useThemeHooks } from "@redocly/theme/core/hooks";
|
import { useThemeHooks } from "@redocly/theme/core/hooks";
|
||||||
import events from "../static/JSON/events.json";
|
import base_events from "../static/JSON/events.json";
|
||||||
|
import contentful_events from "../static/JSON/contentful-events.json";
|
||||||
|
|
||||||
|
const events = base_events.concat(contentful_events);
|
||||||
const moment = require("moment");
|
const moment = require("moment");
|
||||||
export const frontmatter = {
|
export const frontmatter = {
|
||||||
seo: {
|
seo: {
|
||||||
@@ -268,7 +270,7 @@ export default function Events() {
|
|||||||
<div
|
<div
|
||||||
className="event-card-header"
|
className="event-card-header"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(/img/events/${event.image})`,
|
backgroundImage: `url(${event.image.startsWith('https://') ? event.image : `/img/events/${event.image}`})`,
|
||||||
backgroundRepeat: "no-repeat",
|
backgroundRepeat: "no-repeat",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -402,7 +404,7 @@ export default function Events() {
|
|||||||
<div
|
<div
|
||||||
className="event-card-header"
|
className="event-card-header"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(/img/events/${event.image})`,
|
backgroundImage: `url(${event.image.startsWith('https://') ? event.image : `/img/events/${event.image}`})`,
|
||||||
backgroundRepeat: "no-repeat",
|
backgroundRepeat: "no-repeat",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { useThemeHooks } from "@redocly/theme/core/hooks";
|
import { useThemeHooks } from "@redocly/theme/core/hooks";
|
||||||
import allEvents from "../static/JSON/events.json";
|
import base_events from "../static/JSON/events.json";
|
||||||
|
import contentful_events from "../static/JSON/contentful-events.json";
|
||||||
import { Link } from "@redocly/theme/components/Link/Link";
|
import { Link } from "@redocly/theme/components/Link/Link";
|
||||||
|
const allEvents = base_events.concat(contentful_events)
|
||||||
const findNearestUpcomingEvent = (events) => {
|
const findNearestUpcomingEvent = (events) => {
|
||||||
let nearestEvent = null;
|
let nearestEvent = null;
|
||||||
let nearestDateDiff = Infinity;
|
let nearestDateDiff = Infinity;
|
||||||
@@ -138,14 +139,14 @@ const XrplEventsAndCarouselSection = ({ events }) => {
|
|||||||
<img
|
<img
|
||||||
id="left-image"
|
id="left-image"
|
||||||
alt="Left Event Image"
|
alt="Left Event Image"
|
||||||
src={prevEvent ? `/img/events/${prevEvent.image}` : ""}
|
src={prevEvent ? (prevEvent.image.startsWith('https://') ? prevEvent.image : `/img/events/${prevEvent.image}`) : ""}
|
||||||
style={{ visibility: prevEvent ? "visible" : "hidden" }}
|
style={{ visibility: prevEvent ? "visible" : "hidden" }}
|
||||||
/>
|
/>
|
||||||
<div className="center-image-wrapper">
|
<div className="center-image-wrapper">
|
||||||
<img
|
<img
|
||||||
id="center-image"
|
id="center-image"
|
||||||
alt="Featured Event Image"
|
alt="Featured Event Image"
|
||||||
src={currentEvent ? `/img/events/${currentEvent.image}` : ""}
|
src={currentEvent ? (currentEvent.image.startsWith('https://') ? currentEvent.image : `/img/events/${currentEvent.image}`) : ""}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
currentEvent && window.open(currentEvent.link, "_blank")
|
currentEvent && window.open(currentEvent.link, "_blank")
|
||||||
}
|
}
|
||||||
@@ -167,7 +168,7 @@ const XrplEventsAndCarouselSection = ({ events }) => {
|
|||||||
<img
|
<img
|
||||||
id="right-image"
|
id="right-image"
|
||||||
alt="Right Event Image"
|
alt="Right Event Image"
|
||||||
src={nextEvent ? `/img/events/${nextEvent.image}` : ""}
|
src={nextEvent ? (nextEvent.image.startsWith('https://') ? nextEvent.image : `/img/events/${nextEvent.image}`) : ""}
|
||||||
style={{ visibility: nextEvent ? "visible" : "hidden" }}
|
style={{ visibility: nextEvent ? "visible" : "hidden" }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,26 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const moment = require('moment');
|
||||||
const contentful = require('contentful');
|
const contentful = require('contentful');
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
const eventTypeLookup = {
|
||||||
|
hackathon: 'hackathon',
|
||||||
|
meetup: 'meetup',
|
||||||
|
ama: 'ama',
|
||||||
|
conference: 'conference',
|
||||||
|
'community-call': 'cc',
|
||||||
|
'xrpl-zone': 'zone',
|
||||||
|
'info-session': 'info',
|
||||||
|
}
|
||||||
|
const imageFallbackLookup = {
|
||||||
|
hackathon: 'Hackathons.png',
|
||||||
|
meetup: '', // should not be blank from contentful
|
||||||
|
ama: 'AMAs.png',
|
||||||
|
conference: 'Conference.png',
|
||||||
|
'community-call': 'CommunityCalls.png',
|
||||||
|
'xrpl-zone': 'XRPLZone.png',
|
||||||
|
'info-session': 'InfoSessions.png',
|
||||||
|
}
|
||||||
const space = process.env.CONTENTFUL_SPACE_ID;
|
const space = process.env.CONTENTFUL_SPACE_ID;
|
||||||
const accessToken = process.env.CONTENTFUL_ACCESS_TOKEN;
|
const accessToken = process.env.CONTENTFUL_ACCESS_TOKEN;
|
||||||
|
|
||||||
@@ -14,14 +32,42 @@ const client = contentful.createClient({
|
|||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
try {
|
try {
|
||||||
const entries = await client.getEntries();
|
const entries = await client.getEntries();
|
||||||
// Transform the entries into the required JSON format
|
|
||||||
const data = entries.items.map((item) => {
|
const data = entries.items.map((item) => {
|
||||||
return {
|
// Edit: Format the dates to match events.json format
|
||||||
id: item.sys.id,
|
const startDate = moment(item.fields.startDate);
|
||||||
...item.fields,
|
const endDate = moment(item.fields.endDate);
|
||||||
image: item?.fields.image?.fields?.file?.url || '',
|
const startDateFormatted = startDate.format('MMMM D, YYYY');
|
||||||
};
|
const endDateFormatted = endDate.format('MMMM D, YYYY');
|
||||||
});
|
const sameDay = startDate.isSame(endDate, 'day');
|
||||||
|
const sameMonth = startDate.isSame(endDate, 'month');
|
||||||
|
const sameYear = startDate.isSame(endDate, 'year');
|
||||||
|
let dateString;
|
||||||
|
|
||||||
|
if (sameDay) {
|
||||||
|
dateString = startDateFormatted;
|
||||||
|
} else if (sameYear && sameMonth) {
|
||||||
|
dateString = `${startDate.format('MMMM D')} - ${endDate.format('D, YYYY')}`;
|
||||||
|
} else if (sameYear) {
|
||||||
|
dateString = `${startDate.format('MMMM D')} - ${endDateFormatted}`;
|
||||||
|
} else {
|
||||||
|
dateString = `${startDateFormatted} - ${endDateFormatted}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const eventType = (item.fields.category[0]).toLocaleLowerCase();
|
||||||
|
return {
|
||||||
|
name: item.fields.name,
|
||||||
|
description: item.fields.description,
|
||||||
|
type: eventTypeLookup[eventType],
|
||||||
|
link: item.fields.link,
|
||||||
|
location: item.fields.location,
|
||||||
|
date: dateString,
|
||||||
|
image: item?.fields?.image?.fields?.file?.url ? `https:${item.fields.image.fields.file.url}` : imageFallbackLookup[eventType],
|
||||||
|
end_date: endDateFormatted,
|
||||||
|
start_date: startDateFormatted,
|
||||||
|
community: item.fields.community,
|
||||||
|
contentful: true, // flag to show its coming from contentful
|
||||||
|
};
|
||||||
|
});
|
||||||
// Write data to JSON file
|
// Write data to JSON file
|
||||||
const filePath = path.join(__dirname, '../static/JSON/contentful-events.json');
|
const filePath = path.join(__dirname, '../static/JSON/contentful-events.json');
|
||||||
fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
fs.writeFileSync(filePath, JSON.stringify(data, null, 2));
|
||||||
|
|||||||
@@ -1,3 +1,15 @@
|
|||||||
[
|
[
|
||||||
|
{
|
||||||
]
|
"name": "NAMEEE Aria Newest Title",
|
||||||
|
"description": "alfknaskljnfaclonfasckln acfslkasaskdfnasljknfkjlanfkjoanfskanafskjnfakjnafknfsaoknfsoiuasnfoianoifankifsdanaisunfsaoiunfsadoiunfdascdfansiacdsncianacsincsaincasiknason",
|
||||||
|
"type": "ama",
|
||||||
|
"link": "https://google.com",
|
||||||
|
"location": "my house. CA",
|
||||||
|
"date": "December 13, 2024 - January 9, 2025",
|
||||||
|
"image": "https://images.ctfassets.net/mixeai34z104/27BDYjXhNHFEc2g2LpU7pE/43b14752034af1e06e256a8fabfc5c91/SouthKoreaMeetup.png",
|
||||||
|
"end_date": "January 9, 2025",
|
||||||
|
"start_date": "December 13, 2024",
|
||||||
|
"community": true,
|
||||||
|
"contentful": true
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1021,7 +1021,7 @@
|
|||||||
"link": "https://xrpl.at/Aquarium-XRPL-Residency-DemoDay4",
|
"link": "https://xrpl.at/Aquarium-XRPL-Residency-DemoDay4",
|
||||||
"location": "New York, New York",
|
"location": "New York, New York",
|
||||||
"date": "November 19, 2024",
|
"date": "November 19, 2024",
|
||||||
"image": "new-york.jpeg",
|
"image": "event-meetup-new-york@2x.jpg",
|
||||||
"end_date": "November 19, 2024",
|
"end_date": "November 19, 2024",
|
||||||
"start_date": "November 19, 2024",
|
"start_date": "November 19, 2024",
|
||||||
"community": true
|
"community": true
|
||||||
|
|||||||
Reference in New Issue
Block a user