Nextblog is the best GraphQL Blog Application with everything you can imagine - built with NextJS
Nextblog is an outstanding Blog Application with featured and recent posts, categories, full markdown articles, author information, comments, and much more, works with Hygraph. hygraph is a headless content management system based on GraphQL technology enabling seamless integration with any application.
Nextblog code folder structure
Nextblog/
|- components/
|- pages/
|-- api/
|-- category/
|-- post/
|- sections/
|- services/
|- styles/
Now, lets dive into the main folder
Author.jsx
- Categories.jsx
- Comments.jsx
- CommentsForm.jsx
- FeaturedPostCard.jsx
- Header.jsx
- Layout.jsx
- Loader.jsx
- PostCard.jsx
- PostDetail.jsx
- PostWidget
- index.js
This folder contains all React Components, which they're independent and reusable bits of code. They serve the UI (User Interface) of Nextblog to avoid unnecessary repetition of the code. those components are beautiful customized widgets using TailwindCSS to describe theme for widgets as they're named.
_app.js
- index.js
- category
- post
- api
this folder contains activities / scenes of application as a exported react arrow function components. this folder contains a well-structured activities / scenes of applications using NextJS Best Practices. Nextblog includes Home page, Dynamic Categories & Blogposts pages.
FeaturedPosts.jsx
file implement the featured posts sections using React-Multi-Carousel
index.js
- This script exports multiple GraphQL queries for a blog website. The queries retrieve information about posts, post details, recent posts, similar posts, featured posts, adjacent posts, posts belonging to a specific category, and categories. The queries use the GraphQL request library to send the queries to the Hygraph endpoint specified in the graphqlAPI environment variable.
For example, Here is getPostDetails
function
export const getSimilarPosts = async (categories, slug) => {
const query = gql`
query GetPostDetails($slug: String!, $categories: [String!]) {
posts(
where: {
slug_not: $slug
AND: { categories_some: { slug_in: $categories } }
}
last: 3
) {
title
featuredImage {
url
}
createdAt
slug
}
}
`;
const result = await request(graphqlAPI, query, { categories, slug });
return result.posts;
};
global.scss
file is the stylesheet file written in SCSS and uses the Tailwind CSS framework. It defines the default styles and custom styles for the HTML elements and components used in a web page.
In order to use Nextblog you have to add the following environment variable to your .env file
NEXT_PUBLIC_GRAPHCMS_ENDPOINT=<HYGRAPH_ENDPOINT>
GRAPHCMS_TOKEN=<HYGRAPH_TOKEN>
Download or clone this repo by using the link below:
https://github.com/ladunjexa/GraphQL-Nextblog
Nextblog using NPM
(Node Package Manager) Yarn
, therefore, make sure that Node.js is installed by execute the following command in consle
node -v
Go to root folder and execute the following command to get the required packages:
npm install
At the root folder execute the following command in order to run the development sever:
npm run dev
#or
yarn dev
Contributions are always welcome!
See contributing.md
for ways to get started.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt for more information.
Liron Abutbul - @lironabutbul6 - @ladunjexa
Project Link: https://github.com/ladunjexa/GraphQL-Nextblog
This section used to mention useful resources and libraries (packages) that used in Nextblog application project.