diff --git a/src/components/common/card/index.tsx b/src/components/common/card/index.tsx index eae5629..013c788 100644 --- a/src/components/common/card/index.tsx +++ b/src/components/common/card/index.tsx @@ -19,7 +19,7 @@ interface CardProps { const Card = ({ className, data, isNews = false }: CardProps) => { return ( - +
{!isNews && ( @@ -28,7 +28,7 @@ const Card = ({ className, data, isNews = false }: CardProps) => {
{isNews && ( - BY {data?.author} + BY {data?.author.name} )} @@ -44,14 +44,18 @@ const Card = ({ className, data, isNews = false }: CardProps) => {
- {data?.title} + {data?.title}
{data?.title} -

{data?.preview}

- +

{isNews ? getDescription(data) : data?.preview}

+ {isNews ? 'READ ARTICLE' : 'LEARN MORE'}
diff --git a/src/components/sections/about/related/index.tsx b/src/components/sections/about/related/index.tsx index 29fd804..2687eea 100644 --- a/src/components/sections/about/related/index.tsx +++ b/src/components/sections/about/related/index.tsx @@ -2,16 +2,22 @@ import 'keen-slider/keen-slider.min.css' import clsx from 'clsx' import { useKeenSlider } from 'keen-slider/react' +import { Key } from 'react' import Card from '~/components/common/card' import { Container } from '~/components/layout/container' import Section from '~/components/layout/section' import Heading from '~/components/primitives/heading' -import { related } from './related' import s from './related.module.scss' -const Related = () => { +// TODO +export interface Props { + isInPost?: boolean + data: any +} + +const Related = ({ data, isInPost }: Props) => { const [sliderRef] = useKeenSlider({ initial: 0, loop: true, @@ -32,14 +38,14 @@ const Related = () => { return (
- + - Learn More + {isInPost ? 'Related articles' : 'Learn More'}
- {related.map((item, i) => ( + {data.map((item: any, i: Key) => ( ))}
diff --git a/src/components/sections/about/related/related.module.scss b/src/components/sections/about/related/related.module.scss index 691221a..77b9b76 100644 --- a/src/components/sections/about/related/related.module.scss +++ b/src/components/sections/about/related/related.module.scss @@ -35,6 +35,12 @@ justify-content: space-between; margin-bottom: tovw(90px, 'default', 64px); + &.altheader { + @media screen and (min-width: 1141px) { + place-content: center; + } + } + h2 { text-shadow: 0 0 tovw(20px, 'default', 20px) rgb(255 255 255 / 0.4); } diff --git a/src/components/sections/homepage/latest-news/index.tsx b/src/components/sections/homepage/latest-news/index.tsx index b7c6790..e94c69f 100644 --- a/src/components/sections/homepage/latest-news/index.tsx +++ b/src/components/sections/homepage/latest-news/index.tsx @@ -1,7 +1,7 @@ import 'keen-slider/keen-slider.min.css' import { useKeenSlider } from 'keen-slider/react' -import { useState } from 'react' +import { Key, useState } from 'react' import Card from '~/components/common/card' import { ArrowSlider } from '~/components/icons/arrow' @@ -10,9 +10,13 @@ import Section from '~/components/layout/section' import Heading from '~/components/primitives/heading' import s from './latest-news.module.scss' -import { latestNews } from './news' -const LatestNews = () => { +// TODO +export interface Props { + data: any +} + +const LatestNews = ({ data }: Props) => { const [loaded, setLoaded] = useState(false) const [sliderRef, slider] = useKeenSlider({ @@ -42,7 +46,7 @@ const LatestNews = () => {
- {latestNews.map((item, i) => ( + {data.map((item: any, i: Key) => ( ))}
diff --git a/src/components/sections/homepage/latest-news/news.ts b/src/components/sections/homepage/latest-news/news.ts deleted file mode 100644 index 1b34a37..0000000 --- a/src/components/sections/homepage/latest-news/news.ts +++ /dev/null @@ -1,38 +0,0 @@ -export const latestNews = [ - { - author: 'BRIAN MILLER', - date: '01.31.22', - imgSrc: '/images/blog/post001.jpg', - title: '7 Trends Transforming DeFi 2022', - preview: - 'Sit sed dolor felis quis. Porttitor semper enim placerat luctus purus aliquam. Diam eu varius donec sit urna feugiat libero diam augue.', - link: '/blog/article' - }, - { - author: 'STEPHAN WILLSON', - date: '04.25.22', - imgSrc: '/images/blog/post002.jpg', - title: 'State of Verifiable Data', - preview: - 'Sit sed dolor felis quis. Porttitor semper enim placerat luctus purus aliquam. Diam eu varius donec sit urna feugiat libero diam augue.', - link: '/blog/article' - }, - { - author: 'BRIAN MILLER', - date: '06.25.22', - imgSrc: '/images/blog/post003.jpg', - title: '7 Trends Transforming DeFi 2022', - preview: - 'Sit sed dolor felis quis. Porttitor semper enim placerat luctus purus aliquam. Diam eu varius donec sit urna feugiat libero diam augue.', - link: '/blog/article' - }, - { - author: 'STEPHAN WILLSON', - date: '08.25.22', - imgSrc: '/images/blog/post004.jpg', - title: '7 Trends Transforming DeFi 2022', - preview: - 'Sit sed dolor felis quis. Porttitor semper enim placerat luctus purus aliquam. Diam eu varius donec sit urna feugiat libero diam augue.', - link: '/blog/article' - } -] diff --git a/src/pages/about.tsx b/src/pages/about.tsx index 19fdd32..188c9de 100644 --- a/src/pages/about.tsx +++ b/src/pages/about.tsx @@ -1,18 +1,48 @@ +import { + getBlogPosts as serverGetBlogPosts, + getBlogPostsCategories as serverGetBlogPostsCategories +} from 'lib/blog' +import { InferGetStaticPropsType } from 'next' + import { Meta } from '~/components/common/meta' import { PageLayout } from '~/components/layout/page' import Hero from '~/components/sections/about/hero' import Related from '~/components/sections/about/related' import Team from '~/components/sections/about/team' -import { Page } from './_app' +export const getStaticProps = async () => { + const [allBlogPosts, categories] = await Promise.all([ + serverGetBlogPosts({ page: 1 }), + serverGetBlogPostsCategories() + ]) -const About: Page = () => { + const heroBlogPost = allBlogPosts.data[0] + + return { + props: { + initialBlogPosts: { + pagination: allBlogPosts.pagination, + data: allBlogPosts.data.slice(0, 3) + }, + categories, + page: + { + heroBlogPost + } ?? null + }, + revalidate: 1 + } +} + +const About = ({ + initialBlogPosts +}: InferGetStaticPropsType) => { return ( - + ) } diff --git a/src/pages/blog/[slug].tsx b/src/pages/blog/[slug].tsx index 92445b5..b1eb7c1 100644 --- a/src/pages/blog/[slug].tsx +++ b/src/pages/blog/[slug].tsx @@ -12,15 +12,12 @@ import { } from 'next' import Error from 'next/error' import { useRouter } from 'next/router' -import { Key } from 'react' -import { BlogCard } from '~/components/common/card' import { Meta } from '~/components/common/meta' +import Related from '~/components/sections/about/related' import Content from '~/components/sections/blog/post-content' import Hero from '~/components/sections/blog/post-hero' -import PostsGrid from '~/components/sections/blog/posts-grid' import Shares from '~/components/sections/blog/shares' -import { BlogPostFragment } from '~/lib/cms/generated' const BlogPost = ({ latestPosts, @@ -40,7 +37,7 @@ const BlogPost = ({ - + {/* {latestPosts.map((relatedPost: BlogPostFragment, index: Key) => { return (
@@ -48,7 +45,8 @@ const BlogPost = ({
) })} -
+
*/} + ) } diff --git a/src/pages/index.tsx b/src/pages/index.tsx index a5063a3..ef0aeb4 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,3 +1,9 @@ +import { + getBlogPosts as serverGetBlogPosts, + getBlogPostsCategories as serverGetBlogPostsCategories +} from 'lib/blog' +import { InferGetStaticPropsType } from 'next' + import { Meta } from '~/components/common/meta' import { PageLayout } from '~/components/layout/page' import Benefits from '~/components/sections/homepage/benefits' @@ -5,15 +11,39 @@ import Hero from '~/components/sections/homepage/hero' import LatestNews from '~/components/sections/homepage/latest-news' import WhatOthersSay from '~/components/sections/homepage/what-others-say' -import { Page } from './_app' +export const getStaticProps = async () => { + const [allBlogPosts, categories] = await Promise.all([ + serverGetBlogPosts({ page: 1 }), + serverGetBlogPostsCategories() + ]) -const HomePage: Page = () => { + const heroBlogPost = allBlogPosts.data[0] + + return { + props: { + initialBlogPosts: { + pagination: allBlogPosts.pagination, + data: allBlogPosts.data.slice(0, 8) + }, + categories, + page: + { + heroBlogPost + } ?? null + }, + revalidate: 1 + } +} + +const HomePage = ({ + initialBlogPosts +}: InferGetStaticPropsType) => { return ( - + )