Skip to content

Commit

Permalink
Merge branch 'develop' into fix/coinshift-support
Browse files Browse the repository at this point in the history
  • Loading branch information
shoom3301 authored Dec 17, 2024
2 parents 64ef900 + e473c2b commit 94bc88b
Show file tree
Hide file tree
Showing 220 changed files with 9,216 additions and 7,905 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ out

# Next.js sitemap
apps/cow-fi/public/robots.txt
apps/cow-fi/public/sitemap*
apps/cow-fi/public/sitemap*
38 changes: 19 additions & 19 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"apps/cowswap-frontend": "1.90.0",
"apps/explorer": "2.36.1",
"libs/permit-utils": "0.4.0",
"libs/widget-lib": "0.17.0",
"apps/cowswap-frontend": "1.93.2",
"apps/explorer": "2.38.0",
"libs/permit-utils": "0.5.0",
"libs/widget-lib": "0.18.0",
"libs/widget-react": "0.11.0",
"apps/widget-configurator": "1.9.0",
"libs/analytics": "1.8.0",
"libs/assets": "1.10.0",
"libs/common-const": "1.10.1",
"libs/common-hooks": "1.4.0",
"libs/common-utils": "1.7.2",
"libs/core": "1.3.0",
"libs/ens": "1.2.0",
"apps/widget-configurator": "1.10.0",
"libs/analytics": "1.9.0",
"libs/assets": "1.11.0",
"libs/common-const": "1.12.2",
"libs/common-hooks": "1.6.0",
"libs/common-utils": "1.8.0",
"libs/core": "1.5.0",
"libs/ens": "1.3.0",
"libs/events": "1.5.0",
"libs/snackbars": "1.1.0",
"libs/tokens": "1.11.0",
"libs/types": "1.4.0",
"libs/ui": "1.14.0",
"libs/wallet": "1.6.1",
"apps/cow-fi": "1.16.0",
"libs/tokens": "1.13.0",
"libs/types": "1.5.0",
"libs/ui": "1.16.0",
"libs/wallet": "1.7.0",
"apps/cow-fi": "1.19.2",
"libs/wallet-provider": "1.0.0",
"libs/ui-utils": "1.1.0",
"libs/abis": "1.2.0",
"libs/balances-and-allowances": "1.1.1",
"libs/balances-and-allowances": "1.2.0",
"libs/iframe-transport": "1.0.0",
"libs/hook-dapp-lib": "1.3.0",
"libs/hook-dapp-lib": "1.4.0",
"libs/multicall": "1.0.0"
}
2 changes: 1 addition & 1 deletion apps/cow-fi/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ DUNE_API_KEY=tuBkOcda6ymMvmnpIX9Qer9Xb5hJ2rf8
NEXT_PUBLIC_GOOGLE_ANALYTICS=
NEXT_PUBLIC_AWS_API_ENDPOINT="https://bff.cow.fi/proxies/tokens"
NEXT_PUBLIC_LAUNCH_DARKLY_KEY=
NEXT_PUBLIC_SITE_URL="https://cow.fi"
NEXT_PUBLIC_SITE_URL="https://cow.fi"
45 changes: 45 additions & 0 deletions apps/cow-fi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Changelog

## [1.19.2](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.19.1...cow-fi-v1.19.2) (2024-12-12)


### Bug Fixes

