This repository has been archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add schema.org events to head (#3385)
* add schema.org events to head * fix lint * lint fix * [WIP] events from schemaorgs * move schemaOrg to composable * add list of events * move events schema to events/index * remove qiskit schema composable * add eventschema to all event pages * add schema.org events to head * fix lint * lint fix * [WIP] events from schemaorgs * move schemaOrg to composable * add list of events * move events schema to events/index * remove qiskit schema composable * add eventschema to all event pages * fix import * [WIP] * move reusable code to utils/ * add schema.org events to head * fix lint * lint fix * [WIP] events from schemaorgs * move schemaOrg to composable * add list of events * move events schema to events/index * remove qiskit schema composable * add eventschema to all event pages * add schema.org events to head * fix lint * [WIP] events from schemaorgs * move schemaOrg to composable * add list of events * move events schema to events/index * remove qiskit schema composable * fix import * [WIP] * move reusable code to utils/ * fix lint * Apply suggestions from code review Co-authored-by: Eddybrando Vásquez <eddybrando.vasquez@gmail.com> * [WIP] fixing PR requests * fix: add EventSchemaOrg type * chore: DRY sort events * fix: useSchemaOrg fix * resolve PR conversations * chore: remove unused layout --------- Co-authored-by: Yaiza <yaiza.garcia.mm@gmail.com> Co-authored-by: Eddybrando Vásquez <eddybrando.vasquez@gmail.com>
- Loading branch information
1 parent
0dca4d2
commit 76b2080
Showing
10 changed files
with
189 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
type EventAttendanceModeTypes = | ||
| "OfflineEventAttendanceMode" | ||
| "OnlineEventAttendanceMode" | ||
| "MixedEventAttendanceMode"; | ||
|
||
interface VirtualLocation { | ||
"@type"?: "VirtualLocation"; | ||
url: string; | ||
} | ||
interface Place { | ||
name: string; | ||
address: string; | ||
url: string; | ||
} | ||
|
||
interface EventSchemaOrg { | ||
name: string; | ||
eventAttendanceMode: EventAttendanceModeTypes; | ||
image: string; | ||
location: VirtualLocation | Place; | ||
startDate: string; | ||
organizer: { | ||
name: string; | ||
url: string; | ||
}; | ||
performer?: { | ||
name: string; | ||
}; | ||
endDate?: string; | ||
} | ||
|
||
interface Event { | ||
startDate: Date; | ||
mode: "Online" | "Offline"; | ||
location: string; | ||
url: string; | ||
name: string; | ||
image: string; | ||
performer?: string; | ||
endDate?: Date; | ||
} | ||
|
||
export function createEventSchemaOrg(event: Event) { | ||
let location; | ||
if (event.mode === "Online") { | ||
location = { | ||
url: event.url, | ||
}; | ||
} else { | ||
location = { | ||
name: event.location, | ||
address: event.location, | ||
url: event.url, | ||
}; | ||
} | ||
|
||
const eventAttendanceMode = | ||
event.mode === "Online" | ||
? "OnlineEventAttendanceMode" | ||
: "OfflineEventAttendanceMode"; | ||
|
||
const schemaEvent: EventSchemaOrg = { | ||
name: event.name, | ||
eventAttendanceMode, | ||
image: event.image, | ||
location, | ||
startDate: new Date(event.startDate).toISOString(), | ||
organizer: { | ||
name: "IBM Quantum", | ||
url: "https://ibm.com/quantum", | ||
}, | ||
}; | ||
|
||
if (event.performer) { | ||
schemaEvent.performer = { | ||
name: event.performer, | ||
}; | ||
} | ||
|
||
if (event.endDate) { | ||
schemaEvent.endDate = event.endDate.toISOString(); | ||
} | ||
|
||
return defineEvent(schemaEvent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export function sortEvents<T extends { startDate: string }>(events: T[]): T[] { | ||
return events | ||
.filter((event) => event.startDate) | ||
.sort((a, b) => { | ||
const dateA = new Date(a.startDate); | ||
const dateB = new Date(b.startDate); | ||
|
||
return dateA > dateB ? 1 : dateA < dateB ? -1 : 0; | ||
}); | ||
} |
File renamed without changes.