<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Dev articles]]></title><description><![CDATA[Dev articles]]></description><link>https://blogs.amrit-acharya.com.np</link><generator>RSS for Node</generator><lastBuildDate>Fri, 05 Jun 2026 21:09:06 GMT</lastBuildDate><atom:link href="https://blogs.amrit-acharya.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Generate a sitemap for the react application]]></title><description><![CDATA[Creating a sitemap for a React application can indeed be a complex task, especially when managing routes dynamically. However, with the right approach, this process can be simplified significantly. In this article, I'll guide you through the steps to...]]></description><link>https://blogs.amrit-acharya.com.np/generate-a-sitemap-for-the-react-application</link><guid isPermaLink="true">https://blogs.amrit-acharya.com.np/generate-a-sitemap-for-the-react-application</guid><dc:creator><![CDATA[Amrit Acharya]]></dc:creator><pubDate>Wed, 06 Mar 2024 09:16:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1709714840833/22525dd8-5d2f-4a1d-8e61-03571e7589d9.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Creating a sitemap for a React application can indeed be a complex task, especially when managing routes dynamically. However, with the right approach, this process can be simplified significantly. In this article, I'll guide you through the steps to streamline the creation of a sitemap for your React application.</p>
<p>Let's dive right in!</p>
<p>If you're using React Router v6 in your project, the first step is to define an array of route objects. These route objects should include at least the route path and a descriptive name. This array will serve as the foundation for generating our sitemap.</p>
<p>Alternatively, you can store your route data in a separate JSON file. Simply create a JSON file and populate it with route information, focusing only on the route path and name attributes.</p>
<p>Here's a quick example of how you can structure your route data (src/data.json):</p>
<pre><code class="lang-json">{ <span class="hljs-attr">"routes"</span>:[
  { <span class="hljs-attr">"path"</span>: <span class="hljs-string">"/"</span>, <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Home"</span> },
  { <span class="hljs-attr">"path"</span>: <span class="hljs-string">"/about"</span>, <span class="hljs-attr">"name"</span>: <span class="hljs-string">"About"</span> },
  { <span class="hljs-attr">"path"</span>: <span class="hljs-string">"/contact"</span>, <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Contact"</span> },
  <span class="hljs-comment">// Add more routes as needed</span>
]
</code></pre>
<p>Now, let's discuss how we can simplify the process of generating the sitemap.</p>
<p>Create a file named as createSitemap.mjs inside src folder.</p>
<p>createSitemap.mjs includes</p>
<pre><code class="lang-json">import fs from <span class="hljs-string">"fs"</span>;
import data from <span class="hljs-string">"./data.json"</span> assert { type: <span class="hljs-string">"json"</span> };
const routes = data.routes?.map((route) =&gt; {
  return {
    path: route.route,
    name: route.key.label,
  };
});

const hostname = <span class="hljs-string">"https://themebuilderwebfront.bcctl.com"</span>;
const generateSitemap = (routes) =&gt; {
  const sitemap = `&lt;?xml version=<span class="hljs-attr">"1.0"</span> encoding=<span class="hljs-attr">"UTF-8"</span>?&gt;
  &lt;urlset xmlns=<span class="hljs-attr">"http://www.sitemaps.org/schemas/sitemap/0.9"</span>&gt;
    ${routes
      .map((route) =&gt; {
        return `
        &lt;url&gt;
          &lt;loc&gt; ${hostname}${route.path}&lt;/loc&gt;
          &lt;lastmod&gt;${new Date().toISOString()}&lt;/lastmod&gt;
        &lt;/url&gt;
      `;
      })
      .join(<span class="hljs-string">""</span>)}
  &lt;/urlset&gt;`;

  fs.writeFileSync(<span class="hljs-string">"public/sitemap.xml"</span>, sitemap);
};
generateSitemap(routes);
</code></pre>
<p>After completing the steps outlined above, you're ready to generate your sitemap. Simply follow these instructions to run the command in your project's root directory terminal:</p>
<p>Open your terminal or command prompt.</p>
<pre><code class="lang-bash">node src/createSitemap.mjs
</code></pre>
<p>Congratulations! You've successfully generated the sitemap.xml file for your React application. This crucial step ensures that your website is effectively indexed by search engines, enhancing its discoverability and boosting its online presence.</p>
<p>With this sitemap in place, search engine crawlers can efficiently navigate through your website's structure, ensuring that all relevant pages are properly indexed and included in search results. This is essential for maximizing your website's visibility and attracting organic traffic.</p>
<p>By automating the sitemap generation process, you've streamlined a tedious task, allowing you to focus on building and enhancing your website's content and functionality. This proactive approach to search engine optimization (SEO) sets a strong foundation for your online presence, ultimately driving more visitors to your site and achieving your business goals.</p>
<p>Keep up the great work, and continue exploring ways to optimize and improve your website for maximum impact. Happy site building!</p>
]]></content:encoded></item><item><title><![CDATA[Code splitting in React JS]]></title><description><![CDATA["An organized or maintainable code can speak for itself, there is no need to explain" In React JS there is a main concept to enhance the performance of code and its maintainability, which is code splitting. Code splitting is a way to divide your code...]]></description><link>https://blogs.amrit-acharya.com.np/code-splitting-in-react-js</link><guid isPermaLink="true">https://blogs.amrit-acharya.com.np/code-splitting-in-react-js</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[React]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Programming Tips]]></category><dc:creator><![CDATA[Amrit Acharya]]></dc:creator><pubDate>Wed, 10 Jan 2024 04:47:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/XXMA-8fBB-g/upload/af46a8814f50eac4cf67fb89de0a26e4.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>"An organized or maintainable code can speak for itself, there is no need to explain" In React JS there is a main concept to enhance the performance of code and its maintainability, which is code splitting. Code splitting is a way to divide your code into smaller chunks or parts due to which you easily specify your specific functionality within the app.</p>
<p>One of the main benefits of code splitting is that no need to load the entire bundle JavaScript bundle, code splitting enables you to load only those portions of code that are related to a particular page. This leads to a reduction in initial load time as well as improves the performance of your application.</p>
<p><strong>Some of the key benefits of code splitting are as follows:</strong></p>
<ol>
<li><p>Better caching and Resource utilization</p>
</li>
<li><p>Enhance performance</p>
</li>
<li><p>Reduce initial load time</p>
</li>
<li><p>Reduce bandwidth consumption</p>
</li>
</ol>
<p><strong>Implementing code splitting</strong></p>
<ol>
<li><p>Dynamic importing with React.lazy()</p>
</li>
<li><p>Implementing route based coding with libraries like react-router allows you to write page-specific code.</p>
</li>
<li><p>Handle errors with ErrorBoudary</p>
</li>
<li><p>Implement component loading with Suspense</p>
</li>
<li><p>Webpack code splitting: webpack is a popular module bundler for JavaScript applications, webpack breaks buldle into multiple files and allows you to load only those portions of the component that are required.</p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[How to open any GitHub repo to VsCode?]]></title><description><![CDATA[Yes, you can open any GitHub repo into vscode with one click.
Steps:

Open your GitHub repository in your browser just like following.
 

And press the dot on your keyboard and enjoy 😊.
 

Result 🤗
 
 Thank You!]]></description><link>https://blogs.amrit-acharya.com.np/how-to-open-any-github-repo-to-vscode</link><guid isPermaLink="true">https://blogs.amrit-acharya.com.np/how-to-open-any-github-repo-to-vscode</guid><category><![CDATA[vscode]]></category><category><![CDATA[GitHub]]></category><dc:creator><![CDATA[Amrit Acharya]]></dc:creator><pubDate>Fri, 29 Dec 2023 09:40:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/KPAQpJYzH0Y/upload/57f0de1f567a2158fea2c8a7290ebdfa.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Yes, you can open any GitHub repo into vscode with one click.</p>
