-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into LF-9574-jumper-frontend-make-superfest-re…
…usable
- Loading branch information
Showing
44 changed files
with
1,385 additions
and
1,563 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import type { StrapiResponse, TagAttributes } from '@/types/strapi'; | ||
import { TagStrapiApi } from '@/utils/strapi/StrapiApi'; | ||
|
||
export interface GetTagsResponse extends StrapiResponse<TagAttributes> { | ||
url: string; | ||
} | ||
|
||
const predefinedOrder = ['Announcement', 'Partner', 'Bridge']; | ||
|
||
// Helper function to sort tags based on predefined order | ||
const sortTagsByPredefinedOrder = (tags: TagAttributes[]) => { | ||
return tags.sort((a, b) => { | ||
const titleA = a.attributes.Title; | ||
const titleB = b.attributes.Title; | ||
|
||
const indexA = predefinedOrder.indexOf(titleA); | ||
const indexB = predefinedOrder.indexOf(titleB); | ||
|
||
if (indexA === -1 && indexB === -1) { | ||
return 0; | ||
} | ||
if (indexA === -1) { | ||
return 1; | ||
} | ||
if (indexB === -1) { | ||
return -1; | ||
} | ||
return indexA - indexB; | ||
}); | ||
}; | ||
|
||
// Helper function to sort blog articles by `publishedAt` date | ||
const sortBlogArticlesByPublishedDate = (tags: TagAttributes[]) => { | ||
return tags.map((tag) => { | ||
tag.attributes.blog_articles.data = tag.attributes.blog_articles.data.sort( | ||
(a, b) => { | ||
const dateA = a.attributes.publishedAt | ||
? Date.parse(a.attributes.publishedAt) | ||
: -Infinity; // Default to oldest if undefined | ||
const dateB = b.attributes.publishedAt | ||
? Date.parse(b.attributes.publishedAt) | ||
: -Infinity; // Default to oldest if undefined | ||
|
||
return dateB - dateA; | ||
}, | ||
); | ||
return tag; | ||
}); | ||
}; | ||
|
||
export async function getTags(): Promise<GetTagsResponse> { | ||
const urlParams = new TagStrapiApi().addPaginationParams({ | ||
page: 1, | ||
pageSize: 20, | ||
withCount: false, | ||
}); | ||
const apiBaseUrl = urlParams.getApiBaseUrl(); | ||
const apiUrl = urlParams.getApiUrl(); | ||
const accessToken = urlParams.getApiAccessToken(); | ||
|
||
const res = await fetch(decodeURIComponent(apiUrl), { | ||
cache: 'force-cache', | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
|
||
if (!res.ok) { | ||
throw new Error('Failed to fetch data'); | ||
} | ||
|
||
const data = await res.json().then((output) => { | ||
let filteredData = output.data; | ||
|
||
// Sort blog_articles by published date first | ||
filteredData = sortBlogArticlesByPublishedDate(filteredData); | ||
|
||
// Then sort tags by predefined order | ||
filteredData = sortTagsByPredefinedOrder(filteredData); | ||
|
||
return { | ||
meta: output.meta, | ||
data: filteredData, | ||
}; | ||
}); | ||
|
||
return { ...data, url: apiBaseUrl }; | ||
} |
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 |
---|---|---|
@@ -1,77 +1,4 @@ | ||
import type { Metadata } from 'next'; | ||
|
||
export const siteName = 'Jumper.Exchange'; | ||
export const title = 'Jumper | Multi-Chain Bridging & Swapping'; | ||
const description = | ||
export const description = | ||
'Jumper is Crypto’s Everything Exchange, enabling seamless swap and bridge transactions across 25 blockchains. By aggregating all of DeFi liquidity, Jumper ensures the best routes for any token transaction.'; | ||
|
||
export const metadata: Metadata = { | ||
title, | ||
description, | ||
alternates: { | ||
canonical: `${process.env.NEXT_PUBLIC_SITE_URL}/`, | ||
}, | ||
openGraph: { | ||
title: title, | ||
description, | ||
siteName, | ||
url: `${process.env.NEXT_PUBLIC_SITE_URL}/`, | ||
images: [ | ||
{ | ||
url: 'https://jumper.exchange/preview.png', // Default image | ||
width: 900, | ||
height: 450, | ||
}, | ||
], | ||
type: 'website', // Override type | ||
}, | ||
twitter: { | ||
// Twitter metadata | ||
// cardType: 'summary_large_image', | ||
site: '@JumperExchange', | ||
title: title, // Twitter title | ||
description, | ||
images: 'https://jumper.exchange/preview.png', // Twitter image | ||
}, | ||
icons: { | ||
// Icons metadata | ||
icon: [ | ||
{ | ||
url: '/favicon_DT.svg', | ||
sizes: 'any', | ||
media: '(prefers-color-scheme: dark)', | ||
}, | ||
{ url: '/favicon_DT.png', media: '(prefers-color-scheme: dark)' }, | ||
{ url: '/favicon_DT.ico', media: '(prefers-color-scheme: dark)' }, | ||
{ | ||
url: '/favicon.svg', | ||
sizes: 'any', | ||
media: '(prefers-color-scheme: light)', | ||
}, | ||
{ url: '/favicon.png', media: '(prefers-color-scheme: light)' }, | ||
{ url: '/favicon.ico', media: '(prefers-color-scheme: light)' }, | ||
], | ||
shortcut: [ | ||
{ | ||
url: '/apple-touch-icon-57x57.png', | ||
sizes: '57x57', | ||
media: '(prefers-color-scheme: light)', | ||
}, | ||
{ | ||
url: '/apple-touch-icon-180x180.png', | ||
sizes: '180x180', | ||
media: '(prefers-color-scheme: light)', | ||
}, | ||
{ | ||
url: '/apple-touch-icon-57x57_DT.png', | ||
sizes: '57x57', | ||
media: '(prefers-color-scheme: dark)', | ||
}, | ||
{ | ||
url: '/apple-touch-icon-180x180_DT.png', | ||
sizes: '180x180', | ||
media: '(prefers-color-scheme: dark)', | ||
}, | ||
], | ||
}, | ||
}; |
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
Oops, something went wrong.