Skip to content

Commit

Permalink
add custom page
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Feb 2, 2024
1 parent eadf53d commit b7e8a05
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/leaderboard/ProgressModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,14 @@ function ProgressPanel({
const shareOnX = () => {
const { isZero, value } = formatSUB(data?.earned)
generateImage(image => {
const redirectTo = spaceHandleOrId ? `/${spaceHandleOrId}` : `/accounts/${myAddress}`
const title = 'I earned SUB for my activity on Subsocial!'
const desc = 'Follow me here and join The Creator Economy!'
openNewWindow(
twitterShareUrl(
spaceHandleOrId
? `/${spaceHandleOrId}?customImage=${encodeURIComponent(image)}`
: `/accounts/${myAddress}`,
`/custom?image=${encodeURIComponent(image)}&title=${encodeURIComponent(
title,
)}&desc=${encodeURIComponent(desc)}&redirectTo=${encodeURIComponent(redirectTo)}`,
`I earned ${isZero ? '' : `${value} `}#SUB ${
isUsingLastWeekData ? 'last week for my activity' : 'yesterday'
} on @SubsocialChain! 🥳\n\nFollow me here and join The Creator Economy!`,
Expand Down
33 changes: 33 additions & 0 deletions src/pages/custom.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { NextPageContext } from 'next'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import { PageContent } from 'src/components/main/PageWrapper'

export default function CustomPage({
desc,
image,
title,
redirectTo,
}: {
image: string
title: string
desc: string
redirectTo: string
}) {
const router = useRouter()
useEffect(() => {
router.push(redirectTo)
}, [])

return <PageContent meta={{ desc, image, title }} />
}

export const getInitialProps = async (context: NextPageContext) => {
const { image, title, desc, redirectTo } = context.query
return {
image,
title,
desc,
redirectTo,
}
}

0 comments on commit b7e8a05

Please sign in to comment.