Skip to content

Commit 5c23096

Browse files
authored
fix attendee page (graphql#1545)
1 parent 67ed5f9 commit 5c23096

File tree

4 files changed

+53
-16
lines changed

4 files changed

+53
-16
lines changed

gatsby-node.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ export const onCreatePage: GatsbyNode["onCreatePage"] = async ({
9292
actions,
9393
}) => {
9494
// This way is not "the Gatsby way", we create the pages, delete the pages, and create "code" paths page again.
95-
if (page.path.startsWith("/blog") || page.path.startsWith("/tags")) {
95+
if (
96+
page.path.startsWith("/blog") ||
97+
page.path.startsWith("/tags") ||
98+
// we have manual og:image in this page that point to cf worker
99+
page.path.startsWith("/conf/attendee/")
100+
) {
96101
return
97102
}
98103
const { createPage, deletePage } = actions

src/components/Conf/Schedule/ScheduleList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ interface Props {
3737
scheduleData: ScheduleSession[]
3838
filterSchedule?: (sessions: ScheduleSession[]) => ScheduleSession[]
3939
}
40+
4041
const ScheduleList: FC<Props> = ({
4142
showEventType,
4243
filterSchedule,
@@ -78,8 +79,8 @@ const ScheduleList: FC<Props> = ({
7879
</div>
7980
<div className="lg:flex-row flex flex-col gap-5 relative lg:items-start items-end w-full lg:pl-0 pl-[28px]">
8081
<div className="block lg:hidden absolute left-3 top-0 h-full w-0.5 bg-gray-200" />
81-
8282
{sessions.map(session => {
83+
session.event_type ??= ""
8384
const eventType = session.event_type.endsWith("s")
8485
? session.event_type.slice(0, -1)
8586
: session.event_type

src/pages/conf/attendee.tsx renamed to src/pages/conf/attendee/[hash].tsx

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React from "react"
2-
import LayoutConf from "../../components/Conf/Layout"
3-
import HeaderConf from "../../components/Conf/Header"
2+
import LayoutConf from "../../../components/Conf/Layout"
3+
import HeaderConf from "../../../components/Conf/Header"
44
// import ButtonConf from "../../components/Conf/Button"
55
import clsx from "clsx"
66
import { PageProps, HeadProps } from "gatsby"
7-
import SeoConf from "../../components/Conf/Seo"
8-
import { useLocation } from "@reach/router"
7+
import SeoConf from "../../../components/Conf/Seo"
98

10-
export default (_props: PageProps) => {
11-
const { href, search } = useLocation()
9+
export default ({ location, params }: PageProps) => {
10+
const search = getSeachParams(params.hash)
1211
// const text = "Nice! I got my @GraphQLConf ticket! Get yours too!"
1312
return (
1413
<LayoutConf>
@@ -30,7 +29,7 @@ export default (_props: PageProps) => {
3029
)}
3130
onClick={async () => {
3231
try {
33-
await navigator.clipboard.writeText(href)
32+
await navigator.clipboard.writeText(location.href)
3433
console.log("Content copied to clipboard")
3534
} catch (err) {
3635
console.error("Failed to copy:", err)
@@ -42,22 +41,53 @@ export default (_props: PageProps) => {
4241
</div>
4342
</section>
4443
</div>
45-
<img
46-
src={`https://og-image.the-guild.dev/conf${search}`}
47-
className="block mx-auto"
48-
/>
44+
{search && (
45+
<img
46+
src={`https://og-image.the-guild.dev/conf${search}`}
47+
className="block mx-auto"
48+
/>
49+
)}
4950
</div>
5051
</LayoutConf>
5152
)
5253
}
5354

54-
export function Head(_props: HeadProps) {
55-
const { search } = useLocation()
55+
function getSeachParams(base64: string): string {
56+
let string: string
57+
try {
58+
string = atob(base64)
59+
} catch (error) {
60+
console.log(error)
61+
return ""
62+
}
63+
64+
let list: string[] = []
65+
66+
try {
67+
list = JSON.parse(string)
68+
} catch (error) {
69+
console.log(error)
70+
return ""
71+
}
72+
73+
const [fullName, jobTitle, company, github] = list
74+
const searchParams = new URLSearchParams({
75+
...(fullName && { fullName }),
76+
...(jobTitle && { jobTitle }),
77+
...(company && { company }),
78+
...(github && { github }),
79+
})
80+
return "?" + searchParams.toString()
81+
}
82+
83+
export function Head({ params }: HeadProps & { hash: string }) {
5684
return (
5785
<SeoConf
5886
title="My ticket"
5987
ogImage={{
60-
url: `https://og-image.the-guild.dev/conf${search}`,
88+
url: `https://og-image.the-guild.dev/conf${getSeachParams(
89+
params.hash
90+
)}`,
6191
width: 1200,
6292
height: 600,
6393
}}

src/templates/event.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const EventComponent: FC<{
4242
speakers: SchedSpeaker[]
4343
hideBackButton?: boolean
4444
}> = ({ event, speakers, hideBackButton }) => {
45+
event.event_type ??= ""
4546
const eventType = event.event_type.endsWith("s")
4647
? event.event_type.slice(0, -1)
4748
: event.event_type

0 commit comments

Comments
 (0)