Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into alpha-landing-page
Browse files Browse the repository at this point in the history
  • Loading branch information
DiogoSoaress committed Oct 16, 2024
2 parents bd9e369 + 291b1a1 commit c5487ed
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/components/Blog/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { calculateReadingTimeInMin } from '@/components/Blog/utils/calculateRead
import Tags from '@/components/Blog/Tags'
import CategoryIcon from '@/public/images/Blog/category-icon.svg'
import { isAsset } from '@/lib/typeGuards'
import { type BlogPostEntry } from '@/components/Blog/Post'
import type { BlogPostEntry } from '@/config/types'
import { AppRoutes } from '@/config/routes'

const Card = (props: BlogPostEntry) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Blog/FeaturedPost/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box, Grid, Link, Typography } from '@mui/material'
import css from './styles.module.css'
import { formatBlogDate } from '@/components/Blog/utils/formatBlogDate'
import { calculateReadingTimeInMin } from '@/components/Blog/utils/calculateReadingTime'
import { type BlogPostEntry } from '@/components/Blog/Post'
import type { BlogPostEntry } from '@/config/types'
import { isAsset } from '@/lib/typeGuards'
import CategoryIcon from '@/public/images/Blog/category-icon.svg'
import { AppRoutes } from '@/config/routes'
Expand Down
11 changes: 6 additions & 5 deletions src/components/Blog/Post/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Image from 'next/image'
import { Box, Button, Container, Divider, Grid, Typography } from '@mui/material'
import { type Entry } from 'contentful'
import type { TypeAuthorSkeleton, TypePostSkeleton } from '@/contentful/types'
import type { TypeAuthorSkeleton } from '@/contentful/types'
import { formatBlogDate } from '@/components/Blog/utils/formatBlogDate'
import { calculateReadingTimeInMin } from '@/components/Blog/utils/calculateReadingTime'
import { isAsset, isEntryTypeAuthor, isEntryTypePost } from '@/lib/typeGuards'
Expand All @@ -20,12 +20,13 @@ import css from '../styles.module.css'
import { PRESS_RELEASE_TAG, containsTag } from '@/lib/containsTag'
import { COMMS_EMAIL } from '@/config/constants'
import { useBlogPost } from '@/hooks/useBlogPost'
import type { InferGetStaticPropsType } from 'next'
import type { getStaticProps } from '@/pages/blog/[slug]'
import type { BlogPostEntry } from '@/config/types'

export type BlogPostEntry = Entry<TypePostSkeleton, undefined, string>
export type BlogPostProps = {
blogPost: BlogPostEntry
}

const BlogPost = ({ blogPost }: InferGetStaticPropsType<typeof getStaticProps>) => {
const BlogPost = ({ blogPost }: BlogPostProps) => {
const { data: post } = useBlogPost(blogPost.sys.id, blogPost)

const { title, excerpt, content, coverImage, authors, tags, category, date, relatedPosts, metaTags } = post.fields
Expand Down
6 changes: 5 additions & 1 deletion src/components/common/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { isEntryType, isEntryTypeBaseBlock } from '@/lib/typeGuards'
import MetaTags from '@/components/common/MetaTagsContentful'
import { type LandingPageEntry } from '@/config/types'

const Page = ({ landingPage }: { landingPage: LandingPageEntry }) => {
export type LandingPageProps = {
landingPage: LandingPageEntry
}

const Page = ({ landingPage }: LandingPageProps) => {
const { metaTags, content } = landingPage.fields

return (
Expand Down
1 change: 1 addition & 0 deletions src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export type ButtonEntry = Entry<TypeButtonSkeleton, undefined, string>
export type LandingPageEntry = Entry<TypeLandingPageSkeleton, undefined, string>
export type PressRoomEntry = Entry<TypePressRoomSkeleton, undefined, string>
export type BlogHomeEntry = Entry<TypeBlogHomeSkeleton, undefined, string>
export type BlogPostEntry = Entry<TypePostSkeleton, undefined, string>
export type PostEntryCollection = EntryCollection<TypePostSkeleton, undefined, string>
2 changes: 1 addition & 1 deletion src/hooks/useBlogPost.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import useSWR from 'swr'
import client from '@/lib/contentful'
import { type BlogPostEntry } from '@/components/Blog/Post'
import type { BlogPostEntry } from '@/config/types'
import { type TypePostSkeleton } from '@/contentful/types'

const postFetcher = (id: string) => client.getEntry<TypePostSkeleton>(id)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/contentful/__test__/isPressRelease.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isPressReleasePost, isPublishedPressRelease } from '@/lib/contentful/isPressRelease'
import type { BlogPostEntry } from '@/components/Blog/Post'
import type { BlogPostEntry } from '@/config/types'
import type { TypePostFields } from '@/contentful/types'

describe('isPressReleasePost', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/contentful/isDraft.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type { BlogPostEntry } from '@/components/Blog/Post'
import type { BlogPostEntry } from '@/config/types'

export const isDraft = (post: BlogPostEntry) => post.fields.isDraft
2 changes: 1 addition & 1 deletion src/lib/contentful/isPressRelease.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { containsTag, PRESS_RELEASE_TAG } from '@/lib/containsTag'
import { isDraft } from '@/lib/contentful/isDraft'
import type { BlogPostEntry } from '@/components/Blog/Post'
import type { BlogPostEntry } from '@/config/types'

export const isPressReleasePost = (post: BlogPostEntry) => containsTag(post.fields.tags, PRESS_RELEASE_TAG)

Expand Down
16 changes: 4 additions & 12 deletions src/pages/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import type { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from 'next'
import type { GetStaticPaths, GetStaticProps, InferGetStaticPropsType, NextPage } from 'next'
import client from '@/lib/contentful'
import { type TypeLandingPageSkeleton } from '@/contentful/types'
import Page from '@/components/common/Page'
import { type LandingPageEntry } from '@/config/types'
import PageLayout from '@/components/common/PageLayout'
import type { ReactElement } from 'react'
import type { NextPageWithLayout } from '@/pages/_app'
import Page, { type LandingPageProps } from '@/components/common/Page'

const LandingPage: NextPageWithLayout<InferGetStaticPropsType<typeof getStaticProps>> = (props) => {
const LandingPage: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (props) => {
if (!props.landingPage) return null

return <Page {...props} />
}

LandingPage.getLayout = function getLayout(page: ReactElement) {
return <PageLayout>{page}</PageLayout>
}

export const getStaticProps: GetStaticProps<{ landingPage: LandingPageEntry }> = async ({ params }) => {
export const getStaticProps: GetStaticProps<LandingPageProps> = async ({ params }) => {
const slug = params?.slug as string

const landingPageEntries = await client.getEntries<TypeLandingPageSkeleton>({
Expand Down
5 changes: 3 additions & 2 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { CookieBanner } from '@/components/common/CookieBanner'
import { theme } from '@/styles/theme'

import '@/styles/globals.css'
import PageLayout from '@/components/common/PageLayout'
import { useGa } from '@/hooks/useGa'
import useHotjar from '@/hooks/useHotjar'
import DOMPurify from 'isomorphic-dompurify'
Expand Down Expand Up @@ -54,8 +55,8 @@ const App = ({
Component: NextPageWithLayout
emotionCache?: EmotionCache
}): ReactElement => {
// Use the layout defined at the page level, if available
const getLayout = Component.getLayout ?? ((page) => page)
// Use the layout defined at the page level, if available or the default layout
const getLayout = Component.getLayout ?? ((page) => <PageLayout>{page}</PageLayout>)

return (
<CacheProvider value={emotionCache}>
Expand Down
15 changes: 4 additions & 11 deletions src/pages/blog/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import type { ReactElement } from 'react'
import type { NextPageWithLayout } from '@/pages/_app'
import BlogPost from '@/components/Blog/Post'
import PageLayout from '@/components/common/PageLayout'
import BlogPost, { type BlogPostProps } from '@/components/Blog/Post'
import { type TypePostSkeleton } from '@/contentful/types'
import client from '@/lib/contentful'
import type { GetStaticProps, InferGetStaticPropsType } from 'next'
import type { GetStaticProps, InferGetStaticPropsType, NextPage } from 'next'

const Page: NextPageWithLayout<InferGetStaticPropsType<typeof getStaticProps>> = (props) => {
const Page: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (props) => {
if (!props.blogPost) return null

return <BlogPost {...props} />
}

Page.getLayout = function getLayout(page: ReactElement) {
return <PageLayout>{page}</PageLayout>
}

export const getStaticProps: GetStaticProps = async ({ params }) => {
export const getStaticProps: GetStaticProps<BlogPostProps> = async ({ params }) => {
const slug = params?.slug as string

const content = await client.getEntries<TypePostSkeleton>({
Expand Down
11 changes: 2 additions & 9 deletions src/pages/blog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@ import client from '@/lib/contentful'
import BlogHome, { type BlogHomeProps } from '@/components/Blog/BlogHome'
import type { TypeBlogHomeSkeleton, TypePostSkeleton } from '@/contentful/types'
import { isEntryTypePost } from '@/lib/typeGuards'
import type { NextPageWithLayout } from '@/pages/_app'
import type { ReactElement } from 'react'
import PageLayout from '@/components/common/PageLayout'
import type { GetStaticProps, InferGetStaticPropsType } from 'next'
import type { GetStaticProps, InferGetStaticPropsType, NextPage } from 'next'

const Blog: NextPageWithLayout<InferGetStaticPropsType<typeof getStaticProps>> = (props) => {
const Blog: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (props) => {
return <BlogHome {...props} />
}

Blog.getLayout = function getLayout(page: ReactElement) {
return <PageLayout>{page}</PageLayout>
}

export const getStaticProps: GetStaticProps<BlogHomeProps> = async () => {
const allPosts = await client.getEntries<TypePostSkeleton>({
content_type: 'post',
Expand Down
11 changes: 2 additions & 9 deletions src/pages/press.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@ import client from '@/lib/contentful'
import PressRoom, { type PressRoomProps } from '@/components/Pressroom'
import type { TypePressRoomSkeleton, TypePostSkeleton } from '@/contentful/types'
import { fetchTotalAssets } from '@/hooks/useSafeStats'
import type { ReactElement } from 'react'
import PageLayout from '@/components/common/PageLayout'
import type { NextPageWithLayout } from '@/pages/_app'
import type { GetStaticProps, InferGetStaticPropsType } from 'next'
import type { GetStaticProps, InferGetStaticPropsType, NextPage } from 'next'

const PressroomPage: NextPageWithLayout<InferGetStaticPropsType<typeof getStaticProps>> = (props) => {
const PressroomPage: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (props) => {
return <PressRoom {...props} />
}

PressroomPage.getLayout = function getLayout(page: ReactElement) {
return <PageLayout>{page}</PageLayout>
}

export const getStaticProps: GetStaticProps<PressRoomProps> = async () => {
const allPosts = await client.getEntries<TypePostSkeleton>({
content_type: 'post',
Expand Down

0 comments on commit c5487ed

Please sign in to comment.