<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>howto &amp;mdash; Attach to Process</title>
    <link>https://devblog.dinobansigan.com/tag:howto</link>
    <description>Thoughts and Notes on Software Development</description>
    <pubDate>Tue, 14 Apr 2026 18:22:49 +0000</pubDate>
    <image>
      <url>https://i.snap.as/4wmUdb6N.png</url>
      <title>howto &amp;mdash; Attach to Process</title>
      <link>https://devblog.dinobansigan.com/tag:howto</link>
    </image>
    <item>
      <title>How to Make Image Clickable Using Markdown?</title>
      <link>https://devblog.dinobansigan.com/how-to-make-image-clickable-using-markdown?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[For awhile now, I was wondering if it was possible to use Markdown, to make an image clickable. By that I mean, display an image in a blog post, and allow the reader to click that image to view the image in a tab. You can see an example at the end of this post.&#xA;&#xA;So anyway, I know what the Markdown syntax is for a link and for an image, but I&#39;ve never been able to put the two together until today. &#xA;&#xA;Thanks to this post for the idea on how to do it. This saved me from having to write JavaScript that would find all the Snap.as images in a blog post, then wrap them in an a/a tag just to make the images clickable and open in a browser tab.&#xA;&#xA;So just to recap, the Markdown syntax for a link is this:&#xA;Link text&#xA;&#xA;And the Markdown syntax for an image is this:&#xA;Alt Text for image&#xA;&#xA;So, given the Markdown listed below for an image, how do you display the image and make it clickable at the same time?&#xA;Mazda FC RX-7 - A little drifting action&#xA;!--more--&#xA;The answer is that you put the Markdown for the image inside the Markdown for a link, like so:&#xA;Mazda FC RX-7 - A little drifting action&#xA;&#xA;A couple of things to note here:&#xA;&#xA;The whole Markdown for the image goes inside the brackets [], the &#34;Link text&#34; portion of the Markdown for a link. This is what allows the image to show up as the content of a link.&#xA;The URL to the image goes inside the parenthesis (), the &#34;Link URL&#34; portion of the Markdown for a link. It kinda looks redundant, having the same URL to the image one after another. But that&#39;s how you make it work with the Markdown syntax for an image and a link.&#xA;&#xA;And finally, here it is in action:&#xA;Mazda FC RX-7 - A little drifting action&#xA;&#xA;Tags: #HowTo #Markdown&#xA;&#xA;a href=&#34;https://remark.as/p/devblog.dinobansigan.com/how-to-make-image-clickable-using-markdown&#34;Discuss.../a or leave a comment below.]]&gt;</description>
      <content:encoded><![CDATA[<p>For awhile now, I was wondering if it was possible to use Markdown, to make an image clickable. By that I mean, display an image in a blog post, and allow the reader to click that image to view the image in a tab. <em>You can see an example at the end of this post.</em></p>

<p>So anyway, I know what the Markdown syntax is for a link and for an image, but I&#39;ve never been able to put the two together until today.</p>

<p><em>Thanks to <a href="https://firepress.org/en/how-to-make-an-image-clickable-with-markdown/">this post</a> for the idea on how to do it. This saved me from having to write JavaScript that would find all the Snap.as images in a blog post, then wrap them in an <code>&lt;a&gt;&lt;/a&gt;</code> tag just to make the images clickable and open in a browser tab.</em></p>

<p>So just to recap, the Markdown syntax for a link is this:
<code>[Link text](Link URL)</code></p>

<p>And the Markdown syntax for an image is this:
<code>![Alt Text for image](Image URL)</code></p>

<p>So, given the Markdown listed below for an image, how do you display the image and make it clickable at the same time?
<code>![Mazda FC RX-7 - A little drifting action](https://i.snap.as/2IxnDguK.png)</code>

The answer is that you put the Markdown for the image inside the Markdown for a link, like so:
<code>[![Mazda FC RX-7 - A little drifting action](https://i.snap.as/2IxnDguK.png)](https://i.snap.as/2IxnDguK.png)</code></p>

<p>A couple of things to note here:</p>
<ul><li>The whole Markdown for the image goes inside the brackets <code>[]</code>, the “Link text” portion of the Markdown for a link. This is what allows the image to show up as the content of a link.</li>
<li>The URL to the image goes inside the parenthesis <code>()</code>, the “Link URL” portion of the Markdown for a link. It kinda looks redundant, having the same URL to the image one after another. But that&#39;s how you make it work with the Markdown syntax for an image and a link.</li></ul>

<p>And finally, here it is in action:
<a href="https://i.snap.as/2IxnDguK.png"><img src="https://i.snap.as/2IxnDguK.png" alt="Mazda FC RX-7 - A little drifting action"/></a></p>

<p><em>Tags: <a href="https://devblog.dinobansigan.com/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://devblog.dinobansigan.com/tag:Markdown" class="hashtag"><span>#</span><span class="p-category">Markdown</span></a></em></p>

<p><strong><a href="https://remark.as/p/devblog.dinobansigan.com/how-to-make-image-clickable-using-markdown">Discuss...</a></strong> or leave a comment below.</p>
]]></content:encoded>
      <guid>https://devblog.dinobansigan.com/how-to-make-image-clickable-using-markdown</guid>
      <pubDate>Wed, 27 Jul 2022 04:39:02 +0000</pubDate>
    </item>
    <item>
      <title>How to add Responsive &#34;Last Updated Date&#34; to Pinned Pages on Write.as</title>
      <link>https://devblog.dinobansigan.com/responsive-date-writeas-pinned-pages?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[On some of the pinned pages on my journal, I added a &#34;Last Updated Date&#34; value right under the title. I did it using a span element, like this:&#xA;&#xA;Archive📜&#xA;&#xA;span class=&#34;lastUpdatedDate&#34;Last Updated: 2021-03-17/span&#xA;&#xA;Now, instead of having it show up under the title all the time, I also wanted it to show up to the right of the title, if the screen was wide enough. &#xA;&#xA;So, if the page is being viewed on a wide screen, like on a desktop computer, the &#34;Last Updated Date&#34; will show up on the right side. If the page is being viewed on a small screen, like on a mobile phone, the &#34;Last Updated Date&#34; will show up under the title.  &#xA;&#xA;Here is how I made it responsive using Custom CSS:&#xA;&#xA;span.lastUpdatedDate {&#xA;   font-size: 0.7em; &#xA;   color: silver; &#xA;}&#xA;@media screen and (min-width: 480px) {&#xA;   span.lastUpdatedDate {&#xA;      float: right; &#xA;      margin-top: -4em; &#xA;      margin-bottom: -4em;&#xA;   }&#xA;}&#xA;@media screen and (max-width: 479px) {&#xA;   span.lastUpdatedDate {&#xA;      margin-top: -2em;&#xA;      padding-bottom: 2em;&#xA;      display: block;&#xA;   }&#xA;}&#xA;&#xA;Here is what it looks like on a wide screen:&#xA;Last Updated Date showing up on the right side of the title.&#xA;&#xA;Here is what it looks like on a mobile phone:&#xA;Last Updated Date showing up under the title on a small screen.&#xA;&#xA;If you know of an easier way to do this with less CSS, please let know in the comments below. Or you can do so privately by leaving me a message.&#xA;&#xA;Tags: #HowTo #CSS #WriteAs&#xA;&#xA;!--emailsub--&#xA;&#xA;a href=&#34;https://remark.as/p/devblog.dinobansigan.com/responsive-date-writeas-pinned-pages&#34;Discuss.../a or leave a comment below.]]&gt;</description>
      <content:encoded><![CDATA[<p>On <a href="https://journal.dinobansigan.com/archive">some</a> of the pinned pages on my <a href="https://journal.dinobansigan.com/">journal</a>, I added a <em>“Last Updated Date”</em> value right under the title. I did it using a <code>span</code> element, like this:</p>

<pre><code class="language-md"># Archive📜

&lt;span class=&#34;lastUpdatedDate&#34;&gt;Last Updated: 2021-03-17&lt;/span&gt;
</code></pre>

<p>Now, instead of having it show up under the title all the time, I also wanted it to show up to the right of the title, if the screen was wide enough.</p>

<p>So, if the page is being viewed on a wide screen, like on a desktop computer, the <em>“Last Updated Date”</em> will show up on the right side. If the page is being viewed on a small screen, like on a mobile phone, the <em>“Last Updated Date”</em> will show up under the title.</p>

<p>Here is how I made it responsive using Custom CSS:</p>

<pre><code class="language-css">span.lastUpdatedDate {
   font-size: 0.7em; 
   color: silver; 
}
@media screen and (min-width: 480px) {
   span.lastUpdatedDate {
      float: right; 
      margin-top: -4em; 
      margin-bottom: -4em;
   }
}
@media screen and (max-width: 479px) {
   span.lastUpdatedDate {
      margin-top: -2em;
      padding-bottom: 2em;
      display: block;
   }
}
</code></pre>

<p>Here is what it looks like on a wide screen:
<img src="https://i.snap.as/XmHMe4tj.png" alt="Last Updated Date showing up on the right side of the title."/></p>

<p>Here is what it looks like on a mobile phone:
<img src="https://i.snap.as/7OXxRJdU.png" alt="Last Updated Date showing up under the title on a small screen."/></p>

<p>If you know of an easier way to do this with less CSS, please let know in the comments below. Or you can do so privately by <a href="https://devblog.dinobansigan.com/contact">leaving me a message</a>.</p>

<p><em>Tags: <a href="https://devblog.dinobansigan.com/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://devblog.dinobansigan.com/tag:CSS" class="hashtag"><span>#</span><span class="p-category">CSS</span></a> <a href="https://devblog.dinobansigan.com/tag:WriteAs" class="hashtag"><span>#</span><span class="p-category">WriteAs</span></a></em></p>



<p><strong><a href="https://remark.as/p/devblog.dinobansigan.com/responsive-date-writeas-pinned-pages">Discuss...</a></strong> or leave a comment below.</p>
]]></content:encoded>
      <guid>https://devblog.dinobansigan.com/responsive-date-writeas-pinned-pages</guid>
      <pubDate>Fri, 21 May 2021 17:30:00 +0000</pubDate>
    </item>
    <item>
      <title>How to Customize the Footer on a Write.as Website</title>
      <link>https://devblog.dinobansigan.com/how-to-customize-the-footer-on-a-write-as-website?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[There are two ways that I know of to customize the footer on a Write.as website. The first one is through CSS and the second one is through JavaScript. I&#39;ll go through those two options in this post.&#xA;&#xA;Option 1: CSS&#xA;&#xA;I got this idea of customizing the footer via CSS after looking at Robert Xu&#39;s Write.as powered site. It puzzled me that I could not highlight the text in the footer. After viewing the page source, I finally figured out that it was CSS trickery. &#xA;&#xA;So, anyway here we are. To customize the footer using CSS, all you need to do is modify the following CSS script, then add it to the Custom CSS settings for your website.&#xA;footer nav::before {&#xA;    content: &#34;Copyright © 2020 - 2021 by Your Name \A&#34;;&#xA;    white-space: pre-wrap;&#xA;}&#xA;!--more--&#xA;Note the \A at the end of the content value. That basically functions like a line break (br /) in HTML. Without that, the content value will show up to the left of the &#34;published with write.as&#34; footer text. With \A in place, the content value will show up above the &#34;published with write.as&#34; footer text.&#xA;&#xA;That also means that through the use of \A, you can add however many lines of text you want into your footer.&#xA;&#xA;So, the main thing I like about using CSS for a customized footer, is that even if JavaScript is disabled on the browser, it will still work. If all you really want is to display some text on the footer, this is the best option in my opinion.&#xA;&#xA;Now the thing that I don&#39;t like about it, is that it doesn&#39;t allow you to add hyperlinks in your footer. If you want to do that, then you have to use JavaScript.&#xA;&#xA;hr class=&#34;sb&#34;/&#xA;&#xA;Option 2: JavaScript&#xA;&#xA;As I mentioned above, one of the reasons to go with JavaScript for a customized footer, is that it allows you to add hyperlinks as part of the footer content. This means that you can add links to other websites, or to a license, etc...&#xA;&#xA;To customize the footer using JavaScript, modify the contents of the customFooterHTML variable below, then copy and add the JavaScript code to the Custom Javascript settings for your website.&#xA;/ Custom Footer/&#xA;var customFooterHTML = &#39;Copyright © 2019 - 2021 by a class=&#34;home pubd&#34; href=&#34;WebsiteUrl&#34; target=&#34;_blank&#34;Your Name/abr /The opinions expressed herein are my own and do not represent those of my employerbr /or any other third-party views in any way.br /published with a class=&#34;home pubd&#34; href=&#34;https://write.as/&#34;write.as/a&#39;;&#xA;&#xA;var x = document.querySelector(&#39;footer&#39;).getElementsByTagName(&#39;nav&#39;)[0];&#xA;x.innerHTML = customFooterHTML;&#xA;span class=&#34;imageCaption&#34;For an example of this customized footer in action, scroll to the bottom of this page./span&#xA;&#xA;Note that I added class=&#34;home pubd&#34; to my links (anchor elements). home and pubd are Write.as classes that have their own specific styling. I added them so that I won&#39;t run into padding issues in the footer. This also means that you can put in other class names that you can style via your own Custom CSS settings.&#xA;&#xA;Also note that instead of using \A to force a line break, I use the regular HTML br / line break. This is one of the benefits of going with the JavaScript approach. You are pretty much working with HTML at this point. This also means that you can put any valid HTML elements in there.&#xA;&#xA;Lastly, note that I also added published with a class=&#34;home pubd&#34; href=&#34;https://write.as/&#34;write.as/a as part of the value for customFooterHTML. That&#39;s because with this approach, you are replacing the content of the footer with the content inside the customFooterHTML variable. So, if I don&#39;t add it, that text won&#39;t show up. &#xA;&#xA;Maybe that&#39;s something you don&#39;t want to include in the first place. If that&#39;s the case, then you can simply exclude it from the value of the  customFooterHTML variable.&#xA;&#xA;So, you already know what I like about this approach -- the ability to use HTML and add hyperlinks. What about drawbacks? &#xA;&#xA;Well, since this is done via the Custom Javascript settings for your website, if one of the scripts in there runs into an error, it is possible that your footer won&#39;t be rendered. Also, if someone is viewing your website on a browser with JavaScript disabled, then your footer also won&#39;t show up. It&#39;s not that big of a deal, but something to keep in mind when using this approach.&#xA;&#xA;Tags: #HowTo #WriteAs #CSS #JavaScript&#xA;&#xA;a href=&#34;https://remark.as/p/devblog.dinobansigan.com/how-to-customize-the-footer-on-a-write-as-website&#34;Discuss.../a or leave a comment below.]]&gt;</description>
      <content:encoded><![CDATA[<p>There are two ways that I know of to customize the footer on a <a href="https://write.as/">Write.as</a> website. The first one is through CSS and the second one is through JavaScript. I&#39;ll go through those two options in this post.</p>

<h3 id="option-1-css" id="option-1-css">Option 1: CSS</h3>

<p>I got this idea of customizing the footer via CSS after looking at <a href="https://robxu9.com/">Robert Xu&#39;s</a> Write.as powered site. It puzzled me that I could not highlight the text in the footer. After viewing the page source, I finally figured out that it was CSS trickery.</p>

<p>So, anyway here we are. To customize the footer using CSS, all you need to do is modify the following CSS script, then add it to the Custom CSS settings for your website.</p>

<pre><code class="language-css">footer nav::before {
    content: &#34;Copyright © 2020 - 2021 by Your Name \A&#34;;
    white-space: pre-wrap;
}
</code></pre>



<p>Note the <code>\A</code> at the end of the <code>content</code> value. That basically functions like a line break (<code>&lt;br /&gt;</code>) in HTML. Without that, the content value will show up to the left of the “published with write.as” footer text. With <code>\A</code> in place, the content value will show up above the “published with write.as” footer text.</p>

<p>That also means that through the use of <code>\A</code>, you can add however many lines of text you want into your footer.</p>

<p>So, the main thing I like about using CSS for a customized footer, is that even if JavaScript is disabled on the browser, it will still work. If all you really want is to display some text on the footer, this is the best option in my opinion.</p>

<p>Now the thing that I don&#39;t like about it, is that it doesn&#39;t allow you to add hyperlinks in your footer. If you want to do that, then you have to use JavaScript.</p>

<hr class="sb"/>

<h3 id="option-2-javascript" id="option-2-javascript">Option 2: JavaScript</h3>

<p>As I mentioned above, one of the reasons to go with JavaScript for a customized footer, is that it allows you to add hyperlinks as part of the footer content. This means that you can add links to other websites, or to a license, etc...</p>

<p>To customize the footer using JavaScript, modify the contents of the <code>customFooterHTML</code> variable below, then copy and add the JavaScript code to the Custom Javascript settings for your website.</p>

<pre><code class="language-js">/* Custom Footer*/
var customFooterHTML = &#39;Copyright © 2019 - 2021 by &lt;a class=&#34;home pubd&#34; href=&#34;WebsiteUrl&#34; target=&#34;_blank&#34;&gt;Your Name&lt;/a&gt;&lt;br /&gt;The opinions expressed herein are my own and do not represent those of my employer&lt;br /&gt;or any other third-party views in any way.&lt;br /&gt;published with &lt;a class=&#34;home pubd&#34; href=&#34;https://write.as/&#34;&gt;write.as&lt;/a&gt;&#39;;

var x = document.querySelector(&#39;footer&#39;).getElementsByTagName(&#39;nav&#39;)[0];
x.innerHTML = customFooterHTML;
</code></pre>

<p><span class="imageCaption">For an example of this customized footer in action, scroll to the bottom of this page.</span></p>

<p>Note that I added <code>class=&#34;home pubd&#34;</code> to my links (anchor elements). <code>home</code> and <code>pubd</code> are Write.as classes that have their own specific styling. I added them so that I won&#39;t run into padding issues in the footer. This also means that you can put in other class names that you can style via your own Custom CSS settings.</p>

<p>Also note that instead of using <code>\A</code> to force a line break, I use the regular HTML <code>&lt;br /&gt;</code> line break. This is one of the benefits of going with the JavaScript approach. You are pretty much working with HTML at this point. This also means that you can put any valid HTML elements in there.</p>

<p>Lastly, note that I also added <code>published with &lt;a class=&#34;home pubd&#34; href=&#34;https://write.as/&#34;&gt;write.as&lt;/a&gt;</code> as part of the value for <code>customFooterHTML</code>. That&#39;s because with this approach, you are replacing the content of the footer with the content inside the <code>customFooterHTML</code> variable. So, if I don&#39;t add it, that text won&#39;t show up.</p>

<p><em>Maybe that&#39;s something you don&#39;t want to include in the first place. If that&#39;s the case, then you can simply exclude it from the value of the  <code>customFooterHTML</code> variable.</em></p>

<p>So, you already know what I like about this approach — the ability to use HTML and add hyperlinks. What about drawbacks?</p>

<p>Well, since this is done via the Custom Javascript settings for your website, if one of the scripts in there runs into an error, it is possible that your footer won&#39;t be rendered. Also, if someone is viewing your website on a browser with JavaScript disabled, then your footer also won&#39;t show up. It&#39;s not that big of a deal, but something to keep in mind when using this approach.</p>

<p><em>Tags: <a href="https://devblog.dinobansigan.com/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://devblog.dinobansigan.com/tag:WriteAs" class="hashtag"><span>#</span><span class="p-category">WriteAs</span></a> <a href="https://devblog.dinobansigan.com/tag:CSS" class="hashtag"><span>#</span><span class="p-category">CSS</span></a> <a href="https://devblog.dinobansigan.com/tag:JavaScript" class="hashtag"><span>#</span><span class="p-category">JavaScript</span></a></em></p>

<p><strong><a href="https://remark.as/p/devblog.dinobansigan.com/how-to-customize-the-footer-on-a-write-as-website">Discuss...</a></strong> or leave a comment below.</p>
]]></content:encoded>
      <guid>https://devblog.dinobansigan.com/how-to-customize-the-footer-on-a-write-as-website</guid>
      <pubDate>Sat, 16 Jan 2021 00:00:00 +0000</pubDate>
    </item>
    <item>
      <title>Blog Post Navigation using JavaScript | Part 2</title>
      <link>https://devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-2?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Update 04/26/2021: I have since taken down my Journal Entries, so the links on this post won&#39;t work anymore. However, the idea and logic described in this post, is still applicable for posts that you wanted to add a Previous or Next link to.&#xA;&#xA;In Part 1, I covered how I generated links to the Previous and Next post for my &#34;indexed&#34; journal entries. In this post, I&#39;ll talk about how I generated the links for non-indexed journal entries.&#xA;&#xA;Handling Old Journal Entries&#xA;So, now that I have navigation working for my &#34;indexed&#34; entries. I turned my attention to my a href=&#34;#precursor&#34;emprecursor/em/a journal entries. These entries don&#39;t use base 10 numbers as indexes in their slugs/URLs. For example, the post slug for Journal Entry - I ends in &#34;I&#34;, which is a roman numeral. Same goes for Journal Entry - II, III, IV and so on. To further complicate things, I decided to leave the post slugs unchanged for other precursor journal entries. The post slug for Journal Entry - XV for instance is still &#34;decisions-decisions&#34;. I thought about writing JavaScript that would convert roman numerals to base 10 numbers. But then that won&#39;t work for non-indexed entries like Journal Entry - XV.&#xA;&#xA;Shot myself in the foot right there, huh?   &lt;&#xA;!--more--&#xA;&#xA;The solution I came up with was to hide the slugs to the Previous and Next post, in the post itself. These slugs will get picked up by JavaScript and used for generating the corresponding links. Yeah I know, this is also a bit of a manual process. But I only had 16 precursor journal entries. I didn&#39;t mind updating them one by one to add the slugs for the Previous and Next post in the series. &#xA;&#xA;For future entries in a series, I would consider adding the slugs for the Previous and Next post as part of the writing process. For example, I&#39;ve recently implemented this solution to entries in my Book Review series. For the next Book Review post that I&#39;ll write, I will add the slugs as part of writing the post. And I&#39;ll also update the previous post in the series to point to the new one. -- Update 04/26/2021: I eventually removed these links on the Book Review posts because they were getting picked up by my search app.&#xA;&#xA;Here is an example of how I hid the slugs in a post. In this case, it is for Journal Entry - XV. You can easily verify by looking at the page source. The key to hiding the slugs is using style=&#34;display: none;&#34; for the styling.&#xA;div id=&#34;nextLinkSlug&#34; style=&#34;display: none;&#34;vacation-week-is-over/div &#xA;div id=&#34;previousLinkSlug&#34; style=&#34;display: none;&#34;journal-entry-xiv/div &#xA;&#xA;The slugs will then be picked up by JavaScript and used for generating links to the Next and Previous post in the series. Sample script below for generating the link to the Previous post.&#xA;try {&#xA;     previousLinkUrl = &#34;https://journal.dinobansigan.com/&#34; + document.getElementById(&#34;previousLinkSlug&#34;).innerHTML;&#xA;&#xA;     previousLinkText = &#39;&lt;a class=&#34;previousLink&#34; title=&#34;Get Previous entry in this series&#34; href=&#34;&#39;;&#xA;     previousLinkText = previousLinkText.concat(previousLinkUrl);&#xA;     previousLinkText = previousLinkText.concat(&#39;&#34;  &amp;#8592;Previous/a&#39;);&#xA;} catch (err) { }&#xA;Wrapping the code in a try catch block is crucial here. This is to avoid running into JavaScript errors when viewing a post that doesn&#39;t have any hidden slugs. Basically, calling document.getElementById(&#34;previousLinkSlug&#34;).innerHTML on a post that doesn&#39;t have a previous link slug will throw an error. When that happens, the rest of your custom JavaScript will not run at all.&#xA;&#xA;Before I end this post, I&#39;ll address a question that you might have about the use of slugs in a post. Instead of slugs, why not just add links (URLs) to the Previous and Next post in the series? True, I could have done that. The reason I didn&#39;t, is because I didn&#39;t want to add any more hard-coded URLs into the post. Also, this keeps the slugs &#34;domain agnostic&#34;. I don&#39;t know if that is a proper term. What I mean is, I could switch to a different domain name for this site and not have to mess with all the posts. I would only need to update the Javascript to use the new domain name and all the links should keep working.&#xA;&#xA;Lastly, you might be thinking, why go through all this trouble of manually inserting slugs into a post and writing JavaScript, just so I can display a link to the Previous and Next post in a series? The answer is, because I can and it helps me learn more about JavaScript. Part of the perks of owning your own blog/site, is that you can do what you want with it. You don&#39;t have to follow what everyone else is doing, you can make it your own.&#xA;&#xA;hr /&#xA;p id=&#34;precursor&#34; style=&#34;font-size: 0.9em; font-style: italic;&#34;Precursor journal entries were entries I wrote before I started a a href=&#34;https://journal.dinobansigan.com/journal-entry-009&#34; target=&#34;blank&#34;30 day hiatus for my Digital Declutter phase/a. These were impromptu entries written mostly at night before going to bed. However, starting from a href=&#34;https://journal.dinobansigan.com/journal-entry-010&#34; target=&#34;_blank&#34;Journal Entry - 010/a, the journal entries that I&#39;ve been writing are purely based off entries from my bullet journal./p&#xA;&#xA;Tags: ##HowTo #JavaScript #WriteAs&#xA;&#xA;a href=&#34;https://remark.as/p/devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-2&#34;Discuss.../a or leave a comment below.]]&gt;</description>
      <content:encoded><![CDATA[<p><em>Update 04/26/2021: I have since taken down my Journal Entries, so the links on this post won&#39;t work anymore. However, the idea and logic described in this post, is still applicable for posts that you wanted to add a Previous or Next link to.</em></p>

<p><em>In <a href="https://devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-1">Part 1</a>, I covered how I generated links to the Previous and Next post for my “indexed” journal entries. In this post, I&#39;ll talk about how I generated the links for non-indexed journal entries.</em></p>

<h3 id="handling-old-journal-entries" id="handling-old-journal-entries">Handling Old Journal Entries</h3>

<p>So, now that I have navigation working for my “indexed” entries. I turned my attention to my <a href="#precursor"><em>precursor</em></a> journal entries. These entries don&#39;t use base 10 numbers as indexes in their slugs/URLs. For example, the post slug for <a href="https://journal.dinobansigan.com/journal-entry-i">Journal Entry – I</a> ends in “I”, which is a roman numeral. Same goes for Journal Entry – II, III, IV and so on. To further complicate things, I decided to leave the post slugs unchanged for other <em>precursor</em> journal entries. The post slug for <a href="https://journal.dinobansigan.com/decisions-decisions">Journal Entry – XV</a> for instance is still “decisions-decisions”. I thought about writing JavaScript that would convert roman numerals to base 10 numbers. But then that won&#39;t work for non-indexed entries like Journal Entry – XV.</p>

<p><em>Shot myself in the foot right there, huh? &gt;_&lt;</em>
</p>

<p>The solution I came up with was to hide the slugs to the Previous and Next post, in the post itself. These slugs will get picked up by JavaScript and used for generating the corresponding links. Yeah I know, this is also a bit of a manual process. But I only had 16 precursor journal entries. I didn&#39;t mind updating them one by one to add the slugs for the Previous and Next post in the series.</p>

<p><em>For future entries in a series, I would consider adding the slugs for the Previous and Next post as part of the writing process. For example, I&#39;ve recently implemented this solution to entries in my <a href="https://journal.dinobansigan.com/tag:BookReview">Book Review</a> series. For the next Book Review post that I&#39;ll write, I will add the slugs as part of writing the post. And I&#39;ll also update the previous post in the series to point to the new one. — Update 04/26/2021: I eventually removed these links on the Book Review posts because they were getting picked up by my search app.</em></p>

<p>Here is an example of how I hid the slugs in a post. In this case, it is for Journal Entry – XV. <em>You can easily verify by looking at the page source. The key to hiding the slugs is using <code>style=&#34;display: none;&#34;</code> for the styling.</em></p>

<pre><code class="language-html">&lt;div id=&#34;nextLinkSlug&#34; style=&#34;display: none;&#34;&gt;vacation-week-is-over&lt;/div &gt;
&lt;div id=&#34;previousLinkSlug&#34; style=&#34;display: none;&#34;&gt;journal-entry-xiv&lt;/div &gt;
</code></pre>

<p>The slugs will then be picked up by JavaScript and used for generating links to the Next and Previous post in the series. Sample script below for generating the link to the Previous post.</p>

<pre><code class="language-js">try {
     previousLinkUrl = &#34;https://journal.dinobansigan.com/&#34; + document.getElementById(&#34;previousLinkSlug&#34;).innerHTML;

     previousLinkText = &#39;&lt;a class=&#34;previousLink&#34; title=&#34;Get Previous entry in this series&#34; href=&#34;&#39;;
     previousLinkText = previousLinkText.concat(previousLinkUrl);
     previousLinkText = previousLinkText.concat(&#39;&#34;&gt;&amp;#8592;Previous&lt;/a&gt;&#39;);
} catch (err) { }
</code></pre>

<p>Wrapping the code in a <code>try catch</code> block is crucial here. This is to avoid running into JavaScript errors when viewing a post that doesn&#39;t have any hidden slugs. Basically, calling <code>document.getElementById(&#34;previousLinkSlug&#34;).innerHTML</code> on a post that doesn&#39;t have a previous link slug will throw an error. When that happens, the rest of your custom JavaScript will not run at all.</p>

<p>Before I end this post, I&#39;ll address a question that you might have about the use of slugs in a post. Instead of slugs, why not just add links (URLs) to the Previous and Next post in the series? True, I could have done that. The reason I didn&#39;t, is because I didn&#39;t want to add any more hard-coded URLs into the post. Also, this keeps the slugs “domain agnostic”. <em>I don&#39;t know if that is a proper term.</em> What I mean is, I could switch to a different domain name for this site and not have to mess with all the posts. I would only need to update the Javascript to use the new domain name and all the links should keep working.</p>

<p>Lastly, you might be thinking, why go through all this trouble of manually inserting slugs into a post and writing JavaScript, just so I can display a link to the Previous and Next post in a series? The answer is, because I can and it helps me learn more about JavaScript. Part of the perks of owning your own blog/site, is that you can do what you want with it. You don&#39;t have to follow what everyone else is doing, you can make it your own.</p>

<hr/>

<p id="precursor" id="precursor" style="font-size: 0.9em; font-style: italic;">Precursor journal entries were entries I wrote before I started a <a href="https://journal.dinobansigan.com/journal-entry-009" target="_blank">30 day hiatus for my Digital Declutter phase</a>. These were impromptu entries written mostly at night before going to bed. However, starting from <a href="https://journal.dinobansigan.com/journal-entry-010" target="_blank">Journal Entry - 010</a>, the journal entries that I&#39;ve been writing are purely based off entries from my bullet journal.</p>

<p><em>Tags: #<a href="https://devblog.dinobansigan.com/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://devblog.dinobansigan.com/tag:JavaScript" class="hashtag"><span>#</span><span class="p-category">JavaScript</span></a> <a href="https://devblog.dinobansigan.com/tag:WriteAs" class="hashtag"><span>#</span><span class="p-category">WriteAs</span></a></em></p>

<p><strong><a href="https://remark.as/p/devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-2">Discuss...</a></strong> or leave a comment below.</p>
]]></content:encoded>
      <guid>https://devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-2</guid>
      <pubDate>Tue, 23 Jun 2020 17:22:20 +0000</pubDate>
    </item>
    <item>
      <title>Blog Post Navigation using JavaScript | Part 1</title>
      <link>https://devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-1?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Update 06/22/2020: Didn&#39;t realize that the JavaScript that I talked about in this post, was actually creating a Next link for this post. It thought this was a Journal Entry post, because it found that text in here. That&#39;s hilarious, but that is also part of the fun of tinkering. I have fixed it.&#xA;&#xA;Update 04/26/2021: I have since taken down my Journal Entries, so the links on this post won&#39;t work anymore. However, the idea and logic described in this post, is still applicable for posts that uses index numbers for post slugs. For a working example of this, check out the posts on my photo-blog.&#xA;&#xA;Finally got full blog post navigation working for my Journal Entries. If you have JavaScript enabled on your browser, you could effectively navigate from Journal Entry - I up to Journal Entry - XVI, then continue on to Journal Entry - 001, all the way up to the latest one (as of this writing), Journal Entry - 060. You can also navigate from Journal Entry - 060, all the way back down to Journal Entry - I.&#xA;&#xA;Getting Post Slug and Index&#xA;To make navigation work between blog posts in a series, I made use of a standard format for post slugs/URLs. I call them &#34;indexed&#34; entries because I added an index to the end of the slug/URL. For example, &#34;journal-entry-001&#34;, &#34;journal-entry-002&#34;, &#34;journal-entry-003&#34; and so on. It&#39;s really just a way to help me figure out the sequence of posts.&#xA;&#xA;So, first off, here is the JavaScript for getting the post slug from the URL. Then from there, getting the post index from the slug. Without this code, it will be impossible to automatically generate the links to the Previous and Next posts.&#xA;var element = document.querySelector(&#39;meta[property=&#34;og:url&#34;]&#39;);&#xA;var content = element &amp;&amp; element.getAttribute(&#34;content&#34;);&#xA;&#xA;// Get post slug&#xA;var postSlug = content.split(&#39;/&#39;).pop();&#xA;var postIndex = postSlug.split(&#39;-&#39;).pop();&#xA;!--more--&#xA;Generating Link to Previous Post&#xA;This was easy because all I had to do in JavaScript was calculate the previous index value, based on the current index. If you&#39;re viewing Journal Entry - 010, Javascript will calculate the previous index as 10 - 1, which will give you 9. As long as the calculated previous index value is greater than 0, the script will insert a link to the Previous post.&#xA;&#xA;Here is part of the JavaScript that creates the link to the Previous post.&#xA;// Generate Previous link&#xA;if ((postIndex - 1)   0 &amp;&amp;&#xA;    (isJournalEntry || isGameLog || isMusicLog || isVideoGameScreenshots || isGameClips)) {&#xA;    var previousLinkUrl = &#34;https://journal.dinobansigan.com/&#34;;&#xA;&#xA;    var pad = &#39;000&#39;&#xA;    var previousPostIndex = (pad + (postIndex - 1)).slice(-pad.length);&#xA;    var postSlugSplit = postSlug.split(&#39;-&#39;);&#xA;&#xA;    var i;&#xA;    for (i = 0; i &lt; postSlugSplit.length; i++) {&#xA;        if (i + 1 &lt; postSlugSplit.length) {&#xA;            previousLinkUrl = previousLinkUrl.concat(postSlugSplit[i] + &#34;-&#34;);&#xA;        } else {&#xA;            previousLinkUrl = previousLinkUrl.concat(previousPostIndex);&#xA;        }&#xA;    }&#xA;&#xA;    previousLinkText = &#39;&lt;a class=&#34;previousLink&#34; title=&#34;Get Previous entry in this series&#34; href=&#34;&#39;;&#xA;    previousLinkText = previousLinkText.concat(previousLinkUrl);&#xA;    previousLinkText = previousLinkText.concat(&#39;&#34;  &amp;#8592;Previous/a&#39;);&#xA;}&#xA;&#xA;Generating Link to Next Post&#xA;The next thing I wanted to do, was insert links to the Next post in my Journal Entry series. So, if you were viewing Journal Entry - 010, I wanted to display a link to Journal Entry - 011. Unlike the logic for calculating the previous index, on this one I cannot check if the calculated index is greater than zero. I needed another way to tell me what the upper limit was.&#xA;&#xA;The solution I came up with for this is a bit of a manual process. I added a variable at the start of the script, var latestJournalEntryIndex = 60;, to track the latest journal entry index. Then I used this value to figure out if I&#39;m already at the latest journal entry. If so, then the script won&#39;t insert a link to the next post. &#xA;&#xA;So, every time I publish a new journal entry, I have to remember to update the latestJournalEntryIndex variable in my Custom JavaScript. Like I said, it is a bit of a manual process, but it works. Even if I forget to update the variable, it won&#39;t break anything. It just means that navigating up is limited until the variable gets updated. Anyway, until I can figure out a better way of handling it, this will do for now.&#xA;&#xA;Here is part of the JavaScript that creates the link to the Next post.&#xA;// Generate Next link&#xA;var nextIndex = parseInt(postIndex) + 1;&#xA;&#xA;if ((nextIndex &lt;= latestJournalEntryIndex &amp;&amp; isJournalEntry) ||&#xA;    (nextIndex &lt;= latestMusicLogIndex &amp;&amp; isMusicLog)) {&#xA;    var nextLinkUrl = &#34;https://journal.dinobansigan.com/&#34;;&#xA;&#xA;    var pad = &#39;000&#39;&#xA;    var nextPostIndex = (pad + (parseInt(postIndex) + 1)).slice(-pad.length);&#xA;    var postSlugSplit = postSlug.split(&#39;-&#39;);&#xA;&#xA;    var j;&#xA;    for (j = 0; j &lt; postSlugSplit.length; j++) {&#xA;        if (j + 1 &lt; postSlugSplit.length) {&#xA;            nextLinkUrl = nextLinkUrl.concat(postSlugSplit[j] + &#34;-&#34;);&#xA;        } else {&#xA;            nextLinkUrl = nextLinkUrl.concat(nextPostIndex);&#xA;        }&#xA;    }&#xA;&#xA;    nextLinkText = &#39;&lt;a class=&#34;previousLink&#34; title=&#34;Get Next entry in this series&#34; href=&#34;&#39;;&#xA;    nextLinkText = nextLinkText.concat(nextLinkUrl);&#xA;    nextLinkText = nextLinkText.concat(&#39;&#34;  Next&amp;#8594;/a&#39;);&#xA;}&#xA;Note that in the script above, I had to use the parseInt method to get the Next index value. While in the script for getting the Previous index, I could simply do postIndex - 1. This is a weird thing with JavaScript. If the value of postIndex is &#39;010&#39;, running postIndex - 1 will give you back a value of 9. But running postIndex + 1 will give you back a value of &#39;0101&#39;. In other words, with the + operator, JavaScript will do string concatenation. So, you have to use the parseInt method.&#xA;&#xA;Displaying Links&#xA;Lastly, here is the code that brings it all together. The script below will insert the links at the bottom of the post.&#xA;var postLinksText = randomLinkText;&#xA;if (previousLinkText) {&#xA;    postLinksText = previousLinkText.concat(&#39;   &#39; + postLinksText);&#xA;}&#xA;&#xA;postLinksText = postLinksText.concat(&#39;   &#39; + backToTopLinkText);&#xA;&#xA;if (nextLinkText) {&#xA;    postLinksText = postLinksText.concat(&#39;   &#39; + nextLinkText);&#xA;}&#xA;&#xA;var postLinksSection = &#39;br /hr /br /div style=&#34;text-align: center; font-style: normal;&#34;&#39; + postLinksText + &#39;br //div&#39;;&#xA;document.getElementsByTagName(&#34;article&#34;)[0].insertAdjacentHTML(&#39;beforeend&#39;, postLinksSection);&#xA;&#xA;hr class=&#34;sb&#34;/&#xA;That&#39;s it for Part 1. For Part 2, I&#39;ll talk about how I managed to insert Previous and Next links for my other non-indexed journal entries.&#xA;&#xA;Tags: #HowTo #JavaScript #WriteAs&#xA;&#xA;a href=&#34;https://remark.as/p/devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-1&#34;Discuss.../a or leave a comment below.]]&gt;</description>
      <content:encoded><![CDATA[<p><em>Update 06/22/2020: Didn&#39;t realize that the JavaScript that I talked about in this post, was actually creating a Next link for this post. It thought this was a Journal Entry post, because it found that text in here. That&#39;s hilarious, but that is also part of the fun of tinkering. I have fixed it.</em></p>

<p><em>Update 04/26/2021: I have since taken down my Journal Entries, so the links on this post won&#39;t work anymore. However, the idea and logic described in this post, is still applicable for posts that uses index numbers for post slugs. For a working example of this, check out the posts on my <a href="https://ateas.dinobansigan.com/">photo-blog</a>.</em></p>

<p>Finally got full blog post navigation working for my Journal Entries. If you have JavaScript enabled on your browser, you could effectively navigate from <a href="https://journal.dinobansigan.com/journal-entry-i">Journal Entry – I</a> up to <a href="https://journal.dinobansigan.com/vacation-week-is-over">Journal Entry – XVI</a>, then continue on to <a href="https://journal.dinobansigan.com/journal-entry-001">Journal Entry – 001</a>, all the way up to the latest one <em>(as of this writing)</em>, <a href="https://journal.dinobansigan.com/journal-entry-060">Journal Entry – 060</a>. You can also navigate from <a href="https://journal.dinobansigan.com/journal-entry-060">Journal Entry – 060</a>, all the way back down to <a href="https://journal.dinobansigan.com/journal-entry-i">Journal Entry – I</a>.</p>

<h3 id="getting-post-slug-and-index" id="getting-post-slug-and-index">Getting Post Slug and Index</h3>

<p>To make navigation work between blog posts in a series, I made use of a standard format for post slugs/URLs. I call them “indexed” entries because I added an index to the end of the slug/URL. For example, “journal-entry-<strong>001</strong>”, “journal-entry-<strong>002</strong>”, “journal-entry-<strong>003</strong>” and so on. It&#39;s really just a way to help me figure out the sequence of posts.</p>

<p>So, first off, here is the JavaScript for getting the post slug from the URL. Then from there, getting the post index from the slug. Without this code, it will be impossible to automatically generate the links to the Previous and Next posts.</p>

<pre><code class="language-js">var element = document.querySelector(&#39;meta[property=&#34;og:url&#34;]&#39;);
var content = element &amp;&amp; element.getAttribute(&#34;content&#34;);

// Get post slug
var postSlug = content.split(&#39;/&#39;).pop();
var postIndex = postSlug.split(&#39;-&#39;).pop();
</code></pre>



<h3 id="generating-link-to-previous-post" id="generating-link-to-previous-post">Generating Link to Previous Post</h3>

<p>This was easy because all I had to do in JavaScript was calculate the previous index value, based on the current index. If you&#39;re viewing Journal Entry – 010, Javascript will calculate the previous index as <code>10 - 1</code>, which will give you <code>9</code>. As long as the calculated previous index value is greater than 0, the script will insert a link to the Previous post.</p>

<p>Here is part of the JavaScript that creates the link to the Previous post.</p>

<pre><code class="language-js">// Generate Previous link
if ((postIndex - 1) &gt; 0 &amp;&amp;
    (isJournalEntry || isGameLog || isMusicLog || isVideoGameScreenshots || isGameClips)) {
    var previousLinkUrl = &#34;https://journal.dinobansigan.com/&#34;;

    var pad = &#39;000&#39;
    var previousPostIndex = (pad + (postIndex - 1)).slice(-pad.length);
    var postSlugSplit = postSlug.split(&#39;-&#39;);

    var i;
    for (i = 0; i &lt; postSlugSplit.length; i++) {
        if (i + 1 &lt; postSlugSplit.length) {
            previousLinkUrl = previousLinkUrl.concat(postSlugSplit[i] + &#34;-&#34;);
        } else {
            previousLinkUrl = previousLinkUrl.concat(previousPostIndex);
        }
    }

    previousLinkText = &#39;&lt;a class=&#34;previousLink&#34; title=&#34;Get Previous entry in this series&#34; href=&#34;&#39;;
    previousLinkText = previousLinkText.concat(previousLinkUrl);
    previousLinkText = previousLinkText.concat(&#39;&#34;&gt;&amp;#8592;Previous&lt;/a&gt;&#39;);
}
</code></pre>

<h3 id="generating-link-to-next-post" id="generating-link-to-next-post">Generating Link to Next Post</h3>

<p>The next thing I wanted to do, was insert links to the Next post in my Journal Entry series. So, if you were viewing Journal Entry – 010, I wanted to display a link to Journal Entry – 011. Unlike the logic for calculating the previous index, on this one I cannot check if the calculated index is greater than zero. I needed another way to tell me what the upper limit was.</p>

<p>The solution I came up with for this is a bit of a manual process. I added a variable at the start of the script, <code>var latestJournalEntryIndex = 60;</code>, to track the latest journal entry index. Then I used this value to figure out if I&#39;m already at the latest journal entry. If so, then the script won&#39;t insert a link to the next post.</p>

<p>So, every time I publish a new journal entry, I have to remember to update the <code>latestJournalEntryIndex</code> variable in my Custom JavaScript. Like I said, it is a bit of a manual process, but it works. Even if I forget to update the variable, it won&#39;t break anything. It just means that navigating up is limited until the variable gets updated. Anyway, until I can figure out a better way of handling it, this will do for now.</p>

<p>Here is part of the JavaScript that creates the link to the Next post.</p>

<pre><code class="language-js">// Generate Next link
var nextIndex = parseInt(postIndex) + 1;

if ((nextIndex &lt;= latestJournalEntryIndex &amp;&amp; isJournalEntry) ||
    (nextIndex &lt;= latestMusicLogIndex &amp;&amp; isMusicLog)) {
    var nextLinkUrl = &#34;https://journal.dinobansigan.com/&#34;;

    var pad = &#39;000&#39;
    var nextPostIndex = (pad + (parseInt(postIndex) + 1)).slice(-pad.length);
    var postSlugSplit = postSlug.split(&#39;-&#39;);

    var j;
    for (j = 0; j &lt; postSlugSplit.length; j++) {
        if (j + 1 &lt; postSlugSplit.length) {
            nextLinkUrl = nextLinkUrl.concat(postSlugSplit[j] + &#34;-&#34;);
        } else {
            nextLinkUrl = nextLinkUrl.concat(nextPostIndex);
        }
    }

    nextLinkText = &#39;&lt;a class=&#34;previousLink&#34; title=&#34;Get Next entry in this series&#34; href=&#34;&#39;;
    nextLinkText = nextLinkText.concat(nextLinkUrl);
    nextLinkText = nextLinkText.concat(&#39;&#34;&gt;Next&amp;#8594;&lt;/a&gt;&#39;);
}
</code></pre>

<p>Note that in the script above, I had to use the <code>parseInt</code> method to get the Next index value. While in the script for getting the Previous index, I could simply do <code>postIndex - 1</code>. This is a weird thing with JavaScript. If the value of <code>postIndex</code> is <code>&#39;010&#39;</code>, running <code>postIndex - 1</code> will give you back a value of <code>9</code>. But running <code>postIndex + 1</code> will give you back a value of <code>&#39;0101&#39;</code>. In other words, with the + operator, JavaScript will do string concatenation. So, you have to use the <code>parseInt</code> method.</p>

<h3 id="displaying-links" id="displaying-links">Displaying Links</h3>

<p>Lastly, here is the code that brings it all together. The script below will insert the links at the bottom of the post.</p>

<pre><code class="language-js">var postLinksText = randomLinkText;
if (previousLinkText) {
    postLinksText = previousLinkText.concat(&#39;   &#39; + postLinksText);
}

postLinksText = postLinksText.concat(&#39;   &#39; + backToTopLinkText);

if (nextLinkText) {
    postLinksText = postLinksText.concat(&#39;   &#39; + nextLinkText);
}

var postLinksSection = &#39;&lt;br /&gt;&lt;hr /&gt;&lt;br /&gt;&lt;div style=&#34;text-align: center; font-style: normal;&#34;&gt;&#39; + postLinksText + &#39;&lt;br /&gt;&lt;/div&gt;&#39;;
document.getElementsByTagName(&#34;article&#34;)[0].insertAdjacentHTML(&#39;beforeend&#39;, postLinksSection);
</code></pre>

<hr class="sb"/>

<p>That&#39;s it for Part 1. For Part 2, I&#39;ll talk about how I managed to insert Previous and Next links for my other non-indexed journal entries.</p>

<p><em>Tags: <a href="https://devblog.dinobansigan.com/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://devblog.dinobansigan.com/tag:JavaScript" class="hashtag"><span>#</span><span class="p-category">JavaScript</span></a> <a href="https://devblog.dinobansigan.com/tag:WriteAs" class="hashtag"><span>#</span><span class="p-category">WriteAs</span></a></em></p>

<p><strong><a href="https://remark.as/p/devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-1">Discuss...</a></strong> or leave a comment below.</p>
]]></content:encoded>
      <guid>https://devblog.dinobansigan.com/blog-post-navigation-using-javascript-part-1</guid>
      <pubDate>Sat, 20 Jun 2020 03:33:56 +0000</pubDate>
    </item>
    <item>
      <title>How to Embed Responsive YouTube Videos on Write.as</title>
      <link>https://devblog.dinobansigan.com/how-to-embed-responsive-youtube-videos-on-write-as?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Updated: 4/26/2021&#xA;&#xA;Coney complained to me this morning that the YouTube videos on my latest music log entry were getting cut off when viewed from her phone. I&#39;ve known about this issue for awhile, but didn&#39;t really try to find a solution for it. Well, today I did and it turns out to be really easy.&#xA;&#xA;The issue stems from the fact that I have to use iframes to embed videos on write.as sites. To make the YouTube videos I embed on write.as sites responsive, I simply followed the instructions from this Responsive Youtube Embed post. Specifically, these are the changes I added to my journal.&#xA;!--more--&#xA;&#xA;Custom CSS&#xA;I added the following Custom CSS:&#xA;/ Responsive Video Container /&#xA;.video-container {&#xA;    position: relative;&#xA;    padding-bottom: 56.25%;&#xA;    padding-top: 30px; height: 0; overflow: hidden;&#xA;}&#xA; &#xA;.video-container iframe,&#xA;.video-container object,&#xA;.video-container embed {&#xA;    position: absolute;&#xA;    top: 0;&#xA;    left: 0;&#xA;    width: 100%;&#xA;    height: 100%;&#xA;}&#xA;&#xA;HTML Changes&#xA;And on my posts where I embedded YouTube videos, I simply wrapped the iframe element with a div element that had a class attribute value of &#34;video-container&#34;, like this:&#xA;div class=&#34;video-container&#34;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#34;https://www.youtube-nocookie.com/embed/nJS5VpoGbc4&#34; frameborder=&#34;0&#34; allowfullscreen=&#34;&#34;/iframe/div&#xA;&#xA;With those changes in place, I have found that the YouTube videos I embedded on my posts will shrink down to match the size of the screen on a mobile phone, or will expand to match the width of the text on a post when viewed on a desktop browser. Pretty cool.&#xA;&#xA;Tags: #HowTo #HTML #CSS #WriteAs&#xA;&#xA;a href=&#34;https://remark.as/p/devblog.dinobansigan.com/how-to-embed-responsive-youtube-videos-on-write-as&#34;Discuss.../a or leave a comment below.]]&gt;</description>
      <content:encoded><![CDATA[<p><em>Updated: 4/26/2021</em></p>

<p>Coney complained to me this morning that the YouTube videos on my latest <a href="https://journal.dinobansigan.com/music-log-025">music log entry</a> were getting cut off when viewed from her phone. I&#39;ve known about this issue for awhile, but didn&#39;t really try to find a solution for it. Well, today I did and it turns out to be really easy.</p>

<p>The issue stems from the fact that I have to use iframes to embed videos on <a href="https://write.as/">write.as</a> sites. To make the YouTube videos I embed on write.as sites responsive, I simply followed the instructions from this <a href="https://avexdesigns.com/responsive-youtube-embed/">Responsive Youtube Embed</a> post. Specifically, these are the changes I added to my <a href="https://journal.dinobansigan.com/">journal</a>.
</p>

<h4 id="custom-css" id="custom-css">Custom CSS</h4>

<p>I added the following Custom CSS:</p>

<pre><code class="language-css">/* Responsive Video Container */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 30px; height: 0; overflow: hidden;
}
 
.video-container iframe,
.video-container object,
.video-container embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
</code></pre>

<h4 id="html-changes" id="html-changes">HTML Changes</h4>

<p>And on my posts where I embedded YouTube videos, I simply wrapped the iframe element with a div element that had a class attribute value of “video-container”, like this:</p>

<pre><code class="language-html">&lt;div class=&#34;video-container&#34;&gt;&lt;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#34;https://www.youtube-nocookie.com/embed/nJS5VpoGbc4&#34; frameborder=&#34;0&#34; allowfullscreen=&#34;&#34;&gt;&lt;/iframe&gt;&lt;/div&gt;
</code></pre>

<p>With those changes in place, I have found that the YouTube videos I embedded on my posts will shrink down to match the size of the screen on a mobile phone, or will expand to match the width of the text on a post when viewed on a desktop browser. Pretty cool.</p>

<p><em>Tags: <a href="https://devblog.dinobansigan.com/tag:HowTo" class="hashtag"><span>#</span><span class="p-category">HowTo</span></a> <a href="https://devblog.dinobansigan.com/tag:HTML" class="hashtag"><span>#</span><span class="p-category">HTML</span></a> <a href="https://devblog.dinobansigan.com/tag:CSS" class="hashtag"><span>#</span><span class="p-category">CSS</span></a> <a href="https://devblog.dinobansigan.com/tag:WriteAs" class="hashtag"><span>#</span><span class="p-category">WriteAs</span></a></em></p>

<p><strong><a href="https://remark.as/p/devblog.dinobansigan.com/how-to-embed-responsive-youtube-videos-on-write-as">Discuss...</a></strong> or leave a comment below.</p>
]]></content:encoded>
      <guid>https://devblog.dinobansigan.com/how-to-embed-responsive-youtube-videos-on-write-as</guid>
      <pubDate>Sun, 19 Apr 2020 18:07:39 +0000</pubDate>
    </item>
  </channel>
</rss>