Coder Social home page Coder Social logo

seemoine / next-tinacms-blog-kit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from makerkit/next-tinacms-blog-kit

0.0 0.0 0.0 380 KB

Blog Starter for your next blog, portfolio or online publication using Next.js, Tina CMS and Tailwind CSS.

Home Page: https://makerkit.dev

License: MIT License

Shell 0.07% JavaScript 7.12% TypeScript 78.79% CSS 14.03%

next-tinacms-blog-kit's Introduction

A free and open-source starter by MakerKit.

Blog Starter Template with Next.js, Tina CMS, MDX and Tailwind CSS

This Blog Starter is the perfect foundation for writing your next blog, portfolio or online publication using Next.js, Tina CMS and Tailwind CSS.

Features

  • โœ… Responsive, fast and ready-to-deploy Next.js Blog Starter
  • ๐Ÿ“„ Write your articles with all the power of Tina CMS and MDX
  • โšก Live-reloading MDX content
  • ๐Ÿš€ Search Engine Optimized (SEO) out-of-the-box
  • ๐Ÿ“‚ Sitemap and RSS generated automatically
  • ๐ŸŽจ Dark and Light themes
  • โœจ Written with strict Typescript, validated with EsLint, formatted with Prettier
  • ๐Ÿ‘จโ€๐Ÿ’ป Developed, maintained and used by Makerkit

Getting Started

Clone the repository:

git clone https://github.com/makerkit/next-tinacms-blog-kit

Rename your project and jump into the folder.

Install Node dependencies

Install the Node dependencies:

npm i

Initialize Tina CMS

Initialize Tina CMS with the following command:

npx @tinacms/cli@latest init

When Tina prompts to override your App component, reject by typing "n" (it's already set up):

โœ” do you want us to override your _app.tsx? โ€ฆ no

This command will generate some redundant files; feel free to remove them.

Decorate the following commands with --experimentalData to enable querying and filtering your graphql content with Tina:

"dev": "NODE_ENV=development tinacms server:start -c \"next dev\" --experimentalData",
"build": "tinacms server:start -c \"next build\" --experimentalData",
"start": "tinacms server:start -c \"next start\" --experimentalData",

NB: do not forget to prefix the dev command with NODE_ENV=development.

Setting up the Tina CMS schema

Copy the contents of the file schema.template and override the content of schema.ts. Tina CMS will initialize the correct GraphQL schema based on the schema we provided.

Run the application

Then, run the development server:

npm run dev
# or
yarn dev
  1. Visit http://localhost:3000 to see your blog
  2. Visit http://localhost:3000/admin to access the Tina CMS admin
  3. Visit http://localhost:4001/altair to access the GraphqQL playground

Remove .tina from the .gitignore file, and remember to check it in, so that your builds will be able to use the folder.

Inline Tina Editor

Because Tina lazy-loads the inline editor in production mode, but does not disable it, I thought the best compromise was to dynamicaly add the editor based on a variable.

By default, the editor is loaded only if the URL contains a query parameter named tina. You can change this logic as you prefer in _app.tsx.

Using Tina Cloud?

If you're also using Tina Cloud, remember to add the NEXT_PUBLIC_TINA_CLIENT_ID environment variable, either from a .env file or from your Vercel console (or other provider).

You will find the Client ID environment variable in the Tina CMS Dashboard.

Setting the upstream folder

If you want, reinitialize the git repository and set this repository as your upstream, so you can continue getting updates:

rm -rf .git
git init
git remote add upstream https://github.com/makerkit/next-tinacms-blog-kit

To keep your repository up-to-date with this, use git pull:

git pull upstream main 

Solve the eventual conflicts and merge ๐Ÿ˜ƒ

Configuration

Open the configuration file at ./configuration.ts. It will have the following content:

const configuration = {
  site: {
    name: '',
    description: '',
    themeColor: '',
    siteUrl: '',
    siteName: '',
    twitterHandle: '',
    githubHandle: '',
    language: 'en',
  },
  blog: {
    maxReadMorePosts: 6,
  },
  production: process.env.NODE_ENV === 'production',
};

Update it with your own data, or leave as is to begin with.

Enter the Tina CMS Admin

After starting the development server, access the following URL: https://localhost:3000/admin.

Time to get writing!

Add Articles, Categories and Authors manually

Before creating a blog post, we define which collection it belongs to and the author of the post.

To define a category, create a JSON file at content/categories:

{
  "name": "Tutorials",
  "emoji": "๐Ÿ–ฅ๏ธ"
}

Alternatively, you can choose to assign a picture to each collection (or neither):

{
  "name": "Tutorials",
  "picture": "/assets/images/tutorials.png"
}

Next, we need to add the author of the article. Add a JSON file at _authors:

{
  "name": "MakerKit",
  "picture": "/assets/images/makerkit.png",
  "url": "https://twitter.com/makerkit_dev"
}

We can now create a blog post. Add an MDX file at _posts:

---
title: 'Dextera Sibi Orbes'
category: 'content/categories/lorem-ipsum.json'
author: 'content/authors/makerkit.json'
date: 2022-03-30
live: true
image: ''
description: "Lorem markdownum ictu; leti quae, paenituisse venere. Liquet praemia omne di
amarunt dicta."
---

As you can see, the properties category and author are references to the path of each.

Deploy on Vercel

The easiest way to deploy this app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

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.