A New Space Race Has Quietly Begun

Unless you have been living under a rock recently (which is understandable; what with Covid still lurking about), you would have noticed the privateer space race finally come to fruition. SpaceX…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to install Contentlayer in nextjs?

Nextjs + Markdown + Content layer

Build an entire static blog with markdown and content layer — full support of Home, tag, search, SEO, sitemap and pagination. #series 1

The content layer is a new javascript content management library. The content layer help organise your markdown file.

Benefits of the content layer

My project builds with javascript, and I’m not using typescript in my content layer.

The happiest news with the content layer npm package. With the content layer, you do not need gray-matter and markednpm package. The content layer itself handles all markdown functionality.

Edit Configuration of a content layer inside nextjs. You change the code into two files.

If you use javascript in nextjs, you copy and paste the following code into your next.config.js file.

If you use typescript in your nextjs project. then you copy and paste the following code into your next.config.mjs file.

The code is the same for both next.config.js and next.config.mjs file.

The tsconfig.json file use for typescript and jsconfig.json file use for javascript.

If you use javascript. paste the following code into jsconfig.json

If you are using javascript. the paste the following code into tsconfig.json .

After the code, add your tsconfig.json file looks like.

At the root level, you create contentlayer.config.js file in your project and add your markdown schema and source for your markdown posts in the project.

For this project, I’m using markdown for our blog and my contentlayer.config.js file look.

I like the content layer for not does have an Automatic type definition, Built-in validations and Live reloading. But I’m using the content layer for Clean code, which is better readability and understandability. With the content layer, you achieve blog functionality with a few lines of code.

Suppose you read my previous series on markdown. You know I write code is a little bit messy. On the other hand, the content layer provides clean code syntax, and you can easily add other functionality to the blog.

I start the entire series on the content layer with markdown in nextjs. In series, we create a full-function blog with static generation.

Read More content on the Nextjs. Sign up for a free newsletter and join the frontend web community on medium

Add a comment

Related posts:

How To Boost Your Credit Score With A Quick Strategy?

All individuals are having different credit scores. If we talk about financial privileges, it is necessary to have a good credit score. Without a good score, you cannot get approval for any credit…

Aura Pool is a unique platform in the world of NFT marketplaces.

Aura Pool is a unique platform in the world of NFT (Non-Fungible Token) marketplaces. It is a platform that offers an exclusive opportunity for individuals to invest in hashrate collectibles, and it…

Making the difference you were born to make

I recently had a conversation with a friend who is on the threshold of a new venture. He has worked hard to achieve the required qualification and experience. He wholeheartedly believes in it, knows…