-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from blockworks-foundation/news-links
news links
- Loading branch information
Showing
9 changed files
with
29,649 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import dayjs from 'dayjs' | ||
import { NewsArticle } from '../../../contentful/newsArticle' | ||
|
||
const NewsArticleCard = ({ article }: { article: NewsArticle }) => { | ||
const { title, articleUrl, imageUrl, sourceSiteName, datePublished } = article | ||
return ( | ||
<a | ||
className="col-span-3 md:col-span-1 md:hover:opacity-80" | ||
href={articleUrl} | ||
key={articleUrl} | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
> | ||
<img src={imageUrl} className="w-48 h-auto" /> | ||
<h4 className="mt-4">{title}</h4> | ||
<p className="mt-2 text-sm text-th-fgd-2">{sourceSiteName}</p> | ||
<p className="text-sm">{dayjs(datePublished).format('D MMM YYYY')}</p> | ||
</a> | ||
) | ||
} | ||
|
||
export default NewsArticleCard |
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,60 @@ | ||
import { TypeNewsArticleSkeleton } from './types' | ||
import { Entry } from 'contentful' | ||
import contentfulClient from './contentfulClient' | ||
|
||
type NewsArticleEntry = Entry<TypeNewsArticleSkeleton, undefined, string> | ||
|
||
// Our simplified version of a NewsArticle. | ||
// We don't need all the data that Contentful gives us. | ||
export interface NewsArticle { | ||
title: string | ||
articleUrl: string | ||
imageUrl: string | undefined | ||
sourceSiteName: string | ||
datePublished: string | ||
categories: string[] | ||
} | ||
|
||
// A function to transform a Contentful blog post | ||
// into our own NewsArticle object. | ||
export function parseContentfulNewsArticle( | ||
newsArticleEntry?: NewsArticleEntry, | ||
): NewsArticle | null { | ||
if (!newsArticleEntry) { | ||
return null | ||
} | ||
|
||
return { | ||
title: newsArticleEntry.fields.title || '', | ||
articleUrl: newsArticleEntry.fields.articleUrl, | ||
imageUrl: newsArticleEntry.fields.imageUrl || '', | ||
sourceSiteName: newsArticleEntry.fields.sourceSiteName, | ||
datePublished: newsArticleEntry.fields.datePublished, | ||
categories: newsArticleEntry.fields.categories, | ||
} | ||
} | ||
|
||
// A function to fetch all blog posts. | ||
// Optionally uses the Contentful content preview. | ||
interface FetchNewsArticlesOptions { | ||
preview: boolean | ||
category: any | ||
} | ||
export async function fetchNewsArticles({ | ||
preview, | ||
category, | ||
}: FetchNewsArticlesOptions): Promise<NewsArticle[]> { | ||
const contentful = contentfulClient({ preview }) | ||
|
||
const newsArticlesResult = | ||
await contentful.getEntries<TypeNewsArticleSkeleton>({ | ||
content_type: 'newsArticle', | ||
include: 2, | ||
'fields.categories[in]': category, | ||
}) | ||
|
||
return newsArticlesResult.items.map( | ||
(newsArticleEntry) => | ||
parseContentfulNewsArticle(newsArticleEntry) as NewsArticle, | ||
) | ||
} |
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,86 @@ | ||
import type { | ||
ChainModifiers, | ||
Entry, | ||
EntryFieldTypes, | ||
EntrySkeletonType, | ||
LocaleCode, | ||
} from 'contentful' | ||
|
||
export interface TypeNewsArticleFields { | ||
title: EntryFieldTypes.Symbol | ||
articleUrl: EntryFieldTypes.Symbol | ||
imageUrl?: EntryFieldTypes.Symbol | ||
sourceSiteName: EntryFieldTypes.Symbol | ||
datePublished: EntryFieldTypes.Symbol | ||
categories: EntryFieldTypes.Array< | ||
EntryFieldTypes.Symbol< | ||
| 'AI' | ||
| 'ALL' | ||
| 'AMM' | ||
| 'BONK' | ||
| 'Bridged (Portal)' | ||
| 'CHAI' | ||
| 'CORN' | ||
| 'CROWN' | ||
| 'Communication' | ||
| 'DUAL' | ||
| 'DeFi' | ||
| 'DePIN' | ||
| 'Dog Coin' | ||
| 'Domains' | ||
| 'ETH (Portal)' | ||
| 'Exchange' | ||
| 'GUAC' | ||
| 'Gambling' | ||
| 'Gaming' | ||
| 'Governance' | ||
| 'HNT' | ||
| 'Infrastructure' | ||
| 'JLP' | ||
| 'JTO' | ||
| 'JitoSOL' | ||
| 'KIN' | ||
| 'LDO' | ||
| 'Layer 1' | ||
| 'Liquid Staking' | ||
| 'MNGO' | ||
| 'Meme' | ||
| 'NEON' | ||
| 'NOS' | ||
| 'OPOS' | ||
| 'ORCA' | ||
| 'Options' | ||
| 'Oracle' | ||
| 'PYTH' | ||
| 'Payments' | ||
| 'Perps' | ||
| 'RAY' | ||
| 'RENDER' | ||
| 'RLB' | ||
| 'SAMO' | ||
| 'SLCL' | ||
| 'SOL' | ||
| 'Social' | ||
| 'Stablecoin' | ||
| 'TBTC' | ||
| 'Tokenized Asset' | ||
| 'USDC' | ||
| 'USDH' | ||
| 'USDT' | ||
| 'WIF' | ||
| 'Yield Bearing' | ||
| 'bSOL' | ||
| 'mSOL' | ||
| 'wBTC (Portal)' | ||
> | ||
> | ||
} | ||
|
||
export type TypeNewsArticleSkeleton = EntrySkeletonType< | ||
TypeNewsArticleFields, | ||
'newsArticle' | ||
> | ||
export type TypeNewsArticle< | ||
Modifiers extends ChainModifiers, | ||
Locales extends LocaleCode, | ||
> = Entry<TypeNewsArticleSkeleton, Modifiers, Locales> |
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
Large diffs are not rendered by default.
Oops, something went wrong.
3596e78
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mango-web – ./
mango-web-git-main-blockworks-foundation.vercel.app
mango-web.vercel.app
mango-web-blockworks-foundation.vercel.app
mango.markets
www.mango.markets