Salute folks. For a while now, I have wanted to create a personal blog where I can share my experiences with others and keep an organized document of what I have learned or discovered. Although it is not completely finished, I have completed most of my blog. I will share with you the technologies I used while developing this blog and my experiences as a developer. First of all, here are the technologies I used.
- Next.js 13 ve App Router
- Sanity CMS
- Next-auth
- MongoDB
1. Next.js 13 and App Router #
I had already tried Next.js 13 in a few projects before this one. App Router allows the application to be scalable. Also in this project, I needed a language select component with both dynamic and static links because I wanted the SEO scope of the project to be very wide. Previously, for my dynamically generated blog posts, I had used the same url for different languages as en/a-post-slug, tr/a-post-slug and de/a-post-slug, but for a better SEO experience, in this project, I was able to create the relevant translated page of an en/a-post-slug page as new static pages with en/a-post-slug and de/eine-post-slug links. I shared with you how I solved this problem hereuseRouter from 'next/router
, would have made my job much easier. Also, error handling can get a bit complicated when you use the App Router [locale] dynamic folder. You can have more ideas about this by checking this issue
2. Sanity CMS #
My adventure with CMS tools started with Gatsby.js and Netlify CMS. Then I discovered Contentful CMS while looking for a Content Management System that supports multilingual structure in my company and I developed 2 big landing pages of the company integrated with Contentful CMS. Contentful CMS has very rich tools both in terms of content editor and developer experience, but the rich text editor does not support custom code blocks and I wanted to use and edit code blocks on this blog. Another problem is that Contentful's free plan only allows 2 languages. However, I wanted 3 (for now) language options on my blog. While looking for a free CMS tool that would fulfill this requirement, I came across Sanity. The great thing about Sanity is that it supports multiple language options for free. In addition, you can define the schemas of your content in your code and develop a type-safe application. I post all my posts on this site, including this post I'm writing right now, from Sanity's admin panel.
Sanity offers 2 types of translation options. The first option is field based translation. In summary, if you have a field called name in a document, you have as many inputs for it as n (n represents the number of language options here) languages and you need to filter from these fields according to your current language while querying your document. This document is very useful if you have a few fields in your schema, but as your schemas grow, it becomes a bit difficult to see and organize n inputs for 1 field in a single document. I explained the details here
3. Next-Auth #
Next-auth is a great npm package. I wanted to add an area on this site so that you, the readers, can post comments. I used this library and GoogleProvider, one of the dozens of auth provider services it provides, so that you can log in with google while posting comments. With this package, you can log in securely with your Google account, comment under my posts, ask questions and interact with me. Leave a comment :)
4.MongoDB #
MongoDB is my favorite database for many projects thanks to its easy installation and generous free package. In this project, I'm using MongoDB to store user comments. Although I'm currently trying to learn Prisma and Sql, I think MongoDB is always useful on a small scale. I store your comments in MongoDB. Below I shared how I'm saving your comments using Next.js api routes. Your comments. Your comments...
To summarize, this project started as a simple blog and has taught me a lot while adding something to it every day. Every day, I will try to share my experiences with you while continuing these and many more new developments. I would be happy if you share any comments, criticisms or feedback with me. Thank you for reading :)