<p>Steps:</p>
<ol>
<li><p>Open your GitHub repository in your browser just like following.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703842009737/47921199-296c-4fdc-9078-c18f9b4b77d2.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>And press the dot on your keyboard and enjoy 😊.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703842506892/38b6d701-2256-4eea-9140-707947717910.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Result 🤗</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1703842646625/921e4902-7352-4008-b88c-c8345b961de2.png" alt class="image--center mx-auto" /></p>
<p> Thank You!</p>
</li>
</ol>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Enter does not work in vs code.]]></title><description><![CDATA[Solutions
Option 1:
Go to settings.json file in vs code and write the following command
{
 "editor.acceptSuggestionOnEnter": "on", //or "editor.acceptSuggestionOnEnter": "smart"
}

Option 2:

If you have installed https://marketplace.visualstudio.com...]]></description><link>https://blogs.amrit-acharya.com.np/enter-does-not-work-in-vs-code</link><guid isPermaLink="true">https://blogs.amrit-acharya.com.np/enter-does-not-work-in-vs-code</guid><category><![CDATA[vscode extensions]]></category><category><![CDATA[vscode]]></category><category><![CDATA[VSCode Tips]]></category><category><![CDATA[enter]]></category><dc:creator><![CDATA[Amrit Acharya]]></dc:creator><pubDate>Wed, 04 Oct 2023 08:43:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/6tedMQIJpNI/upload/991376893f5a30da5a3dad3f44928e1e.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-solutions">Solutions</h3>
<p><strong>Option 1:</strong></p>
<p>Go to settings.json file in vs code and write the following command</p>
<pre><code class="lang-json">{
 <span class="hljs-attr">"editor.acceptSuggestionOnEnter"</span>: <span class="hljs-string">"on"</span>, <span class="hljs-comment">//or "editor.acceptSuggestionOnEnter": "smart"</span>
}
</code></pre>
<p><strong>Option 2:</strong></p>
<ol>
<li><p>If you have installed <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components">https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components</a> extension in your vs code extensions, just uninstall it and try an alternative because it is not well maintained extension.</p>
</li>
<li><p>Press "CTRL+K+S" simultaneously and the window is opened</p>
</li>
<li><p>Search "enter" there and right-click on the command contributed by vscode-styled-components</p>
</li>
<li><p>Then press on "Remove binding".</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1696408816344/9b183128-6940-48d6-81be-6bc53f251f8a.png" alt class="image--center mx-auto" /></p>
<p> Here, your enter problem should be fixed. If any confusion please contact me through email: <a target="_blank" href="http://amritach222@gmail.com">amritach222@gmail.com</a></p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Docker]]></title><description><![CDATA[Introduction
Docker is an environment for developing, shipping and running an application in containers. Docker provides a way to create, deploy, and manage containers efficiently, making it easier to build and deploy software across different enviro...]]></description><link>https://blogs.amrit-acharya.com.np/docker</link><guid isPermaLink="true">https://blogs.amrit-acharya.com.np/docker</guid><category><![CDATA[Devops]]></category><category><![CDATA[Docker]]></category><dc:creator><![CDATA[Amrit Acharya]]></dc:creator><pubDate>Tue, 03 Oct 2023 08:24:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/HSACbYjZsqQ/upload/2cfccd1c4f77831a4189749e1584adf6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">Introduction</h3>
<p>Docker is an environment for developing, shipping and running an application in containers. Docker provides a way to create, deploy, and manage containers efficiently, making it easier to build and deploy software across different environments consistently.</p>
<h3 id="heading-wsl">WSL</h3>
<p>WSL stands for Windows Subsystem for Linux. It provides an environment that allows us to run Linux tools and programs inside Windows. Once you install WSL, which provides us with a bash terminal, where we can run Linux commands within our Windows OS.<br /><strong>Steps to enable WSL in Windows:</strong></p>
<ol>
<li><p>Go to the "Windows turn feature off and on" section in your system.</p>
</li>
<li><p>Tick on Windows Subsystem for Linux and save.</p>
</li>
<li><p>Then Restart your PC.</p>
</li>
<li><p>After restarting Windows go to Microsoft Store and install one of the Linux App (e.g.: Ubuntu 22.0 LTS)</p>
</li>
<li><p>After installing then open open it. If any error occurs then follow the instructions shown</p>
</li>
<li><p>Then set up your Linux system username and password. (Note username and password should not coincide with your Windows username or password)</p>
</li>
<li><p>Then enjoy your Linux subsystem inside Windows.</p>
</li>
</ol>
<p>After setting up WSL you can install docker from bash otherwise you can download <a target="_blank" href="https://www.docker.com/products/docker-desktop/">docker desktop</a> directly into your system.</p>
<h3 id="heading-containers">Containers</h3>
<p>It is a way to package an application with all the necessary dependencies and configuration. These packages can be easily shared and moved between development teams.</p>
<p>This package of containers makes the development environment more efficient.</p>
<h3 id="heading-where-do-containers-live">Where do containers live?</h3>
<p>Containers live in the container repository. So it is a special type of storage for containers.<br />Many companies have their own repository which is known as a private repository.<br />There is also a public repository for the docker. Docker Hub is a public repository for docker.</p>
<h3 id="heading-how-do-containers-improve-development">How do containers improve development?</h3>
<p><strong>Before docker</strong> to develop an application with multiple teams. They run their application on different machine, the services required to set up an environment for the application is also different and there are many steps to set up an application environment which is reduced by containerized concept. Manual setup for an application can be very tedious and time-consuming resulting in loss of time and effort.</p>
<p><strong>After Docker,</strong> you do not have to install any services or dependencies manually on your local machine. Because the container has its own isolated environment. With a based image that provides an isolated environment with everything packaged. Rather developer go and install services for application, developer checks containers to find specific container and download on his local machine.</p>
<h3 id="heading-how-container-environment-help-in-the-deployment-process">How container environment help in the deployment process?</h3>
<p><strong>Before Container</strong></p>
<ul>
<li><p>Configuration on the server needed</p>
</li>
<li><p>Conflicts may occur in dependency version</p>
</li>
<li><p>Misunderstanding between developer and operation team</p>
</li>
<li><p>The developer needs to mention the operation of the configuration.</p>
</li>
</ul>
<p><strong>After Container</strong></p>
<ul>
<li><p>Developers and operations work together to package applications in a container</p>
</li>
<li><p>No environmental configuration is needed on the server except docker runtime</p>
</li>
<li><p>The only thing you need to do is to run docker command. So it is a one-time effort.</p>
</li>
</ul>
<h3 id="heading-docker-image-vs-docker-container">Docker Image vs Docker Container</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Docker Image</td><td>Docker Container</td></tr>
</thead>
<tbody>
<tr>
<td>Actual package</td><td>Actually, start the application</td></tr>
<tr>
<td>Artifact that can be moved around</td><td>A container environment is created.</td></tr>
<tr>
<td>Image run on container</td><td>It is a running environment for image</td></tr>
</tbody>
</table>
</div>]]></content:encoded></item></channel></rss>