mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 19:41:02 +08:00
refactor: update blog post directory structure
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
---
|
||||
title: Example Draft Post
|
||||
author: Sat Naing
|
||||
pubDatetime: 2022-06-06T04:06:31Z
|
||||
slug: example-draft-post
|
||||
featured: false
|
||||
draft: true
|
||||
tags:
|
||||
- TypeScript
|
||||
- Astro
|
||||
description:
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
|
||||
incididunt ut labore et dolore magna aliqua. Praesent elementum facilisis leo vel
|
||||
fringilla est
|
||||
---
|
||||
|
||||
Users cannot see this post because it is in draft.
|
||||
|
||||
## Motivation
|
||||
|
||||
rec 1
|
||||
@@ -0,0 +1,104 @@
|
||||
---
|
||||
title: How Do I Develop My Portfolio Website & Blog
|
||||
author: Sat Naing
|
||||
pubDatetime: 2022-03-25T16:55:12.000+00:00
|
||||
slug: how-do-i-develop-my-portfolio-and-blog
|
||||
featured: false
|
||||
draft: false
|
||||
tags:
|
||||
- NextJS
|
||||
- TailwindCSS
|
||||
- HeadlessCMS
|
||||
- Blog
|
||||
description:
|
||||
"EXAMPLE POST: My experience about developing my first portfolio website and a blog
|
||||
using NextJS and a headless CMS."
|
||||
---
|
||||
|
||||
> This article is originally from my [blog post](https://satnaing.dev/blog/posts/how-do-i-develop-my-portfolio-and-blog). I put this article to demonstrate how you can write blog posts/articles using AstroPaper theme.
|
||||
|
||||
My experience about developing my first portfolio website and a blog using NextJS and a headless CMS.
|
||||
|
||||

|
||||
|
||||
## Motivation
|
||||
|
||||
I've been always thinking about launching my own website with my custom domain name (**satnaing.dev**) since my college student life. But that never happened until this project. I've done several projects and works about web application development but I didn't make an effort to do this.
|
||||
|
||||
So, "what about blog?" you may ask. Yeah, blog also has been in my project list for some time. I always wanted to make a blog project using some of the latest technologies. However, I've been busy with my works and other projects so that blog project has never been started.
|
||||
|
||||
In these days, I tend to develop my own projects with the focus in good quality rather than quantity. After the project is done, I usually put a proper readme file in the Github repo. But Github repo readme is only suitable for technical aspects (this is just my thought). I want to write down my experiences and challenges. Thus, I decided to make my own blog. Plus, at this point, I have decent experiences and confidence to develop this project.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
For the front-end, I wanted to use [React](https://reactjs.org/ "React Official Website"). But React alone is not good enough for SEO; and I did have to consider many factors like routing, image optimization etc. So, I chose [NextJS](https://nextjs.org/ "NextJS Official Website") as my main front-end stack. And of course TypeScript for type checking. (It's said that you'll love TypeScript when you're used to it 😉)
|
||||
|
||||
For styling, I use [TailwindCSS](https://tailwindcss.com/ "Tailwind CSS Official Website"). This is because I love developer experience that Tailwind gives and it has a lot of flexibilities compared to other component UI libraries like MUI or React Bootstrap.
|
||||
|
||||
All contents of this project reside within the GitHub repository. All my blog posts (including this one) are written in Markdown file format since I'm very used to with this. But to write Markdown along with its frontmatter effortlessly, I use [Forestry](https://forestry.io/ "Forestry Official Website") headless CMS. It is a git-based CMS that can serve Markdown and other contents. Because of this, I can write my contents either using Markdown or wysiwyg editor. Besides, writing frontmatters with this is a breeze.
|
||||
|
||||
Images and assets are uploaded and stored in [Cloudinary](https://cloudinary.com/ "Cloudinary Official Website"). I connect Cloudinary via Forestry and manage them directly in the dashboard.
|
||||
|
||||
In conclusion, these are the tech stack I've used for this project.
|
||||
|
||||
- Front-end: NextJS (TypeScript)
|
||||
- Styling: TailwindCSS
|
||||
- Animations: GSAP
|
||||
- CMS: Forestry Headless CMS
|
||||
- Deployment: Vercel
|
||||
|
||||
## Features
|
||||
|
||||
The following are certain features of my portfolio and blog
|
||||
|
||||
### SEO Friendly
|
||||
|
||||
The entire project is developed with SEO focus in mind. I've used proper meta tags, descriptions and heading alignments. This website is now indexed by Google.
|
||||
|
||||
> You can search this website on google by using keywords like 'sat naing dev'
|
||||
|
||||

|
||||
|
||||
Moreover, this website will be displayed well when shared to social media due to properly used meta tags.
|
||||
|
||||

|
||||
|
||||
### Dynamic Sitemap
|
||||
|
||||
Sitemap plays an important part in SEO. Because of this, every single page of this site should be included in sitemap.xml. I made an auto generated sitemap in my website whenever I create a new content or tags or categories.
|
||||
|
||||
### Light & Dark Themes
|
||||
|
||||
Due to dark theme trend in recent years, many websites include dark theme out of the box nowadays. Certainly, my website also supports light & dark themes.
|
||||
|
||||
### Fully Accessible
|
||||
|
||||
This website is fully accessible. You can navigate around by only using keyboard. I put all a11y enhancement best practices like including alt text in all images, no skipping headings, using semantic HTML tags, using aria-attributes properly.
|
||||
|
||||
### Search box, Categories & Tags
|
||||
|
||||
All blog contents can be searched by search box. Moreover, contents can be filtered by categories and tags. In this way, blog readers can search and read what they really want.
|
||||
|
||||
### Performance and Lighthouse Score
|
||||
|
||||
This website got very good performance and lighthouse score thanks to proper development and best practices. Here's the lighthouse score for this website.
|
||||
|
||||

|
||||
|
||||
### Animations
|
||||
|
||||
Initially I used [Framer Motion](https://www.framer.com/motion/ "Framer Motion") to add animations and micro interactions for this website. However, when I tried to use some complex animations and parallax effects, I found it inconvenient to integrate with Framer Motion (Maybe I'm not very good at and used to working with it). Hence, I decided to use [GSAP](https://greensock.com/ "GSAP Animation Library") for all of my animations. It is one of the most popular animation library and it is capable of doing complex and advanced animations. You can see animations and micro interactions on pretty much every page of this website.
|
||||
|
||||

|
||||
|
||||
## Outro
|
||||
|
||||
In conclusion, this project gives me a lot of experience and confidence about developing blog site (SSG). Now, I have gained knowledge of git-based CMS and how it interacts with NextJS. I've also learned about SEO, dynamic sitemap generation and indexing Google procedures. I will make better projects in the future. So, stay tuned! ✌🏻
|
||||
|
||||
And... last but not least, I would like to say 'thanks' to my friend [Swann Fevian Kyaw](https://www.facebook.com/bon.zai.3910 "Swann Fevian Kyaw's Facebook Account") (@[ToonHa](https://www.facebook.com/ToonHa-102639465752883 "ToonHa Facebook Page")) who has drawn a beautiful illustration for my hero section of the website.
|
||||
|
||||
## Project Links
|
||||
|
||||
- Website: [https://satnaing.dev/](https://satnaing.dev/ "https://satnaing.dev/")
|
||||
- Blog: [https://satnaing.dev/blog](https://satnaing.dev/blog "https://satnaing.dev/blog")
|
||||
- Repo: [https://github.com/satnaing/my-portfolio](https://github.com/satnaing/my-portfolio "https://github.com/satnaing/my-portfolio")
|
||||
@@ -0,0 +1,208 @@
|
||||
---
|
||||
title: Tailwind Typography Plugin
|
||||
author: Sat Naing
|
||||
pubDatetime: 2022-07-05T02:05:51Z
|
||||
featured: false
|
||||
draft: false
|
||||
tags:
|
||||
- TypeScript
|
||||
- Astro
|
||||
description: "EXAMPLE POST: About Tailwind Typography Plugin and how you can use it effectively."
|
||||
---
|
||||
|
||||
> This article is from [TailwindLabs](https://tailwindcss-typography.vercel.app/). I put this article to demonstrate how you can write blog posts/articles using AstroPaper theme.
|
||||
|
||||
By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
|
||||
|
||||
We get lots of complaints about it actually, with people regularly asking us things like:
|
||||
|
||||
> Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
|
||||
> We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
|
||||
|
||||
The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
|
||||
|
||||
It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
|
||||
|
||||
```html
|
||||
<article class="prose">
|
||||
<h1>Garlic bread with cheese: What the science tells us</h1>
|
||||
<p>
|
||||
For years parents have espoused the health benefits of eating garlic bread
|
||||
with cheese to their children, with the food earning such an iconic status
|
||||
in our culture that kids will often dress up as warm, cheesy loaf for
|
||||
Halloween.
|
||||
</p>
|
||||
<p>
|
||||
But a recent study shows that the celebrated appetizer may be linked to a
|
||||
series of rabies cases springing up around the country.
|
||||
</p>
|
||||
<!-- ... -->
|
||||
</article>
|
||||
```
|
||||
|
||||
For more information about how to use the plugin and the features it includes, [read the documentation](https://github.com/tailwindcss/typography/blob/master/README.md).
|
||||
|
||||
---
|
||||
|
||||
## What to expect from here on out
|
||||
|
||||
What follows from here is just a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of, like **bold text**, unordered lists, ordered lists, code blocks, block quotes, _and even italics_.
|
||||
|
||||
It's important to cover all of these use cases for a few reasons:
|
||||
|
||||
1. We want everything to look good out of the box.
|
||||
2. Really just the first reason, that's the whole point of the plugin.
|
||||
3. Here's a third pretend reason though a list with three items looks more realistic than a list with two items.
|
||||
|
||||
Now we're going to try out another header style.
|
||||
|
||||
### Typography should be easy
|
||||
|
||||
So that's a header for you — with any luck if we've done our job correctly that will look pretty reasonable.
|
||||
|
||||
Something a wise person once told me about typography is:
|
||||
|
||||
> Typography is pretty important if you don't want your stuff to look like trash. Make it good then it won't be bad.
|
||||
> It's probably important that images look okay here by default as well:
|
||||
|
||||
<figure>
|
||||
<img
|
||||
src="https://images.unsplash.com/photo-1556740758-90de374c12ad?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80"
|
||||
alt=""
|
||||
/>
|
||||
<figcaption>
|
||||
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of
|
||||
classical Latin literature from 45 BC, making it over 2000 years old.
|
||||
</figcaption>
|
||||
</figure>
|
||||
|
||||
Now I'm going to show you an example of an unordered list to make sure that looks good, too:
|
||||
|
||||
- So here is the first item in this list.
|
||||
- In this example we're keeping the items short.
|
||||
- Later, we'll use longer, more complex list items.
|
||||
|
||||
And that's the end of this section.
|
||||
|
||||
## What if we stack headings?
|
||||
|
||||
### We should make sure that looks good, too.
|
||||
|
||||
Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.
|
||||
|
||||
### When a heading comes after a paragraph …
|
||||
|
||||
When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let's see what a more complex list would look like.
|
||||
|
||||
- **I often do this thing where list items have headings.**
|
||||
|
||||
For some reason I think this looks cool which is unfortunate because it's pretty annoying to get the styles right.
|
||||
|
||||
I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn't write this way.
|
||||
|
||||
- **Since this is a list, I need at least two items.**
|
||||
|
||||
I explained what I'm doing already in the previous list item, but a list wouldn't be a list if it only had one item, and we really want this to look realistic. That's why I've added this second list item so I actually have something to look at when writing the styles.
|
||||
|
||||
- **It's not a bad idea to add a third item either.**
|
||||
|
||||
I think it probably would've been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it.
|
||||
|
||||
After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.
|
||||
|
||||
## Code should look okay by default.
|
||||
|
||||
I think most people are going to use [highlight.js](https://highlightjs.org/) or [Prism](https://prismjs.com/) or something if they want to style their code blocks but it wouldn't hurt to make them look _okay_ out of the box, even with no syntax highlighting.
|
||||
|
||||
Here's what a default `tailwind.config.js` file looks like at the time of writing:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
purge: [],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
variants: {},
|
||||
plugins: [],
|
||||
};
|
||||
```
|
||||
|
||||
Hopefully that looks good enough to you.
|
||||
|
||||
### What about nested lists?
|
||||
|
||||
Nested lists basically always look bad which is why editors like Medium don't even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.
|
||||
|
||||
1. **Nested lists are rarely a good idea.**
|
||||
- You might feel like you are being really "organized" or something but you are just creating a gross shape on the screen that is hard to read.
|
||||
- Nested navigation in UIs is a bad idea too, keep things as flat as possible.
|
||||
- Nesting tons of folders in your source code is also not helpful.
|
||||
2. **Since we need to have more items, here's another one.**
|
||||
- I'm not sure if we'll bother styling more than two levels deep.
|
||||
- Two is already too much, three is guaranteed to be a bad idea.
|
||||
- If you nest four levels deep you belong in prison.
|
||||
3. **Two items isn't really a list, three is good though.**
|
||||
- Again please don't nest lists if you want people to actually read your content.
|
||||
- Nobody wants to look at this.
|
||||
- I'm upset that we even have to bother styling this.
|
||||
|
||||
The most annoying thing about lists in Markdown is that `<li>` elements aren't given a child `<p>` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
|
||||
|
||||
- **For example, here's another nested list.**
|
||||
|
||||
But this time with a second paragraph.
|
||||
|
||||
- These list items won't have `<p>` tags
|
||||
- Because they are only one line each
|
||||
|
||||
- **But in this second top-level list item, they will.**
|
||||
|
||||
This is especially annoying because of the spacing on this paragraph.
|
||||
|
||||
- As you can see here, because I've added a second line, this list item now has a `<p>` tag.
|
||||
|
||||
This is the second line I'm talking about by the way.
|
||||
|
||||
- Finally here's another list item so it's more like a list.
|
||||
|
||||
- A closing list item, but with no nested list, because why not?
|
||||
|
||||
And finally a sentence to close off this section.
|
||||
|
||||
## There are other elements we need to style
|
||||
|
||||
I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
|
||||
|
||||
We even included table styles, check it out:
|
||||
|
||||
| Wrestler | Origin | Finisher |
|
||||
| ----------------------- | ------------ | ------------------ |
|
||||
| Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
|
||||
| Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
|
||||
| Randy Savage | Sarasota, FL | Elbow Drop |
|
||||
| Vader | Boulder, CO | Vader Bomb |
|
||||
| Razor Ramon | Chuluota, FL | Razor's Edge |
|
||||
|
||||
We also need to make sure inline code looks good, like if I wanted to talk about `<span>` elements or tell you the good news about `@tailwindcss/typography`.
|
||||
|
||||
### Sometimes I even use `code` in headings
|
||||
|
||||
Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
|
||||
|
||||
Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
|
||||
|
||||
#### We haven't used an `h4` yet
|
||||
|
||||
But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
|
||||
|
||||
We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
|
||||
|
||||
### We still need to think about stacked headings though.
|
||||
|
||||
#### Let's make sure we don't screw that up with `h4` elements, either.
|
||||
|
||||
Phew, with any luck we have styled the headings above this text and they look pretty good.
|
||||
|
||||
Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
|
||||
|
||||
What I've written here is probably long enough, but adding this final sentence can't hurt.
|
||||
@@ -0,0 +1,88 @@
|
||||
---
|
||||
title: How Do I Develop My Terminal Portfolio Website with React
|
||||
author: Sat Naing
|
||||
pubDatetime: 2022-06-09T03:42:51Z
|
||||
slug: how-do-i-develop-my-terminal-portfolio-website-with-react
|
||||
featured: false
|
||||
draft: false
|
||||
tags:
|
||||
- JavaScript
|
||||
- ReactJS
|
||||
- ContextAPI
|
||||
- Styled-Components
|
||||
- TypeScript
|
||||
description:
|
||||
"EXAMPLE POST: Developing a terminal-like website using ReactJS, TypeScript and Styled-Components.
|
||||
Includes features like autocomplete, multiple themes, command hints etc."
|
||||
---
|
||||
|
||||
> This article is originally from my [blog post](https://satnaing.dev/blog/posts/how-do-i-develop-my-terminal-portfolio-website-with-react). I put this article to demonstrate how you can write blog posts/articles using AstroPaper theme.
|
||||
|
||||
Developing a terminal-like website using ReactJS, TypeScript and Styled-Components. Includes features like autocomplete, multiple themes, command hints etc.
|
||||
|
||||

|
||||
|
||||
## Table of contents
|
||||
|
||||
## Intro
|
||||
|
||||
Recently, I've developed and published my portfolio + a blog. I’m glad I got some good feedback for it. Today, I want to introduce my new terminal-like portfolio website. It is developed using ReactJS, TypeScript. I got this idea from CodePen and YouTube.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
This project is a frontend project without any backend codes. The UI/UX part is designed in Figma. For the frontend user-interface, I chose React over pain JavaScript and NextJS. Why?
|
||||
|
||||
- Firstly, I want to write declarative code. Managing HTML DOM using JavaScript imperatively is really tedious.
|
||||
- Secondly, because it is React!!! It is fast, and reliable.
|
||||
- Lastly, I don’t need much of the SEO features, routing and image optimization provided by NextJS.
|
||||
|
||||
And of course there's TypeScript for type checking.
|
||||
|
||||
For styling, I took a different approach than what I usually do. Instead of choosing Pure CSS, Sass, or Utility CSS Framework like TailwindCSS, I chose the CSS-in-JS way (Styled-Components). Although I’ve known about Styled-Components for some time, I’ve never tried it out. So, the writing style and structures of Styled-Components in this project may not be very organized or very good.
|
||||
|
||||
This project doesn’t need very complex state management. I just use ContextAPI in this project for multiple theming and to avoid prop drilling.
|
||||
|
||||
Here’s a quick recap for the tech stack.
|
||||
|
||||
- Frontend: [ReactJS](https://reactjs.org/ "React Website"), [TypeScript](https://www.typescriptlang.org/ "TypeScript Website")
|
||||
- Styling: [Styled-Components](https://styled-components.com/ "Styled-Components Website")
|
||||
- UI/UX: [Figma](https://figma.com/ "Figma Website")
|
||||
- State Management: [ContextAPI](https://reactjs.org/docs/context.html "React ContextAPI")
|
||||
- Deployment: [Netlify](https://www.netlify.com/ "Netlify Website")
|
||||
|
||||
## Features
|
||||
|
||||
Here are some features of the project.
|
||||
|
||||
### Multiple Themes
|
||||
|
||||
Users can change multiple themes. At the time of writing this post, there are 5 themes; and more themes will probably be added in the future. The selected theme is saved in local storage so that the theme won’t change on page refresh.
|
||||
|
||||

|
||||
|
||||
### Command-line Completion
|
||||
|
||||
To look and feel as close to the actual terminal as possible, I put a command-line completion feature which auto fills in partially typed commands by simply pressing ‘Tab’ or ‘Ctrl + i’.
|
||||
|
||||

|
||||
|
||||
### Previous Commands
|
||||
|
||||
Users can go back to the previous commands or navigate the previously typed commands by pressing Up & Down Arrows.
|
||||
|
||||

|
||||
|
||||
### View/Clear Command History
|
||||
|
||||
previously typed commands can be viewed by typing ‘history’ in the command line. All the command history and terminal screen can be wiped out by typing ‘clear’ or pressing ‘Ctrl + l’.
|
||||
|
||||

|
||||
|
||||
## Outro
|
||||
|
||||
This is a really fun project, and one special part of this project is I had to focus on logic rather than user-interface (even though this is kind of a frontend project).
|
||||
|
||||
## Project Links
|
||||
|
||||
- Website: [https://terminal.satnaing.dev/](https://terminal.satnaing.dev/ "https://terminal.satnaing.dev/")
|
||||
- Repo: [https://github.com/satnaing/terminal-portfolio](https://github.com/satnaing/terminal-portfolio "https://github.com/satnaing/terminal-portfolio")
|
||||
Reference in New Issue
Block a user