-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from saharshy29/add-blog
Add blog with CMS
- Loading branch information
Showing
26 changed files
with
523 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@use 'styles/colors'; | ||
@use 'styles/breakpoints'; | ||
@use 'styles/functions' as *; | ||
|
||
$radial-size: 0.75px; | ||
|
||
.root { | ||
margin: 1em; | ||
margin-top: 0; | ||
background-image: radial-gradient(colors.$primary $radial-size, transparent $radial-size); | ||
background-size: css-calc(10 * $radial-size) css-calc(10 * $radial-size); | ||
|
||
@media (max-width: breakpoints.$tablet) { | ||
margin-top: 1em; | ||
} | ||
} | ||
|
||
.wrapper { | ||
background-color: map-get(colors.$background, primary); | ||
transform: translate(20px, -20px); | ||
padding-left: 0.5em; | ||
padding-bottom: 0.5em; | ||
padding-top: 10px; | ||
} | ||
|
||
.icon { | ||
font-size: 0.85em; | ||
} | ||
|
||
.posts { | ||
margin-top: 0.5em; | ||
} | ||
.post + .post { | ||
margin-top: 0.75em; | ||
} | ||
|
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,43 @@ | ||
import { useContext } from 'react'; | ||
|
||
import { FaBookmark } from 'react-icons/fa'; | ||
import FeaturedPost from './FeaturedPost'; | ||
import featured from './Featured.module.scss'; | ||
|
||
import { PostsContext } from '../../pages/blog/index'; | ||
|
||
const Featured = () => { | ||
const posts = useContext(PostsContext); | ||
const featuredPosts = posts | ||
.filter((post) => post.featured === true) | ||
.sort(() => 0.5 - Math.random()) | ||
.slice(0, 3); | ||
|
||
featuredPosts.map((post) => { | ||
post.tagList = post.tags.map((tag) => tag.name).join(' '); | ||
}); | ||
|
||
return ( | ||
<div className={featured.root}> | ||
<div className={featured.wrapper}> | ||
<h2> | ||
<FaBookmark className={featured.icon} /> Featured | ||
</h2> | ||
<div className={featured.posts}> | ||
{featuredPosts.map((post) => ( | ||
<div className={featured.post}> | ||
<FeaturedPost | ||
key={post.uuid} | ||
slug={post.slug} | ||
title={post.title} | ||
tags={post.tagList} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Featured; |
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,13 @@ | ||
@use 'styles/colors'; | ||
|
||
.root { | ||
font-size: 0.8em; | ||
|
||
p { | ||
color: colors.$gray; | ||
} | ||
|
||
h3:hover { | ||
text-decoration: underline; | ||
} | ||
} |
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,18 @@ | ||
import Link from 'next/link'; | ||
|
||
import styles from './FeaturedPost.module.scss'; | ||
|
||
const FeaturedPost = (props) => { | ||
return ( | ||
<Link as={`/blog/${props.slug}`} href="/blog/[slug]"> | ||
<a> | ||
<div className={styles.root}> | ||
<h3>{props.title}</h3> | ||
<p>{props.tags}</p> | ||
</div> | ||
</a> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default FeaturedPost; |
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,51 @@ | ||
@use 'styles/colors'; | ||
|
||
.root { | ||
margin-top: 1em; | ||
input { | ||
background-color: map-get(colors.$background, secondary); | ||
padding: 0.5em 1em; | ||
width: 100%; | ||
color: map-get(colors.$text, primary); | ||
border-radius: max(0.3em, 5px); | ||
outline: none; | ||
border: none; | ||
font-size: 1rem; | ||
|
||
&[type='submit'] { | ||
color: colors.$white; | ||
background-color: colors.$gray; | ||
transition: all 0.1s ease-in-out; | ||
|
||
&:hover, | ||
&:active { | ||
cursor: pointer; | ||
} | ||
|
||
&:hover { | ||
transform: scale(1.08); | ||
} | ||
|
||
&:active { | ||
transform: scale(1); | ||
} | ||
} | ||
} | ||
|
||
label { | ||
font-size: 0.8rem; | ||
padding: 0.25em 1em; | ||
} | ||
} | ||
|
||
.group + .group { | ||
display: flex; | ||
flex-direction: column; | ||
margin-top: 0.5em; | ||
} | ||
|
||
.inline { | ||
display: grid; | ||
grid-template-columns: 7fr 3fr; | ||
grid-gap: 0.5em; | ||
} |
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,22 @@ | ||
import form from './Form.module.scss'; | ||
|
||
const Form = () => { | ||
return ( | ||
<div className={form.root}> | ||
<h2>Newsletter</h2> | ||
<div className={form.group}> | ||
<input type="email" name="email" placeholder="Email" required /> | ||
{/* <label>Email</label> */} | ||
</div> | ||
<div className={form.group}> | ||
<div className={form.inline}> | ||
<input type="text" name="name" placeholder="First Name" /> | ||
{/* <label>First Name</label> */} | ||
<input type="submit" className={form.btn} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Form; |
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,17 @@ | ||
@use 'styles/colors'; | ||
@use 'styles/breakpoints'; | ||
|
||
.root { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
// gap: 1em; | ||
|
||
@media (max-width: breakpoints.$tablet) { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
} | ||
|
||
.wrapper:nth-of-type(2) { | ||
padding-top: 15px; | ||
} |
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,19 @@ | ||
import header from './Header.module.scss'; | ||
import Form from './Form'; | ||
import Featured from './Featured'; | ||
|
||
const Header = () => { | ||
return ( | ||
<div className={header.root}> | ||
<div className={header.wrapper}> | ||
<h1>Thoughts.</h1> | ||
<Form /> | ||
</div> | ||
<div className={header.wrapper}> | ||
<Featured /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Header; |
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,20 @@ | ||
@use 'styles/colors'; | ||
|
||
.root { | ||
font-size: 0.8em; | ||
max-width: 65ch; | ||
margin: 1.5em auto; | ||
|
||
h2:hover { | ||
text-decoration: underline; | ||
} | ||
} | ||
|
||
.meta { | ||
color: colors.$gray; | ||
} | ||
|
||
.icon { | ||
font-size: 0.8em; | ||
margin-left: 0.25em; | ||
} |
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,24 @@ | ||
import Link from 'next/link'; | ||
import { FaExternalLinkAlt } from 'react-icons/fa'; | ||
import postPreview from './PostPreview.module.scss'; | ||
|
||
const PostPreview = (props) => { | ||
return ( | ||
<Link as={`/blog/${props.slug}`} href="/blog/[slug]"> | ||
<a> | ||
<div className={postPreview.root}> | ||
<h2> | ||
{props.title} <FaExternalLinkAlt className={postPreview.icon} /> | ||
</h2> | ||
<p className={postPreview.meta}> | ||
{props.pubDate} | {props.readTime} | {props.tags} | ||
</p> | ||
<hr /> | ||
<p>{props.excerpt}</p> | ||
</div> | ||
</a> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default PostPreview; |
File renamed without changes.
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 |
---|---|---|
|
@@ -13,6 +13,6 @@ | |
.contentWrapper { | ||
padding: 0.5em 1em; | ||
margin: 0 auto; | ||
width: 100%; | ||
max-width: 65ch; | ||
max-width: 750px; | ||
} |
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,22 @@ | ||
import GhostContentAPI from '@tryghost/content-api'; | ||
|
||
// Create API instance with site credentials | ||
const api = new GhostContentAPI({ | ||
url: 'https://shuy.ghost.io', | ||
key: '4b1a5b85b966c4f3072ca8b307', // This shouldn't be publicly exposed, but it's not a big deal since it will not work soon enough, and even now, it does not provide access to much. | ||
version: 'v3', | ||
}); | ||
|
||
export async function getPosts() { | ||
return await api.posts | ||
.browse({ | ||
include: 'tags', | ||
limit: 'all', | ||
}) | ||
.catch((err) => { | ||
// eslint-disable-next-line no-console | ||
console.error(err); | ||
}); | ||
} | ||
|
||
export default getPosts(); |
Oops, something went wrong.
b5c73e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: