-
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 #49 from saharshy29/blog-cms
Integrate UI with GhostCMS
- Loading branch information
Showing
16 changed files
with
258 additions
and
139 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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
@use 'styles/colors'; | ||
|
||
.root { | ||
font-size: 0.8em; | ||
font-size: 0.8em; | ||
|
||
p { | ||
color: colors.$gray; | ||
} | ||
} | ||
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
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 |
---|---|---|
@@ -1,11 +1,20 @@ | ||
@use 'styles/colors'; | ||
|
||
.root { | ||
font-size: 0.8em; | ||
max-width: 65ch; | ||
margin: 1.5em auto; | ||
font-size: 0.8em; | ||
max-width: 65ch; | ||
margin: 1.5em auto; | ||
|
||
h2:hover { | ||
text-decoration: underline; | ||
} | ||
} | ||
|
||
.meta { | ||
color: colors.$gray; | ||
} | ||
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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(); |
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,55 @@ | ||
import { GetStaticProps, GetStaticPaths } from 'next'; | ||
import { useRouter } from 'next/router'; | ||
import Layout from '../../components/Layouts/Layout'; | ||
import Copy from '../../components/Copy'; | ||
|
||
import { getPosts } from '../api/posts'; | ||
|
||
const Post = (props) => { | ||
const { slug } = useRouter().query; | ||
let post = props.posts.filter((p) => p.slug === slug); | ||
post = post[0]; | ||
|
||
return ( | ||
<Layout> | ||
<h1>{post.title}</h1> | ||
<p>{post.tagList}</p> | ||
<hr /> | ||
<Copy> | ||
<div dangerouslySetInnerHTML={{ __html: post.html }} /> | ||
</Copy> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default Post; | ||
|
||
export const getStaticProps = async () => { | ||
const posts = await getPosts(); | ||
|
||
posts.map((post) => { | ||
post.dateFormatted = new Intl.DateTimeFormat('en-US', { | ||
year: 'numeric', | ||
month: 'short', | ||
day: 'numeric', | ||
}).format(new Date(post.published_at)); | ||
}); | ||
|
||
posts.map((post) => { | ||
post.tagList = post.tags.map((tag) => tag.name).join(' '); | ||
}); | ||
|
||
return { | ||
props: { | ||
posts, | ||
}, | ||
}; | ||
}; | ||
|
||
export async function getStaticPaths() { | ||
const posts = await getPosts(); | ||
return { | ||
paths: posts?.map((post) => `/blog/${post.slug}`), | ||
fallback: false, | ||
}; | ||
} |
Oops, something went wrong.