This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
156 additions
and
0 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,58 @@ | ||
import React from 'react' | ||
import moment from 'moment' | ||
import Layout from 'features/components/templates/layout' | ||
import * as styles from './posts.module.scss' | ||
import Typography from 'features/components/atoms/typography' | ||
import { Localize } from 'components/localization' | ||
import Flex from 'features/components/atoms/flex-box' | ||
import Link from 'features/components/atoms/link' | ||
import dclsx from 'features/utils/dclsx' | ||
|
||
const PostsModule = ({ data }: TBlogPosts) => { | ||
const posts = data?.allStrapiPost?.nodes || [] | ||
console.log(data, 'www') | ||
return ( | ||
<Layout> | ||
<Flex.Box margin_block="12x" direction="col" className={styles.posts_wrapper}> | ||
<Typography.Heading as="h2" size="small"> | ||
<Localize translate_text={'_t_Recent articles_t_'} /> | ||
</Typography.Heading> | ||
|
||
<Flex.Box wrap="wrap" margin_block="15x" justify="around"> | ||
{posts?.map(({ hero }) => { | ||
const { title, banner, date } = hero | ||
const parsedDate = moment(date) | ||
const formattedDate = parsedDate?.format('Do [of] MMMM YYYY') | ||
return ( | ||
<Flex.Box direction="col" key={title} className={styles.image_wrapper}> | ||
<Link url={{ type: 'internal', to: '/' }} no_hover> | ||
<img | ||
src={banner?.localFile?.publicURL} | ||
className={styles.post_image} | ||
/> | ||
</Link> | ||
<div className={dclsx('margin-block-10x')}> | ||
<Link url={{ type: 'internal', to: '/' }} no_hover> | ||
<Typography.Heading as="h3" size="xxs"> | ||
<Localize translate_text={`_t_${title}_t_`} /> | ||
</Typography.Heading> | ||
</Link> | ||
<div | ||
className={dclsx( | ||
'text-medium', | ||
'typography-color-gray-shade', | ||
)} | ||
> | ||
{formattedDate || ''} | ||
</div> | ||
</div> | ||
</Flex.Box> | ||
) | ||
})} | ||
</Flex.Box> | ||
</Flex.Box> | ||
</Layout> | ||
) | ||
} | ||
|
||
export default PostsModule |
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,27 @@ | ||
@use 'features/styles/theme/theme-mixins' as *; | ||
|
||
.post_image { | ||
max-width: 42rem; | ||
width: 98%; | ||
height: 25rem; | ||
@include breakpoints(tablet) { | ||
height: 14rem; | ||
} | ||
} | ||
.posts_wrapper { | ||
margin-inline: 2%; | ||
|
||
@include breakpoints(laptop) { | ||
margin-inline: 12%; | ||
} | ||
} | ||
|
||
.image_wrapper { | ||
flex-basis: unset; | ||
@include breakpoints(phone) { | ||
flex-basis: 48%; | ||
} | ||
@include breakpoints(tablet) { | ||
flex-basis: 18%; | ||
} | ||
} |
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,21 @@ | ||
type StrapiImage = { | ||
localFile: { | ||
publicURL: string | ||
} | ||
} | ||
type Thero = { | ||
title: string | ||
date: Date | ||
tags: string | ||
banner: StrapiImage | ||
} | ||
|
||
type TBlogPosts = { | ||
data: { | ||
allStrapiPost: { | ||
nodes: { | ||
hero: Thero | ||
}[] | ||
} | ||
} | ||
} |
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,36 @@ | ||
import React from 'react' | ||
import { graphql } from 'gatsby' | ||
import { TGatsbyHead } from 'features/types' | ||
import { SEO } from 'components/containers' | ||
import { WithIntl } from 'components/localization' | ||
import PostsModule from 'features/pages/posts' | ||
|
||
const BlogPosts = ({ data }: TBlogPosts) => { | ||
return <PostsModule data={data} /> | ||
} | ||
|
||
export default WithIntl()(BlogPosts) | ||
|
||
export const query = graphql` | ||
query { | ||
allStrapiPost(sort: { fields: createdAt, order: DESC }, limit: 10) { | ||
nodes { | ||
createdAt | ||
hero { | ||
title | ||
date | ||
tags | ||
banner { | ||
localFile { | ||
publicURL | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` | ||
|
||
export const Head = ({ pageContext }: TGatsbyHead) => ( | ||
<SEO title="_t__t_" description="_t_._t_" pageContext={pageContext} /> | ||
) |