<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Web Development on jshji</title><link>https://jshji.com/categories/web-development/</link><description>Recent content in Web Development on jshji</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 30 Jan 2022 23:15:00 +0000</lastBuildDate><atom:link href="https://jshji.com/categories/web-development/index.xml" rel="self" type="application/rss+xml"/><item><title>SEO, nextjs</title><link>https://jshji.com/posts/seo-nextjs/</link><pubDate>Sun, 30 Jan 2022 23:15:00 +0000</pubDate><guid>https://jshji.com/posts/seo-nextjs/</guid><description>&lt;a href="javascript:history.back()" class="back-button"&gt;← Back&lt;/a&gt;
&lt;p&gt;So I&amp;rsquo;ve implemented nextjs on this blog. You shouldn&amp;rsquo;t feel anything different of course, as its an internal change. I thought nextjs was going to create static HTML files for all, but it turns out it didn&amp;rsquo;t. (But it &lt;em&gt;can&lt;/em&gt; do if we want to). This means that:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SEO friendly doesn&amp;rsquo;t necessarily mean you have to have HTML files&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I think nextjs still uses js and some other things, but somehow they achieve SEO. Maybe I&amp;rsquo;ll have a look later, or maybe not as i don&amp;rsquo;t realy need it. It&amp;rsquo;s good enough to know that these thing exist.&lt;/p&gt;</description></item><item><title>Nextjs</title><link>https://jshji.com/posts/nextjs/</link><pubDate>Thu, 27 Jan 2022 20:09:00 +0000</pubDate><guid>https://jshji.com/posts/nextjs/</guid><description>&lt;a href="javascript:history.back()" class="back-button"&gt;← Back&lt;/a&gt;
&lt;h2 id="nextjs"&gt;Next.js&lt;/h2&gt;
&lt;p&gt;Solves lots of problems regarding static sites generation.&lt;/p&gt;
&lt;h3 id="pages"&gt;Pages&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;all pages reside under &lt;code&gt;/pages/&lt;/code&gt; dir.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pages/index.js&lt;/code&gt; is associated with the &lt;code&gt;/&lt;/code&gt; route.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;pages/posts/first-post.js&lt;/code&gt; is associated with the &lt;code&gt;/posts/first-post&lt;/code&gt; route.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="static-generation"&gt;Static generation&lt;/h3&gt;
&lt;p&gt;Your contents &lt;em&gt;or&lt;/em&gt; paths depend on external data.&lt;/p&gt;
&lt;h4 id="-your-contents-depend-on-external-data"&gt;&amp;gt; Your contents depend on external data.&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Blog&lt;/span&gt;({ &lt;span style="color:#a6e22e"&gt;posts&lt;/span&gt; }) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Render posts...
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// This function gets called at build time
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;export&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;async&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;getStaticProps&lt;/span&gt;() {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// Call an external API endpoint to get posts
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;res&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;await&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;fetch&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;https://.../posts&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;posts&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;await&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;res&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;json&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// By returning { props: { posts } }, the Blog component
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;// will receive `posts` as a prop at build time
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;props&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;posts&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;export&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;default&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Blog&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="-your-paths-depend-on-external-data"&gt;&amp;gt; Your paths depend on external data.&lt;/h4&gt;
&lt;p&gt;First, prepare a special file under a path, &lt;code&gt;pages/posts/[id].js&lt;/code&gt;. Here, &lt;code&gt;[].js&lt;/code&gt; is special structure. Then, similarly, add a function at the bottom:&lt;/p&gt;</description></item><item><title>Project 1 - Refactor InkyFingerz</title><link>https://jshji.com/posts/project-1-refactor-inkyfingerz/</link><pubDate>Thu, 27 Jan 2022 12:20:00 +0000</pubDate><guid>https://jshji.com/posts/project-1-refactor-inkyfingerz/</guid><description>&lt;a href="javascript:history.back()" class="back-button"&gt;← Back&lt;/a&gt;
&lt;h2 id="project-description"&gt;Project Description&lt;/h2&gt;
&lt;p&gt;Refactor the codes for InkyFingerz, using modern tools, especially &lt;code&gt;template engine&lt;/code&gt; and &lt;code&gt;static site generator&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="project-objective"&gt;Project Objective&lt;/h2&gt;
&lt;p&gt;In the end, the project will have:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Much less reptition in terms of developer experience. For example, the developer won&amp;rsquo;t have to copy and paste &lt;code&gt;Header&lt;/code&gt; and &lt;code&gt;Footer&lt;/code&gt; for each of the three pages.&lt;/li&gt;
&lt;li&gt;The output should be roughly the same as current version. For example, there will be separte files for each page (static!).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="technology"&gt;Technology&lt;/h2&gt;
&lt;p&gt;I&amp;rsquo;ll use &lt;code&gt;11ty&lt;/code&gt; for the static site generator, and use &lt;code&gt;liquidjs&lt;/code&gt; for template engine. &lt;code&gt;11ty&lt;/code&gt; is compatible with a dozen template engines including &lt;code&gt;Nunjucks&lt;/code&gt;, &lt;code&gt;liquidjs&lt;/code&gt;, &lt;code&gt;Mustache&lt;/code&gt;, &lt;code&gt;ejs&lt;/code&gt;, &lt;code&gt;pug&lt;/code&gt; and more. I&amp;rsquo;ve used &lt;code&gt;ejs&lt;/code&gt; and &lt;code&gt;pug&lt;/code&gt; before, like, I&amp;rsquo;ve had a go at them. So it won&amp;rsquo;t make much difference even if I learnt a new one. On the website, &lt;code&gt;11ty&lt;/code&gt; shows supported features for each engine, and &lt;code&gt;liquidjs&lt;/code&gt; and &lt;code&gt;nunjucks&lt;/code&gt; had the most supported features. I won&amp;rsquo;t need most of them, but still! I chose &lt;code&gt;liquidjs&lt;/code&gt; because it is actively being maintained, whereas &lt;code&gt;nunjucks&lt;/code&gt; had its lastest release 2 years ago.&lt;/p&gt;</description></item><item><title>Jamstack, Static Site Generators, and Lack of High Level Planning - Again</title><link>https://jshji.com/posts/jamstack-static-site-generators-and-lack-of-high-level-planning-again/</link><pubDate>Wed, 26 Jan 2022 02:21:00 +0000</pubDate><guid>https://jshji.com/posts/jamstack-static-site-generators-and-lack-of-high-level-planning-again/</guid><description>&lt;a href="javascript:history.back()" class="back-button"&gt;← Back&lt;/a&gt;
&lt;p&gt;I talked about lack of high level planning before in &lt;em&gt;SPA and SEO - can we make peace?&lt;/em&gt; post. High level planning is extremely important. With high level planning, we can achieve:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;A &lt;em&gt;much&lt;/em&gt; shorter development time: I don&amp;rsquo;t have to wait until the problem arises &lt;em&gt;after&lt;/em&gt; all the coding.&lt;/li&gt;
&lt;li&gt;A better product: well planned product vs. a toy!&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The problem is that coding is fun, so whenever I have an idea I have this urge to just get my IDE up and start creating something. Well, it&amp;rsquo;s definitely much, much, much better than not creating anything, (no product vs. a toy) and I think it&amp;rsquo;s a good way to get used to programming and all when you&amp;rsquo;re a beginner. In fact, when you&amp;rsquo;re just starting programming, maybe you know too little to plan anything good. But now I should be moving on from the beginner phase, so it has almost no benefits, but a lot of harms.&lt;/p&gt;</description></item><item><title>SPA and SEO - can we make peace?</title><link>https://jshji.com/posts/spa-and-seo-can-we-make-peace/</link><pubDate>Sun, 23 Jan 2022 22:20:00 +0000</pubDate><guid>https://jshji.com/posts/spa-and-seo-can-we-make-peace/</guid><description>&lt;a href="javascript:history.back()" class="back-button"&gt;← Back&lt;/a&gt;
&lt;p&gt;After my blog came into a shape, a question came to me: how do I get my blog to be not just searchable on Google, but also provide meaningful meta-data? Few days ago, I did manage to submit my webpage to Google, so now the world&amp;rsquo;s most popular search engine does have my data. It was a simple process, all I had to do was to verify that this address (*.jshji.com) was mine. This is what Google&amp;rsquo;s search result shows currently:&lt;/p&gt;</description></item></channel></rss>