Coder Social home page Coder Social logo

damurq / blog-strapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marktawa/blog-strapi

0.0 0.0 0.0 23.49 MB

Blog website using Strapi for the backend and Next.js for the frontend

Home Page: https://strapi.io/blog/build-a-blog-with-next-react-js-strapi

License: MIT License

JavaScript 21.95% TypeScript 73.52% CSS 4.53%

blog-strapi's Introduction

Blog using Next.js and Strapi

TUTORIAL LINK

NOTE:

This project is based on the Strapi Starter Next 13, Tailwind, Typescript, and Strapi made by Trecia, Daniel and Paul from the Strapi Team.

Introduction

This project is a code repo for the Strapi blog article Build a blog with Next.js and Strapi.

Getting Started

  1. Clone the repo locally:
git clone https://github.com/Marktawa/blog-strapi
  1. Set up backend dependencies:
cd blog-strapi
cd backend
yarn
  1. Set up environment variables:
cp .env.example .env
  1. Start your project by running the following command:
  yarn build
  yarn develop

Create your first admin user.

admin-user

Seeding the Data

At the root of our project, we have our seed-schema.tar file. We will use it to update the schema for our Strapi app.

  1. Go back to your terminal and stop your Strapi backend server by pressing CTRL plus C on your keyboard.

  2. Run the following command in the root of your project folder blog-strapi to update the schema:

tar xvf seed-schema.tar -C backend
  1. Import data into your backend's database:
cd backend
yarn strapi import -f ../seed-data.tar.gz

Answer y to The import will delete all assets and data in your database. Are you sure you want to proceed? (y/N)

  1. After a successful import, rerun your Strapi backend server.
yarn develop

In your browser, log in to your admin panel. You should see the newly imported content and collection types.

after-import

Frontend Setup

  1. Open up a new terminal session and navigate into your frontend folder. Set up frontend dependencies:
cd frontend
yarn
  1. Create .env file:
touch .env
  1. Paste in the following.
NEXT_PUBLIC_STRAPI_API_TOKEN=your-api-token
NEXT_PUBLIC_PAGE_LIMIT=6
NEXT_PUBLIC_STRAPI_API_URL=http://127.0.0.1:1337
  1. Before starting our Next JS app we need to go inside our Strapi Admin and create a token that we will be using for displaying our content.

Inside your Strapi Admin Panel navigate to Settings -> API Tokens and click on the Create new API Token.

api-tokens

Here are our Token Settings

Name: Public API Token Content Description: Access to public content. Token duration: Unlimited Token type: Custom

In Permissions let's give the following access.

Content Permissions
Article find and findOne
Author find and findOne
Category find and findOne
Global find
Page find and findOne
Product-feature find and findOne

permissions

Once you have your token add it to your NEXT_PUBLIC_STRAPI_API_TOKEN variable name in the .env file.

  1. Start your frontend
yarn dev

blog-strapi's People

Contributors

marktawa avatar abeezurrehman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.