<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Santosh Bhandari — Blog</title>
    <link>https://www.santoshb.com.np/feed.xml</link>
    <description>RSS feed for my blog articles!</description>
    <item>
      <title>Proper API Response structure {}</title>
      <guid isPermaLink="false">importance-of-proper-api-response</guid>
      <link>https://www.santoshb.com.np/blog/importance-of-proper-api-response/</link>
      <description>API are core part of every dynamic website. Without proper communication everything can be mess. So here are my thoughts on having an proper API response structure.</description>
      <content:encoded><![CDATA[ℹ️ **_Before starting to write anything I would like to mention that all this is my personal thoughts based on my knowledge, experiences and issues I have faced in the past._** ℹ️

It is the modern age of Internet, and there are thousands if not millions of website we have stumbled upon. Hundreds of which may be dynamic (i.e. fetch data whenever we request from some data source.)

The whole process of data fetching **in most of the cases** is done through API (SOAP, REST or GraphQL).
Thus you can consider an API as the translator between two people who talk two different language. Just imagine what would happen if the translator translates it wrong.

## Things to Consider

**Communication is key!**

<br />
Thus, there are lots of things which I think we should consider when setting up
API response.

### Do not use top level data Objects or Arrays

I used to think it's easy to just send the data after fetching it directly from the Database.

<br />
For e.g. sending this response for API call `https://api.xyz.com/users/1`

```json
{
  "fullName": "Full Name",
  "dateOfBirth": "2000-01-01"
}
```

Or the e.g. below for API call `https://api.xyz.com/users`

```json
[
  {
    "fullName": "First User",
    "dateOfBirth": "2000-01-01"
  },
  {
    "fullName": "Second User",
    "dateOfBirth": "1990-04-04"
  }
]
```

While it will be easy to return the data like this, it will cause a huge problem sooner or later.

<br />
The major problem being **We can't add extra information in the first response
object, and it's not even possible in the second response array.**

### Use consistent variable name casing

There are variable ways to name a variable:

- **camelCase** being the popular one around JavaScript developers.
- **snake_case** being the popular one around Python developers (_snake_case for Python developers... what a coincidence..._).
- PascalCase
- kebab-case

I think it was not really necessary to mention about it, because developers using a specific language already have their own preference over variable name casing.

_Just a note from my side; using multiple name casing in a single project is a big **NO**!_

<br />
If possible, I would even suggest everyone to grab a name casing technique and
follow it throughout the entire journey of programming in life.

### Use proper variable names

This is not just for the API response object, but also the codes itself and Database entity itself as well.

I am pretty sure there are thousands of articles/notes motioning about how variable names should be written so I am not gonna go in depth, but I would like to attach a simple yet important note about this topic:

<br />
Variables name should be "**As short as possible, as long as required**"!

## Solution

The simple yet powerful solution to API response structure is to simply have the data structure as follow:

For e.g. sending this response for API call `https://api.xyz.com/users/1`

```json
{
  "message": "Successfully fetched User data",
  "data": {
    "fullName": "Full Name",
    "dateOfBirth": "2000-01-01"
  }
}
```

Or the e.g. below for API call `https://api.xyz.com/users`

```json
{
  "message": "Successfully fetch Users data",
  "pagination": {
    "page": 1,
    "count": 2,
    "perPage": 10
  },
  "data": [
    {
      "fullName": "First User",
      "dateOfBirth": "2000-01-01"
    },
    {
      "fullName": "Second User",
      "dateOfBirth": "1990-04-04"
    }
  ]
}
```

You might have already noticed that I am able to send message in the API response. And also in the second API usage example, I am even able to send pagination details.

<br />
There will be thousands of data processing happening, so pagination is obviously
to be done sooner or later. However in the previous approach we could not
properly mention about the pagination details. Which we have overcome.

You might now be wondering, **Isn't it painful to access the data going one more level deep in the object?** i.e. `response.data` instead of `response`.

<br />
The answer is Yes, but apart from that downside, it's only good point I can
think up of.

For e.g. lets say we have to respond with error message if the API request is invalid. Following this approach, we can simply send the response like:

```json
{
  "message": "Invalid email address" // or any other error message
}
```

And now in the frontend/mobile app, we can always refer to `response.message` to get the information about the API usage. And to understand if the API call was a success or failure, we can use HTTP status code of the API call.

### The main point

The major point of all this discussion is that the APi response should never be a top level data object itself.

Instead use an object which contains all the information you want ot share from server to frontend (not related to API).

<br />
And within the top level object, include the data related to the API call inside
a `result` or `data` key.

This will result in **clean** and **consistent** API response across every API endpoint. And also you will be able to share extra information which is not related to the specific API call.

## Conclusion

I have done this mistake in the past and learnt a hard way from it. That doesn't mean you have to make this mistake yourself to learn.

<br />
You can try implementing this approach I have mentioned in your next project (or
even your current project if possible without major breaking changes).

_If you are someone developing API, I would love to hear your thoughts about this approach and if you would like to switch to this approach (if not already using)._

<br />
_If you are someone who consumes API, I would love to hear your thoughts about
how this change (if it is not what your current API provides) would affect you._

**If you are already using this approach, then cheers, you are making life of yourself and the frontend developer easy 😉**]]></content:encoded>
      <pubDate>Mon, 23 May 2022 00:00:00 GMT</pubDate>
    </item>
    <item>
      <title>Brief Introduction to Hacktoberfest 2021</title>
      <guid isPermaLink="false">introduction-to-hacktoberfest</guid>
      <link>https://www.santoshb.com.np/blog/introduction-to-hacktoberfest/</link>
      <description>Hacktoberfest is an annually happening event for the whole month of October. If you know use github/gitlab and love open source projects then you should read this article. You will be able to get Free rewards!</description>
      <content:encoded><![CDATA[Hacktoberfest is an festive for open-source programmers and developers organized by DigitalOcean. Even since I got to know about it I have been participating in this awesome event. **You should too..** I tried gathering some basic and useful information required to learn about this awesome event. There is lot more to learn about this event, but I hope this will provide you some basic knowledge about the event.

## **Discord server**

Before starting with anything else, you can join thousands of other developers on the official hacktoberfest discord server to engage more and learn alongside others.
[Click here to join the official Hacktoberfest discord server](https://discord.gg/hacktoberfest)

## **What is Hacktoberfest?**

Hacktoberfest is a month-long celebration of open source software run by DigitalOcean with various other partners.

## **Who can participate?**

Hacktoberfest is open to everyone! **YOU ARE IN !!**

## **How can I participate?**

All you need to participate is will to contribute to open source and a github account. You simply register [here](https://hacktoberfest.digitalocean.com) using your github account. For participating in the challenge you will have to submit Pull Requests(PR) in any _public_ Github/Gitlab hosted repository.

## **When can I participate?**

You can participate by signing up anytime between October 1 and October 31. All of yours contributions within this time period will be counted even if those were before you sign up for the event.

## **Can I organize an event?**

You surely can as it is a great way to support the open source community.

Explore [Details about organizing events](https://hacktoberfest.digitalocean.com/resources/event-organizers) and [maintainer's information](https://hacktoberfest.digitalocean.com/resources/maintainers) to learn how to successfully organize a Hacktoberfest gathering around you.

## **Can I join an event?**

You surely can if there is one happening around you.
To lookup for events happening around you can [visit here!](https://hacktoberfest.digitalocean.com/events)

## **What do I get for participating?**

There are lots of things you will get for participating:

- Gain more knowledge about open source and open source contributions
- Gain more knowledge about github and community based contributions
- Thanks for the project you contributed to
- **Free Swag Reward from the hacktoberfest team** (_Terms apply_)

## **How do I get the T-shirt?**

To obtain the T-shirt you will have to complete specific amount of contributions on Github.
_Stickers are included with the T-shirt as well_

The amount of PRs to be completed are:

- Hacktoberfest No.7 (2021): **4**
- Hacktoberfest No.6 (2020): **4**
- Hacktoberfest No.5 (2019): **5**
- Hacktoberfest No.4 (2018): **4**

## **When will I receive the T-shirt?**

T-shirts are awarded on a first-come, first-serve basis to the first 55,000 participants who successfully completed the Hacktoberfest challenge. You will be receiving mail when you have completed the challenge. Further details will be provided with the mail.

## **I am new to Open source, how should I start?**

Believe me, everyone once was! You just need to get started with proper resources and guides. Here are some good resources for you:

- [Introduction to Open Source series](https://www.digitalocean.com/community/tutorial_series/an-introduction-to-open-source)
- [How To Create a Pull Request](https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github)
- [Up For Grabs](https://up-for-grabs.net/#/)
- [Issuehub.io](http://issuehub.io/)
- [First Timers Only](https://www.firsttimersonly.com/)
- [Your First PR](http://yourfirstpr.github.io/)
- [Awesome for Beginners](https://github.com/mungell/awesome-for-beginners)

You can also check the official information for beginners [available here](https://hacktoberfest.digitalocean.com/resources/beginners).

## **I completed X-number of PR, but tracking page shows I am not done?**

Make sure your PRs are not among these:

- PRs that are automated (e.g. scripted opening PRs to remove whitespace/optimize images)
- PRs that are disruptive (e.g. taking someone else's branch/commits and making a PR)
- PRs that are regarded by a project maintainer as a hindrance vs. helping
- Something that's clearly an attempt to simply +1 your PR count for October
- Last but not least, one PR to fix a typo is fine. 5 PRs to remove a stray whitespace... not

## **Anything else I need to know?**

These are just the basics you should be knowing about Hacktoberfest. But surely there are lot more things which is better if known. You can learn more about the Hacktoberfest event [through the official resources here](https://hacktoberfest.digitalocean.com/resources)!

## **Hacktoberfest 2021**

Hacktoberfest 2021 is back with a lot more of excitement and fun.

Most of the rules and other information as just as same as the last hacktoberfest. You can refer to the list below for more information about it. But the most amazing thing this year is that **Hacktoberfest is coming to GITLAB as well.** Isn't this exciting?

First 55,000 participants are can earn a T-shirt. But just like 2020, I believe there will be option to choose between tee and tree.

## **Hacktoberfest 2020**

Hacktoberfest 2020 is almost on the way as this article is being updated for the event happening soon. There are few things to be noted for this year's hacktoberfest event. Most of those are already same as the previous years but still knowing them all is always good idea.

- Once you are done with 4 pull requests, your PR will have to go through 2 weeks (14 days) of review window. If maintainers report it as spam you will have to again make the count to 4 and wait for another 2 weeks of review window.
- Any sort of spam PR or attempt to +1 your count will be removed i.e. marked as ineligible for completion. **Quality over quantity**
- Initially all the repositories are ineligible for the hacktoberfest event itself. Which means maintainers have to opt-in their repository this time by adding the **hacktoberfest** label to their repository keywords.
- You can report an ineligible repository by going to this link [here](https://hacktoberfest.digitalocean.com/report)
- According to the hacktoberfest website your PR will have to be accepted by maintainer by merging it, adding the "hacktoberfest-accepted" label to it, or approving it.

There is more to the event itself and the team has really worked to reduce the spam pull requests. So make sure to go through the hacktoberfest website itself to learn more.]]></content:encoded>
      <pubDate>Thu, 09 Sep 2021 00:00:00 GMT</pubDate>
    </item>
    <item>
      <title>Supercell Creator code program</title>
      <guid isPermaLink="false">supercell-content-creation-and-creator-code</guid>
      <link>https://www.santoshb.com.np/blog/supercell-content-creation-and-creator-code/</link>
      <description>Creator codes are part of the special program being run by Supercell. You should start supporting your favourite supercell content creator right away! Also you can join the program yourself! Something interesting is on the bottom as well!</description>
      <content:encoded><![CDATA[import { CreatorCodeTable } from '#/features/blog/components/CreatorCodeTable'
import { creatorCodes } from './data/creator-codes'

**Supercell Creators** is a program by supercell to support all the content creators realted to the supercell games. Supercell introduced this program with the main concern to help out all the content creators who are using all the time and knowledge to help other users(players) with various stuffs. It reall is an amazing program by supercell, so let's dive into all the questions/answers that you might already be thinking of!

## What is it?

If I simply say what is stated in the official website, it's simply **"A place to help you do what you do best"**! And that is absolutely true. Lots of people(creators) have been making content around supercell games for long. In the early phases they were investing all their time and knowledge with nothing to be gained. But Ever since this program launched, creators are being appreciated by the supercell team.

## How it works?

Every creator _approved_ for the supercell creator program get their own unique code, referred to as **creator code**. You can even call them as clash of clans creator code, clash royale creator code, brawl stars creator code, boom beach creator code or simply supercell creator code, it's all upto you. This code acts as a referral code i.e. whenever you do in-app purchases in the supercell games, your favourite creator gets a certain amount of share of the purchase you just made. Also the creator code is usable across all the games that support creator program; Clash of Clans, Clash Royale, Boom Beach and Brawl Stars!

**NOTE:** Creator gets the share when you make in-app purchases for Clash of Clans and Clash Royale. But for Brawl Stars they get the share when you spend the gems. _I am not sure how they work for Boom Beach though!_

## What will it cost?

**Completely nothing**! You will neither be charged anything when you make purchase nor you will be charged anything in-game. You can support your favourite content creator without having to pay anything at all.

## What will I get?

**Lots of love from the creator** if that counts! There is no direct reward for supporting content creators but there are lots of indirect reward for sure.

- Creators give back stuffs to their community in various forms like merchs, gift cards, special role/authority in their community, shoutout in their content and lots more!
- Supercell organizes various events which you can participate only through content creators; Brawl merch giveaways, Brawl skins giveaway, Royale emotes giveaway and more!

Also it's not all about getting rewards! Your support for your favourite content creator will inspire and motivate them to make more of those awesome contents. Which eventually benefits us all right? So keep entering the code everytime it expires. But if you haven't supported any creator yet, think of it again and start supporting your favourite content creator right away!

## How to use the code?

Using the code is really simple as well. You will just have to enter the code in the right location in the game. They do vary from game to game, so lets have a look at them all.

Also there is a list of all the valid creator codes available [here](#available-codes)!

### Clash of clans

- Tap `Settings` button on the bottom left of your game screen
- Press `Show` under More Settings heading
- Scroll all the way to the bottom and click `Enter code` button in the Creator Boost section
- Enter your creator's code and show some love to them

### Clash Royale

- Switch to `Shop` tab from the bottom left of your game screen
- Scroll all the way to the bottom and click `Enter code` button in the Creator Boost section
- Enter your creator's code and show some love to them

### Brawl Stars

- Open the `Shop` from your game screen
- Scroll all the way to the right and click `Enter code` button in the Creator Boost section
- Enter your creator's code and show some love to them

### Keep a note

- Creator code expires after 7 days you used them. So make sure to enter it after every 7 days (or when you make purchase) to keep supporting your favourite content creator
- Creator codes are case insensitive. So you can enter it like `code` or `CODE` or even show your case creativity! _Though space makes difference!_
- You can stop supporting a creator by pressing the `stop` button if you are currently supporting someone. _But make sure you always support someone!_
- You can only support a single creator at a time. So if you want to support multiple creators you will have to stop supporting one and start supporting another creator!

## How do I get my own CODE?

Supercell Creator program is open for all. Which means you can simply apply for it. But there are few requirements so it won't be an easy task. Still all the information about that can be found in the [offical creators website](https://creators.supercell.com)!

## Available codes

This is an attempt to list all the creator codes available. If you find any code missing then you can simply mention that in the comments below. I will add them all to this list. Heads up though there are over 100 creator codes listed!

<CreatorCodeTable codes={creatorCodes} />

**NOTE**: It took me really long to find all these codes and there are still many missing (_I am sure about that_), but it will take only about a minute to support your favourite content creator. So do support your favourite content creator!

**NOTE2**: I have attempted to test all of the codes but if any are found to be wrong please inform me!

## Supercell MAKE

Although this article is all about supercell creators, but I though Supercell Make deserves a mention as well. It is another of the supercell program that tries to involve it's users (_that's us_). They run various campaigns over there so that users can make various skins for brawl stars and the selected ones win amazing prize money! So if you are good at making 3D characters then you definitely need to head to the supercell make platform. Start making some amazing skins and get your hands on that prize money. All the best to you!

Here is the link to the [Official website](https://make.supercell.com/)!]]></content:encoded>
      <pubDate>Fri, 12 Jun 2020 00:00:00 GMT</pubDate>
    </item>
    <item>
      <title>Adding commenting system to website</title>
      <guid isPermaLink="false">adding-user-engagement-with-comments-to-websites</guid>
      <link>https://www.santoshb.com.np/blog/adding-user-engagement-with-comments-to-websites/</link>
      <description>Engage the users in your community or website by providing awesome commenting system and more features. Choose any from this awesome list and start engaging your community with ease.</description>
      <content:encoded><![CDATA[A community or website can operate better if users can engage more over it. If your website already doesn't have the commenting system then you are missing a lot from your users. Users prefer to be over the website where one can engage actively i.e. discuss, comments, react to the articles/content etc. Don't you prefer the same way?

If you also prefer having users on your website engaged then you have made a wise decision being here. Today I am going to talk about the user engagements in any website in general.

## Introduction

Users, including me, would love to have any sort of engagement method when visiting a website. I prefer to talk actively with other users and discussion about various topics. If I find website which doesn't allow me to comment for any article published there, then most likely I won't visit the website again. Talking from the perspective of website developer it is a huge loss. So better not delay a moment to implement the commenting system in your website/blog if you know how to do it. But if you are not aware where and how to start then proceed through the article till the end. After that you will be able to implement comments in your website with no problem at all!

## Implementation

If you are a big company or a big project with dedicated resources and members then implementing comments in your website won't be hard at all. **But what if you are a solo developer or a small team with limited resources?** Things can be really tough right? Yeah it can be, but do not fear. _I have you covered this time!_

I took a day out of my life and invested it all to help everyone out there just like me; just like me who wanted to implement comments system in their website but were in a hard spot with no knowledge about where to start. I have made a small list with every necessary details possible so that you won't have to wonder anywhere else to start with adding comments to your site.

These commenting plugins below are what I found by searching around the internet. There may be many more out there, but after knowing about these you won't have to wonder anywhere else. So let have a look at them:

### Disqus

[Disqus](https://disqus.com/) is the most popular commenting system that lots of websites use. Its amazing features and ease of use makes it the most popular choice amazing many users and developers. It comes with really amazing features, so lets have a look at them:

- **FREE**
- Supports devices from desktop to mobile, including Google AMP
- Supports 70 languages and counting
- Real time comments
- Reactions
- Automatically adapts to your site's design and colors or you can set it to your own liking
- Allows users to comment with rich media i.e. picture, gif and videos
- **Complete moderation options**
  - Pre moderation options
  - Banned and trusted lists
  - User reputation
  - Email moderation
  - Temporary user bans
- Automated spam moderation
- Notifications
- Content recirculation
- Subscriptions
- Analytics
- And many more...

Sorry if I went for only listing the features. Because if I had to describe them all then this article would get super long. So I though to keep and short and meaningful.
If you want to have a detailed information about all the feature you can head to the official disqus site and get detailed information about anything you want to know.

Although I would love to mention that disqus is **FREE**. But you do have the options to update to a paid version with addition features on the line. It's completely your choice if you want to upgrade or not. But if you are a solo developer or small team then I would suggest to work with the free version. Because It is REALLY AWESOME even when used as free.

Even [my site](https://www.santoshb.com.np/blog) has various blog articles with disqus comments plugin installed. Which means if you are reading this article on my site then you can let me know in the comments below. If not head over to this article originally posted on my site and let me know _I love when people interact with me!_

<center>
  <img
    src="/img/content/commenting-system/disqus.webp"
    width={856}
    height={754}
    className="w-64 md:w-3/6"
    alt="commenting system disqus"
  />
</center>

### Facebook

[Facebook](https://facebook.com) is a really well known global brand. Even if you don't user it you might have heard about it once in your lifetime. That already explains how famous it is. There are millions of people using facebook and that is one of the reason why facebook launched it's own commenting system.

If your website is focused upon user base from facebook or if your site is related to facebook by any means then you should go for this system. If not I would suggest not to add extra pain in your life. Wonder why? Lets get to the feature and you will know by yourself!

- **FREE**
- Can be used with users registered on facebook only. _That's why not good for site targeting audience outside of facebook!_
- Facebook life feel. _It is exactly as what you would see in the platform itself, so gives the home like feeling to the users!_
- Admin panel for all moderation and related stuffs
- Webhooks
- And many more...

Although facebook itself is really well known global brand, the commenting system provided by it is not good outside the scope of Facebook related stuffs. So better realize and think about it if you are planning to use it on your site already!

### Spot.IM

[Spot.IM](https://www.spot.im/) is a really new thing for me as well. I had never heard about it till date. _**Thanks to you guys I learned something new**_ But after looking at it the only thing I can say is **WOW**. It looks really promising because of all the features it has, but I could not find any details about it's pricing so you guys got some task to do if you plan to use it! Lets dive into it's features:

- Conversations; yeah thats simply commenting system but with really rich detailing though!
- Community spotlight
- Live blogs; to give real time updates to your users for anything critical, important or emergency
- Reactions
- Powerful moderation options with AI integrations
- User profiles and notifications
- Analytics and insight
- And many more...

All these features look really promising for sure. I am already thinking of doing a small project to test it out with amazing people like you. If you are eager just like me or if you already use it then let me know in the comments below.

<center>
  <img
    src="/img/content/commenting-system/spot.webp"
    width={580}
    height={500}
    className="w-64 md:w-3/6"
    alt="commenting system spot.IM"
  />
</center>

### HTML Comment Box

[HTML Comment Box](https://www.htmlcommentbox.com/) is simple yet powerful commenting system. There is nothing much to describe about it because it is just plug-and-play stuff. But if you have a look at the site you will see additional widgets available. Those are really awesome. So make sure to have look at them!

### Viafoura

[Viafoura](https://viafoura.com/) is another of those promising looking commenting system I found while working on this article. Lets dig right into its features:

- Real time conversations _Includes rich features display_
- Live stories for live streams
- Community chat
- Automated moderation
- Moderation possibilities
- Community reviews
- Integrated login
- User personalization
- And many more...

It is yet another of that amazing stuff which I want to try out someday.. Let me know in the comments below if you are impatient just like me to test it out!

<center>
  <img
    src="/img/content/commenting-system/viafoura.webp"
    width={1500}
    height={1500}
    className="w-64 md:w-3/6"
    alt="commenting system viafoura"
  />
</center>

## List goes on

The list goes on to be honest. There are lots and lots of free and paid commenting systems out there. But in the end it is your choice what you want to use! If I have to be honest the only ones I knew about are Disqus and Facebook commenting system. All the rest are the result of my research I did for this article alone. Usually most of the people prefer disqus for the first choice. So did I. But I know everyone is unique so everyone would not go for the same one I did, or others did. So in addition to all the sites listed above I wanted to notify the source that introduced me to these other sites. You can yourself check the ones listed here and more system from the link below:

[g2.com/categories/commenting-systems](https://www.g2.com/categories/commenting-systems)

## Closing notes

It was a really fun time writing article. And I learnt something new today about all the possibilities of commenting system. I did realize that disqus or facebook is not the only stuff that is taking the market. There are really awesome stuffs, _maybe even better than those existing_ that is still unknown to many people just like me.

As I discussed in the entire article **Let me know about all your thoughts and feedbacks** about this article. I will be hearing them all and hopefully you will teach me something new as well.

Until next time, farewell, Stay Safe!]]></content:encoded>
      <pubDate>Thu, 11 Jun 2020 00:00:00 GMT</pubDate>
    </item>
    <item>
      <title>Creating markdown powered blog</title>
      <guid isPermaLink="false">creating-markdown-powered-blog-with-ease</guid>
      <link>https://www.santoshb.com.np/blog/creating-markdown-powered-blog-with-ease/</link>
      <description>How to create a blog with markdown? How to use markdown to create a blog? If those are the question you have then with the awesome tools like Nuxt.js, nuxt-content and the awesome Jamstack concept the task gets easy like never before!</description>
      <content:encoded><![CDATA[You are reading this then that means you too are interested in creating a blog or alike website, Right ?? I too was very interested for the first time when I tried such stuff and even today when I make similar stuff I get hyped. Technically there are various methods of doing this. But of the most impressive and famous way is **Jamstack** and the entire article is based upon it.

## About Jamstack

So if you are already wondering what is jamstack and why jamstack, then you should head over to the [jamstack website](https://jamstack.org/) to know more about it. Because if I started talking about it, the article can get really long 😜. Although the below listed are very basic ones but here are some awesome feature you should know:

- No need of server to host website
- Higher security
- Cheaper

With that being said, JAMstack makes things only better!

## Prerequisites

To get started with building your own blog we need to install few things. _You need to have **Node.js** installed on your machine!_

### Nuxt

It is the most essential stuff today. It is really easy if you know vue. Also it provides way more than just generating static sites. This is just one of its awesome features. With it you can try so many awesome things and it even makes so many complex stuffs really really easy. It also has an active community and really helpful developers and core team members. To know more about it you can have a look at the [official website](https://nuxtjs.org/)!

### Nuxt content

Nuxt content is an official module by the nuxt team which aims to provide ease to use features while working with _markdown_, _JSON_, _YAML_ and \_CSV files. Although it is a pretty much module by the nuxt team, it already contains really amazing feature which makes our task easier. Also the dev team is working to add new features to the module. So you should keep track of the module to learn about the new amazing features that the module will be getting. More information about it can be found [here](https://content.nuxtjs.org/)!

Thats basically what we will need to start developing the blog. So lets dive deep into building the blog!

## Development

There are few phases of developing the blog. I will try to explain them with minimum words but with maximum meaning. I hope it helps you!

### Writing a blog article

With the `@nuxt/content` module activated you can start with ease to write blog articles. ALl you should be doing is create a **content** directory in the root of your project directory and create files inside it. Generally you can place your article files directly inside the content directory. But if you plan to host files other than blog articles with the content module, I would suggest to create your articles inside `/content/blog` or any subdirectory of your choice. **I strongly recommend to place the markdown articles into a subdirectory. You will understand the reason while reading through this article!**

```md[/content/blog/article.md]
---
title: article1
---

## About this article
You can write any markdown content here and it can be easily displayed later!
```

As you see in the example above I have added YAML front matter block. All the items added will be injected into the article object and you will be able to see them when you fetch the article object. This can be really helpful if you want to add some properties to the article. You can even set the title, date, author details or anything else in the markdown file and later fetch, use them as you like.

All of your general content goes below the front matter block. You can do everything that you can do with a markdown file. On top of that you can even use html and vue components in the markdown file and with the magic of the module, it will be rendered properly. Which means you can customize your content in the markdown file completely! Also the content module provides syntax highlighting using [PrismJS](https://prismjs.com/). So you can even demonstrate codeblock examples!

There is a lot more to writing content though. You can definitely check it out [here](https://content.nuxtjs.org/writing/)!

### Fetching the blog article

Writing alone is not enough right? You would want to fetch the articles and display them. So why not look into fetching the articles next.

Fetching the contents is really really easy. The content module globally injects a **$content** instance, so you can access it anywhere within the project; either `this.$content` or `context.$content` based upon where you use it. That is really easy, isn't it?

Based upon the usage, I can think up of two specific ways you would want to fetch the content. We will look into both the usage methods below.

- Fetching all the articles to list them out
- Fetching a specific article to display it's content

The first use case for fetching the articles is to list them out. While fetching the article list you would either want to fetch all the articles or even filter the articles based upon some parameters. Here is how you would do that:

```js
// Fetching all the article list
const articles = await this.$content('blog').fetch()

// Fetching articles with filters
const articles = await this.$content('blog').search('title', 'welcome').fetch()

// Fetching specific article [1]
const article = await this.$content('blog', articleSlug).fetch()

// Fetching specific article [2]
const article = await this.$content('blog').where({ slug: articleSlug }).fetch()
```

- The first method seen in the example above fetches all the articles inside the `/content/blog` directory.
- The second method also fetches all the articles inside the `/content/blog` but returns result matching the search criteria. _Useful when you are implement a search bar!_
- The third method fetches a specific article based upon the second parameter passed to it. **You get an object instead of array when fetching in this method!**
- The last method is just an alternative to the third method. **It returns an array instead of Object, so you might want to treat it as an array!** _Speaking from experience already..._

You might now always want all the properties of the content. For e.g. when listing title only, you can simply get only the title of the articles using the `.only()` method i.e. `.only(['title'])`. You can even limit the number of items in the result using the `.limit(n)` chainable method. Also you can skip number of results using the `.skip()` method.

I personally use the last method to fetch a specific article and I would even suggest you to do so. It is because it will work even if you decide to change the structure of your content directory and more stuffs here and there. _I personally do that a lot!_ But for the earlier method i.e. you will have to know the exact file location otherwise you will not be able to fetch it.

The content module provides way more control over how you fetch the articles. There is just too many possibilities how you can control fetching your content. It is as good as impossible to know about your specific use case. Thus to know how to customize your fetch request you can have a look [here](https://content.nuxtjs.org/fetching/)!

### Displaying the blog article

This has to be the most easiest task throughout this article. The content module provides a **use-and-enjoy** component which we will be simply using to display the content of our blog article.

```html[/article/_slug.vue]
<template>
  <div>
  <nuxt-content :document="article">
  </div>
</template>
```

The above example will simply display the content of the fetched article. How you customize the page is completely upto you yet again. The article passed into the `document` prop is the object that we obtained after fetching specific article after the dynamic slug param. Theoretically that is all you should do to display the content of the article. But you would love to add more details right? You can simply modify the page template to show off your imagination!

Furthermore your page design will not be included into the markdown content. Thus if you want to customize the markdown with custom style you will have to do that like:

```css
/* Making the h2 component have red color. This is just me, you don't have be bad with examples! */
.nuxt-content h2 {
  color: red;
}
```

A live example of the usage can be found [here](https://github.com/nuxt/content/blob/master/docs/pages/_slug.vue#L65-L191)! I too have used the same thing... _No copyright please!_

### Working with dynamic routes

The core concept of this article is working with static generate site. So we will have to specify all the routes (_the article list for us_) while generating the site. This too is really easy with the content module. With that simple addition of the code below to `nuxt.config.js` your site will be ready to handle the dynamic article page.

```js[nuxt.config.js]
export default {
  modules: [
  '@nuxt/content'
  ],
  generate: {
    async routes() {
      const { $content } = require('@nuxt/content');
      const articles = await $content('blog').only(['slug']).fetch();

      // Generating the routes for the unique page of each article...
      return articles.map((article) => `/article/${article.slug}`);
    }
  }
}
```

**NOTE:** From 2.13+, `nuxt export` is said to have a crawler integrate to the core module. Which means the code above will not have to be injected into your config file!

That has to be all with the development of a basic markdown powered blog using `nuxt` and `nuxt-content`. If you did everything right then your blog should be working as well. If not just tell me in the comments below!

Also like any other module, content also provides customization options so that you can customize the behavior as you like. You can check about the customization options [here](https://content.nuxtjs.org/configuration)!

## Bonus

It was a really long article to write and I am pretty sure it was hard to read it all as well. So I thought about sharing some interesting things with you guys. I actually wanted to list out points/stuffs which you might find interesting, and you can even integrate it with the blog you will be making with the awesome `content` module:

- [Netlify](https://www.netlify.com/): Host the blog you created right away!
- [Implement reading time](https://content.nuxtjs.org/advanced#contentfilebeforeinsert): You can implement reading time in your articles. _Details are from the official nuxt-content module!_
- [Sitemap](https://github.com/nuxt-community/sitemap-module): Let the web crawlers know each and every of your content!
- [Blog feeds](https://github.com/nuxt-community/feed-module): Let your community know when articles are out!
- [Nuxt color mode](https://github.com/nuxt-community/color-mode-module/): Which do you prefer, day or night ??
- [Nuxt components](https://github.com/nuxt/components): Get rid of those component imports that occur everywhere. _Comes with core nuxt 2.13+_
- [Disqus](https://disqus.com/): I love user engaged community!
  - [vue-disqus](https://www.npmjs.com/package/vue-disqus) to make things easy.
  - Optionally you can go for facebook comment plugin or other comment plugin provider!
- [**This site**](https://github.com/TheLearneer/santoshb.com.np) is a live example and demo of using this article! _Lots of changes will be made to the site and article itself to show what more you can do with it!_]]></content:encoded>
      <pubDate>Sun, 31 May 2020 00:00:00 GMT</pubDate>
    </item>
    <item>
      <title>How to earn money online</title>
      <guid isPermaLink="false">working-methods-to-make-online-income-with-ease</guid>
      <link>https://www.santoshb.com.np/blog/working-methods-to-make-online-income-with-ease/</link>
      <description>It actually is possible to make income online with bit of effort and dedication. I am personally making some money online doing stuffs I like. So I thought to share this with you. I am pretty sure you will also be able to do so!</description>
      <content:encoded><![CDATA[Having some online income would be awesome right ?? As far as I am aware, it really helps to have some income either to keep your projects running, or improve your hobby or personal projects, or even to fund a large scale project! So today I thought to share with you all some methods to get started with this.

_I would like to mention that I haven't myself used or verified all the methods listed below, but there are thousands of users who have been making good income out of these methods. So you are most likely to get started having income through these methods!_

## **Google AdSense**

Millions of people have been making billions of dollars annually using Google AdSense, so you can already think how popular google AdSense is! Thousands of people are even making their lives with income from Google AdSense. _This is what I personally upto!_

There are two basic and easy ways to get started with Google AdSense. One of them is **Youtube monetization** and **Website ads**. Both of these methods are really easy to get started with and obviously can help you make online income with ease. But to make earning you will obviously need to have a good user base. And on top of that you will need to meed some criteria set by Google AdSense. To get started with Google AdSense, make sure you meet all the [requirement](https://support.google.com/adsense/answer/9724?hl=en) set by them!

**If you are either a youtube making videos and happen to have good user base, or if you are making an website and happen to have good web traffic, then this is the best choice for you to get started with making money online!**

## **Facebook Instant Article**

Facebook being the most popular social platform, I am sure you can already make a guess it is one of the most amazing choices to do some online income! _I know a bunch of mine friends, who have been doing it and happened to have earned online through this method!_

Facebook Instant Article all started when people accessing the internet via phones, tables and other mobile gadgets surpassed people accessing the internet via traditional computer set-ups back in 2015! So Facebook Instant Article focuses on that same thing and targets mobile users. You will need a facebook page with Admin role to start with it. What's interesting is that people can make even up to **$20K** with Facebook Instant Article, And you can do the same as well! To learn more about it, you can check more of the official article which describes all about Facebook Instant Article [**here**](https://instantarticles.fb.com)

**This method is really useful for earning money online if you happen to have a really awesome user base for your facebook page and you got some original content to post on regular basis.**

## **Freelancing**

Freelancing is something you all must have heard if you ever wanted to earn money online. Freelancing is something you do for someone else and take a certain amount of money for doing that specific job. Users doing so are called _Freelancers_. _I never went this way, but this is one of the major choices for sure!_

People tend to prefer this method when they happen to have skill for something and want to work on their free time or even full time. All because this method typically doesn't require you to get 24/7 into something, but instead you can work however and whenever you like (_being bounded by the limits set by the one offering the task_)! Also a matter of fact that you can make your living with this method. _Lots of people are already doing that!_ Once you get into freelancing, it will be really fun to work on with, and on top of that you will make lots of money! [Freelancer](https://freelancer.com) happens to be the site which I happen to know is really famous for this method. There might be many more of them, so let me know about other awesome ones as well.

**This method happen to be really useful for the users with skill willing to do tasks full-time/part-time.** _Keep in mind, you are paid on the basis of the task you do!_

## **Affiliate Marketing**

Affiliate Marketing indeed is also an amazing way to make money online. When you have an amazing website running, you can opt in for affiliate marketing by allowing various companies to insert web links with affiliate code on your site. When visitors to your site buy product or services by clicking on those links, you get some percentage of the amount spent by the visitor. Although it is not an easy task to find a company who will be willing to opt in this. And indeed you will not make any money if the visitors are not making any purchase through the link on your site. But if you think you got what this needs, then you will make lots and lots of money with real ease!

_I never have personally tried this, but I do know this really works! Lots of YouTubers and social influencer do use this method with the selling of their merchandises._

## **PTC**

There are several sites out there who offer you money when you complete certain offers, surveys, or when you click an advertisement! There are some popular sites out there such as [**Ysense** (_ClixSense_)](https://www.ysense.com/) which lots of people use and you will even find hundreds of people claiming to have made with such sites. But be aware, not all of those sites can be genuine. It really is upto you whether you can to trust the site and invest your time on it or not!

_Aside from those online claims, I neither have ever tried this method nor do I know anyone personally who claims this method to be working. But I leave the final decision upto you completely._

### Other methods

Apart from the described methods above, you can even try these stuffs out as well!

- **Consulting**: You can make money via consulting others if you are expert in any field
- **Online courses**: You can have some online courses to teach others and make money from it

_In this article I have brief introduction to all the methods. Hopefully I will get into detailed discussion about some of these methods in some of mine future articles, so STAY TUNED! Also I am not sponsored/paid by anyone to make up this list or promote anyone/anything specific. I made up this list to help you out._

Until next time, **Stay Safe!**]]></content:encoded>
      <pubDate>Sun, 26 Apr 2020 00:00:00 GMT</pubDate>
    </item>
    <item>
      <title>Working with Supercell API</title>
      <guid isPermaLink="false">how-to-use-supercell-api-with-dynamic-ip</guid>
      <link>https://www.santoshb.com.np/blog/how-to-use-supercell-api-with-dynamic-ip/</link>
      <description>Using the supercell games' API requires a static IP, which means users doing hobby projects will not be able to use them. Not long after reading this article. I personally have got it working and so will you.</description>
      <content:encoded><![CDATA[Almost everyone using the official Supercell games API has shown disagreement with the fact that the official API limit key to IP addresses.
Lots of the people using the API are using it personally for hobby projects and thus use free services. But that limitation of the Supercell API is causing lots of problem to the free users using the service.

**Thus to overcome that issue, I have though of this work around.**

## **How does it actually work?**

- It logins to the developer portal using the mail and password provided through the config.
- It then fetches the available API keys and checks if any key has the current IP whitelisted.
- If found returns the token, otherwise generate a new one for the current IP and return it.
- All the requests to the Official API are made then using the generated key

## **That sounds risky!!**

Well I am not sure about it to be honest but I am pretty sure that things should be fine unless you are doing something really wired! Although you should be aware of these stuffs:

- You are using your mail and password to login to the developer site so you should always make sure then are not publicly posted anywhere! `Important`
- This is not how supercell want's you to access the developer site and create a token and supercell might take actions against you, so make sure to use alternative mails for this purpose..
- Use this method until and unless you are able to get yourself with a **static IP**. If you get one, try to opt out of this method as soon as possible!
  If you are doing what is mentioned above, you should be safe!

## **What extra can I do with it?**

You can **customize** the service as per your needs. If you need to save the responses in some database for analytics purposes then you can simply edit the route files i.e. `{game}/routes/{file}` and customize it as per the need. You can even add custom routes, remove the routes available or modify the available routes as per the requirements.

## **Heard enough! How do I use it?**

Yeah I have talked enough as well. The first thing is, the service is built using _express_ and contains a _index.js_ file to be started with. So all you got to do is run the file through command line as `node index.js`. But well I don't think you will be running it on your local machine. So I have some steps you can follow to host it over heroku. I do consider you already know about **heroku** and **github**.

- Fork this repo [bsantosh909/supercell-api](https://github.com/bsantosh909/supercell-api)
- Update the **config.js** to enable the API you want to use
- Create a new project at heroku
- Connect the heroku app to the forked repo (one at your profile)
- Enable automatic deploys and select `heroku` branch for it (_The heroku branch is setup for hosting at heroku_)
- In the setting tab add environment variables `GLOBAL_MAIL`, `GLOBAL_PASS`, `CLASH_MAIL`, `CLASH_PASS`, `ROYALE_MAIL`, `ROYALE_PASS`, `BRAWL_MAIL`, `BRAWL_PASS`
  - Set `GLOBAL_MAIL` and `GLOBAL_PASS` if you have the mail and password same over all the developer portals
  - Otherwise set the other variables with the individual values of mail and password over the respective developer portals
  - **NOTE:** `GLOBAL_MAIL` and `GLOBAL_PASS` Will surpass values of other relative variables

Doing all the steps mentioned above, you will have a working version of your service that works to receive data from the official API and works just like it. But currently due to the limitation of Heroku, your API will sleep after 30 minutes of inactivity. Well it will not stop working but after that time the initial request will take a longer time.
To overcome this limitation you can use service like [UptimeRobot](https://uptimerobot.com)

```js[config.js]
// Enabling the games
exports.games = {
  clash: false,
  royale: false,
  brawl: true
};

// Set mail and pass are same across all dev platforms
exports.global = {
  mail: 'shared-mail@gmail.com',
  password: 'shared-secret-key'
};

// Set mail and pass for single platform
exports.brawl = {
  mail: 'your-mail@gmail.com',
  password: 'secret-password-here'
};
```

## **How to use with full control?**

Technically it is possible by extracting the core of the project i.e. `util/tokener.js` in the github repository. This file is the reason behind the success of this concept. So if you want to have completely control over how you do stuffs while having this awesome feature, you can simply get the file from the github repo and use as your requirements.

## **How can I believe you are not lying?**

Well I can understand it's hard to believe something you just read up on internet. But I got a proof of concept to prove my words. [**CLICK HERE FOR PROOF OF CONCEPT**](https://statscell.herokuapp.com)

## **Anything else?**

Thats all from me. But if you got anything you can contact me through my contact mail. But if it is some Bug or feature idea, simply report it over at the original Repository. I will be more than happy to hear feedback from you guys.]]></content:encoded>
      <pubDate>Sat, 07 Mar 2020 00:00:00 GMT</pubDate>
    </item>
  </channel>
</rss>
