Skip to content

feat: add new blog page #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fd1a7a6
feat: add new blog page
leandrocunha Aug 18, 2023
be05cb8
feat: rewrite scss file to remove unused module
leandrocunha Aug 18, 2023
c103ddb
feat: remove unnecessary image function
leandrocunha Aug 18, 2023
7887ccd
feat: refactor post.description and replace small tag to use span ins…
leandrocunha Aug 18, 2023
6239a8e
feat: update import to use @use instead
leandrocunha Aug 18, 2023
7113f3e
feat: use css variables for colors instead hex values
leandrocunha Aug 18, 2023
1c46e10
feat: test pre-commit hook
leandrocunha Aug 18, 2023
fbd1bc9
feat: revert import lines change
leandrocunha Aug 18, 2023
a23afdb
feat: remove modules from ArticlePreview and ArticleAuthor styles
leandrocunha Aug 18, 2023
615c1e1
feat: remove unnecessary div element
leandrocunha Aug 19, 2023
4b16daa
feat: enhance CSS for the desktop version
leandrocunha Aug 21, 2023
4618cbe
feat: Update image size to be full width
leandrocunha Aug 21, 2023
6bd27d6
feat: add SubscriptionBanner component
leandrocunha Aug 22, 2023
3acc8f3
feat: add CSS transition
leandrocunha Aug 22, 2023
2badf82
feat: add graphql playground for development
leandrocunha Aug 22, 2023
2883b55
feat: update to use function instead import
leandrocunha Aug 23, 2023
bfe08d8
fix: default typography font parameter
leandrocunha Aug 23, 2023
ebead89
feat: update block class to match the component name
leandrocunha Aug 23, 2023
b7d277a
feat: move SubscriptionBanner to the components folder
leandrocunha Aug 23, 2023
d46a73a
feat: refactor props
leandrocunha Aug 23, 2023
ff38c5e
feat: rename handleClick to it load more posts purpose
leandrocunha Aug 23, 2023
98c94a5
fix: SubscriptionBanner import in LandingPage component
leandrocunha Aug 23, 2023
3d82ff2
feat: add Blog page link to the main menu
leandrocunha Aug 23, 2023
927114b
fix: update blog title size for different screen sizes
leandrocunha Aug 23, 2023
3a81e67
feat: move article auhtor icon to a svg file
leandrocunha Aug 23, 2023
af0e814
feat: add slug to blog posts
leandrocunha Aug 23, 2023
de6999e
fix: page size typo
leandrocunha Aug 23, 2023
b3fb982
feat: refactor articlepreview css
leandrocunha Aug 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ exports.createPages = async ({ graphql, actions, reporter }) => {
{
allContentfulBlogPost {
nodes {
id
title {
title
}
slug
}
}
}
Expand All @@ -44,14 +41,14 @@ exports.createPages = async ({ graphql, actions, reporter }) => {

if (posts.length > 0) {
posts.forEach((post, index) => {
const previousPostSlug = index === 0 ? null : posts[index - 1].id;
const nextPostSlug = index === posts.length - 1 ? null : posts[index + 1].id;
const previousPostSlug = index === 0 ? null : posts[index - 1].slug;
const nextPostSlug = index === posts.length - 1 ? null : posts[index + 1].slug;

createPage({
path: `/blog/${post.id}/`,
path: `/blog/${post.slug}/`,
component: blogPost,
context: {
id: post.id,
slug: post.slug,
previousPostSlug,
nextPostSlug,
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"predev": "node ./bin/gen-antd-css.js && gatsby develop -p 8080",
"dev": "gatsby develop -p 8080",
"graphql:win": "cross-env GATSBY_GRAPHQL_IDE=playground gatsby develop",
"prebuild": "cross-env NODE_ENV=production node ./bin/gen-antd-css.js",
"build": "gatsby build",
"serve": "gatsby serve",
Expand Down
19 changes: 19 additions & 0 deletions src/components/ArticleAuthor/ArticleAuthor.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';

import { createBemBlockBuilder } from '../../utils';
import AuthorIcon from './icons/author.inline.svg';

import './ArticleAuthor.scss';

const getBlocksWith = createBemBlockBuilder(['article-author']);

export const ArticleAuthor = ({ authorName }) => {
return (
<p className={getBlocksWith()}>
<span className={getBlocksWith('__icon')}>
<AuthorIcon />
</span>
{authorName}
</p>
);
};
14 changes: 14 additions & 0 deletions src/components/ArticleAuthor/ArticleAuthor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@use 'src/styles/mixins' as m;
@use 'src/styles/variables' as v;

.article-author {
@include m.font-poppins(v.$fw-medium);

color: var(--text-service);
display: flex;
margin-bottom: 0;

&__icon {
margin-right: 8px;
}
}
4 changes: 4 additions & 0 deletions src/components/ArticleAuthor/icons/author.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 23 additions & 9 deletions src/components/ArticlePreview/ArticlePreview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,39 @@ import React from 'react';
import { Link } from 'gatsby';
import { renderRichText } from 'gatsby-source-contentful/rich-text';

import * as styles from './ArticlePreview.module.scss';
import { ArticleAuthor } from '../ArticleAuthor/ArticleAuthor';
import { createBemBlockBuilder } from '../../utils';

import './ArticlePreview.scss';

const getBlocksWith = createBemBlockBuilder(['article-preview-list']);

export const ArticlePreview = ({ posts }) => {
if (!posts) return null;
if (!Array.isArray(posts)) return null;

return (
<div className="container">
<ul className={styles.articleList}>
<ul className={getBlocksWith()}>
{posts.map(post => {
return (
<li key={post.id}>
<Link to={`/blog/${post.id}`} className={styles.link}>
<h2 className={styles.title}>{post.title.title}</h2>
<li className={getBlocksWith('__item')} key={post.id}>
<Link to={`/blog/${post.slug}`} className={getBlocksWith('__link')}>
<div className={getBlocksWith('__featured-image')}>
<img alt={post.title.title} src={post.featuredImage.file.url} />
</div>
<div className={getBlocksWith('__content')}>
<p className={getBlocksWith('__category')}>{post.category}</p>

<h2 className={getBlocksWith('__title')}>{post.title.title}</h2>
{post.description?.raw && <div>{renderRichText(post.description)}</div>}
<div className={getBlocksWith('__meta')}>
<span className="meta">{post.publishDate}</span>
</div>
<p className={getBlocksWith('__excerpt')}>{post.leadParagraph.leadParagraph}</p>
<ArticleAuthor authorName={post.author} />
</div>
</Link>
<div>{post.description?.raw && renderRichText(post.description)}</div>
<div className={styles.meta}>
<small className="meta">{post.publishDate}</small>
</div>
</li>
);
})}
Expand Down
26 changes: 0 additions & 26 deletions src/components/ArticlePreview/ArticlePreview.module.scss

This file was deleted.

90 changes: 90 additions & 0 deletions src/components/ArticlePreview/ArticlePreview.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
@use 'src/styles/mixins' as m;
@use 'src/styles/variables' as v;

.article-preview-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
grid-gap: calc(4 * var(--base-spacing)) calc(3 * var(--base-spacing));

&__item {
background-color: var(--white);
border-radius: 16px;
box-shadow: 0px 8px 16px 0px rgba(0, 45, 55, 0.12);
color: var(--text-primary);
display: flex;
flex-direction: column;
transition: var(--basic-transition);

&:hover,
&:active {
box-shadow: 0px 8px 32px 0px rgba(0, 45, 55, 0.12);
}

&:hover {
.article-preview-list {
&__title {
color: var(--color-primary-500);
}
}
}

&:active {
.article-preview-list {
&__title {
color: var(--color-primary-700);
}
}
}
}

&__featured-image {
border-top-left-radius: calc(2 * var(--base-spacing));
border-top-right-radius: calc(2 * var(--base-spacing));
overflow: hidden;
}

&__content {
display: flex;
flex: 1;
flex-direction: column;
padding: calc(3 * var(--base-spacing));
}

&__category {
@include m.font-poppins(v.$fw-semi-bold);
@include m.font-scale(small);

color: var(--text-service);
letter-spacing: 1px;
margin: 0;
text-transform: uppercase;
}

&__link {
display: flex;
flex: 1;
flex-direction: column;
text-decoration: none;
}

&__title {
@include m.font-poppins(v.$fw-semi-bold);
@include m.font-scale(medium);

display: inline-block;
margin: calc(2 * var(--base-spacing)) 0;
border-bottom: 1.5px solid transparent;
transition: var(--basic-transition);
}

&__meta {
display: flex;
justify-content: space-between;
}

&__excerpt {
flex-grow: 1;
line-height: calc(3 * var(--base-spacing));
margin: 0;
}
}
Loading