* **cowfi:** reduce cms requests cache time to 5 min ([#5196](https://github.com/cowprotocol/cowswap/issues/5196)) ([8893f35](https://github.com/cowprotocol/cowswap/commit/8893f35e177f86eef15ad2790034b705cf91e349))

## [1.19.1](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.19.0...cow-fi-v1.19.1) (2024-12-12)


### Bug Fixes

* **cow-fi:** add info about base launch ([#5194](https://github.com/cowprotocol/cowswap/issues/5194)) ([6bd2015](https://github.com/cowprotocol/cowswap/commit/6bd20155a2211bba95e5cdd8dab2e108b4783a13))

## [1.19.0](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.18.0...cow-fi-v1.19.0) (2024-12-11)


### Features

* **cow-fi:** upgrade project structure to /app ([#5167](https://github.com/cowprotocol/cowswap/issues/5167)) ([ed152f7](https://github.com/cowprotocol/cowswap/commit/ed152f7ac0fa62ab2c0b9c93035a551c3b8cb4b6))


### Bug Fixes

* add Base to CoW Protocol FAQ on cow.fi ([#5179](https://github.com/cowprotocol/cowswap/issues/5179)) ([a38a3e5](https://github.com/cowprotocol/cowswap/commit/a38a3e5b0cb82d3ad1863f980cfa062d3e8d9954))

## [1.18.0](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.17.0...cow-fi-v1.18.0) (2024-12-09)


### Features

* **cow-fi:** cache data and pages ([#5169](https://github.com/cowprotocol/cowswap/issues/5169)) ([39c94cc](https://github.com/cowprotocol/cowswap/commit/39c94cca11db8a97d9add3ac05c1623755ecd2b3))

## [1.17.0](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.16.0...cow-fi-v1.17.0) (2024-12-04)


### Features

* upgrade react@19 and next@15 ([#5147](https://github.com/cowprotocol/cowswap/issues/5147)) ([a00b1b9](https://github.com/cowprotocol/cowswap/commit/a00b1b930602ab1e6b2f0b3cd148497f68bf4cb5))


### Bug Fixes

* remove props from mevblocker page ([#5148](https://github.com/cowprotocol/cowswap/issues/5148)) ([a20de89](https://github.com/cowprotocol/cowswap/commit/a20de895471fbe957e223fad039f89a182b674bd))

## [1.16.0](https://github.com/cowprotocol/cowswap/compare/cow-fi-v1.15.0...cow-fi-v1.16.0) (2024-10-29)


Expand Down
5 changes: 5 additions & 0 deletions apps/cow-fi/app/(learn)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Layout } from '@/components/Layout'

export default function LayoutPage({ children }: { children: React.ReactNode }) {
return <Layout>{children}</Layout>
}
101 changes: 101 additions & 0 deletions apps/cow-fi/app/(learn)/learn/[article]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
'use server'

import React from 'react'
import {
Article,
getAllArticleSlugs,
getArticleBySlug,
getArticles,
getCategories,
SharedRichTextComponent,
} from '../../../../services/cms'
import { ArticlePageComponent } from '@/components/ArticlePageComponent'
import { notFound } from 'next/navigation'
import type { Metadata } from 'next'
import { stripHtmlTags } from '@/util/stripHTMLTags'
import { getPageMetadata } from '@/util/getPageMetadata'

function isRichTextComponent(block: any): block is SharedRichTextComponent {
return block.body !== undefined
}

type Props = {
params: Promise<{ article: string }>
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const articleSlug = (await params).article

if (!articleSlug) return {}

const article = await getArticleBySlug(articleSlug)
const attributes = article?.attributes
const { title, blocks, description, cover } = attributes || {}
const coverImageUrl = cover?.data?.attributes?.url

const content =
blocks?.map((block: SharedRichTextComponent) => (isRichTextComponent(block) ? block.body : '')).join(' ') || ''
const plainContent = stripHtmlTags(content)

return getPageMetadata({
absoluteTitle: `${title} - CoW DAO`,
description: description
? stripHtmlTags(description)
: plainContent.length > 150
? stripHtmlTags(plainContent.substring(0, 147)) + '...'
: stripHtmlTags(plainContent),
image: coverImageUrl,
})
}

export async function generateStaticParams() {
const slugs = await getAllArticleSlugs()

return slugs.map((article) => ({ article }))
}

export default async function ArticlePage({ params }: Props) {
const articleSlug = (await params).article
const article = await getArticleBySlug(articleSlug)

if (!article) {
return notFound()
}

const articlesResponse = await getArticles()
const articles = articlesResponse.data

// Fetch featured articles
const featuredArticlesResponse = await getArticles({
filters: {
featured: {
$eq: true,
},
},
pageSize: 7, // Limit to 7 articles
})
const featuredArticles = featuredArticlesResponse.data

const randomArticles = getRandomArticles(articles, 3)
const categoriesResponse = await getCategories()
const allCategories =
categoriesResponse?.map((category: any) => ({
name: category?.attributes?.name || '',
slug: category?.attributes?.slug || '',
})) || []

return (
<ArticlePageComponent
article={article}
articles={articles}
randomArticles={randomArticles}
featuredArticles={featuredArticles}
allCategories={allCategories}
/>
)
}

function getRandomArticles(articles: Article[], count: number): Article[] {
const shuffled = articles.sort(() => 0.5 - Math.random())
return shuffled.slice(0, count)
}
11 changes: 11 additions & 0 deletions apps/cow-fi/app/(learn)/learn/articles/[[...pageIndex]]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Metadata } from 'next'
import { getPageMetadata } from '@/util/getPageMetadata'

export const metadata: Metadata = getPageMetadata({
title: 'All articles',
description: 'All knowledge base articles in the Cow DAO ecosystem',
})

export default function LayoutPage({ children }: { children: React.ReactNode }) {
return children
}
67 changes: 67 additions & 0 deletions apps/cow-fi/app/(learn)/learn/articles/[[...pageIndex]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
'use server'

import { Article, getArticles, getCategories } from '../../../../../services/cms'
import { ArticlesPageComponents } from '@/components/ArticlesPageComponents'

const ITEMS_PER_PAGE = 24

type Props = {
params: Promise<{ pageIndex?: string }>
}

export type ArticlesResponse = {
data?: Article[]
meta?: {
pagination?: {
total?: number
}
}
}

export async function generateStaticParams() {
const articlesResponse = await getArticles({ page: 0, pageSize: ITEMS_PER_PAGE })
const totalArticles = articlesResponse.meta?.pagination?.total || 0
const totalPages = Math.ceil(totalArticles / ITEMS_PER_PAGE)

return Array.from({ length: totalPages }, (_, i) => ({ pageIndex: [(i + 1).toString()] }))
}

export default async function Page({ params }: Props) {
const pageParam = (await params)?.pageIndex
const page = pageParam && pageParam.length > 0 ? parseInt(pageParam[0], 10) : 1

const articlesResponse = (await getArticles({ page, pageSize: ITEMS_PER_PAGE })) as ArticlesResponse

const totalArticles = articlesResponse.meta?.pagination?.total || 0
const articles =
articlesResponse.data?.map((article: Article) => ({
...article,
id: article.id || 0,
attributes: {
...article.attributes,
title: article.attributes?.title ?? 'Untitled',
description: article.attributes?.description ?? '',
slug: article.attributes?.slug ?? 'no-slug',
featured: article.attributes?.featured ?? false,
publishDateVisible: article.attributes?.publishDateVisible ?? false,
cover: article.attributes?.cover ?? {},
blocks: article.attributes?.blocks ?? [],
},
})) || []

const categoriesResponse = await getCategories()
const allCategories =
categoriesResponse?.map((category: any) => ({
name: category?.attributes?.name || '',
slug: category?.attributes?.slug || '',
})) || []

return (
<ArticlesPageComponents
articles={articles}
totalArticles={totalArticles}
currentPage={page}
allCategories={allCategories}
/>
)
}
20 changes: 20 additions & 0 deletions apps/cow-fi/app/(learn)/learn/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Metadata } from 'next'
import { getPageMetadata } from '@/util/getPageMetadata'
import { CONFIG } from '@/const/meta'

const title = 'Knowledge Base - CoW DAO'

export const metadata: Metadata = {
...getPageMetadata({
title,
description: CONFIG.description,
}),
title: {
default: title,
template: '%s - CoW DAO',
},
}

export default function LayoutPage({ children }: { children: React.ReactNode }) {
return children
}
45 changes: 45 additions & 0 deletions apps/cow-fi/app/(learn)/learn/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use server'

import { getArticles, getCategories } from '../../../services/cms'

import { LearnPageComponent } from '@/components/LearnPageComponent'

export default async function Page() {
const categoriesResponse = await getCategories()
const articlesResponse = await getArticles()

const featuredArticlesResponse = await getArticles({
filters: { featured: { $eq: true } },
pageSize: 6,
})

const categories =
categoriesResponse?.map((category: any) => {
const imageUrl = category?.attributes?.image?.data?.attributes?.url || ''

return {
name: category?.attributes?.name || '',
slug: category?.attributes?.slug || '',
description: category?.attributes?.description || '',
bgColor: category?.attributes?.backgroundColor || '#fff',
textColor: category?.attributes?.textColor || '#000',
link: `/learn/topic/${category?.attributes?.slug}`,
iconColor: '#fff',
imageUrl,
}
}) || []

const featuredArticles = featuredArticlesResponse.data.map((article) => {
const attributes = article.attributes
return {
title: attributes?.title || 'No title',
description: attributes?.description || 'No description',
link: `/learn/${attributes?.slug || 'no-slug'}`,
cover: attributes?.cover?.data?.attributes?.url || '',
}
})

return (
<LearnPageComponent categories={categories} articles={articlesResponse.data} featuredArticles={featuredArticles} />
)
}
Loading

0 comments on commit 94bc88b

Please sign in to comment.