<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>javascript &amp;mdash; Iman Codes</title>
    <link>https://iman.codes/tag:javascript</link>
    <description>sometimes it&#39;s fun</description>
    <pubDate>Sat, 02 May 2026 03:13:48 +0000</pubDate>
    <item>
      <title>WriteAs Comments - Talkyard</title>
      <link>https://iman.codes/writeas-comments-talkyard?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[Might be a little silly to have a blog post about implementing comments on WriteAs when this blog itself doesn’t have comments implemented, but I thought I’d put it up here anyway. I have no idea how Javascript works so I only managed to get comments up on my personal blog thanks to various resources, specifically by Dino.&#xA;&#xA;But, it&#39;s code and should probably go up on the code blog!&#xA;&#xA;I wanted a lightweight, privacy-focused commenting system and didn&#39;t want to wait for Remark.as to be open for non-paying Write.as users. Also, I didn&#39;t want to pay through the nose for a system that will probably get like, 2 comments total over the lifetime of my blog. Plus I didn&#39;t want to host it myself, because it&#39;d probably be more of a hassle than it&#39;s worth!&#xA;&#xA;I tried out a couple options that were recommended on the Write.as discussion forums but in the end, I went with Talkyard.&#xA;&#xA;!--more--&#xA;&#xA;Getting the Javascript up and running was way easier when I could refer to Dino&#39;s implementation of Hyvor Talk, but it did take some finagling, since I don&#39;t really know what I&#39;m doing.&#xA;&#xA;A lot of the implementation methods for Write.as comments involved placing a code snippet at the bottom of each post, often with the Write.as signature function to make things easier - but that would also put comments onto pinned posts, which is sometimes not what you&#39;re going for. But Dino&#39;s code for Hyvor Talk was pretty elegant - it would automatically insert the code at the bottom of each post, eliminating the need to manually copy and paste it each time or use the signature function. He also had a way to exclude your pinned posts - that part would be manual, but one has way fewer pinned posts than regular blog posts!&#xA;&#xA;Anyway, something that I managed to do specifically for Talkyard is take the post slug and use it as the Talkyard ID. This means that as long as I don&#39;t change my post slug, I can automatically port my comments if I change the post title or domain name! Which is super convenient since I&#39;ll probably move off the writeas.com domain at some point for the personal blog - I just haven&#39;t committed yet.&#xA;&#xA;I think the script is relatively readable so I&#39;ve just copied and pasted it below:&#xA;&#xA;var currentURL = window.location.href;&#xA;var isAboutPage = /\/about$/i.test(currentURL);&#xA;var isArchivePage = /\/archive$/i.test(currentURL);&#xA;&#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;var postSlug = content.split(&#39;/&#39;).pop();&#xA;&#xA;var talkyardServerUrl = &#39;server URL here&#39;;&#xA;&#xA;var talkyardDiv = &#39;brhrbrdiv class=&#34;talkyard-comments&#34; data-discussion-id=&#34;talkyardID&#34;/div&#39;&#xA;&#xA;talkyardDiv = talkyardDiv.replace(&#34;talkyardID&#34;, postSlug);&#xA;&#xA;if (document.getElementById(&#34;post-body&#34;) &amp;&amp; !isArchivePage &amp;&amp; !isAboutPage) {&#xA;    document.getElementsByTagName(&#34;article&#34;)[0].insertAdjacentHTML(&#39;beforeend&#39;, talkyardDiv );&#xA;}&#xA;&#xA;// src: https://c1.ty-cdn.net/-/talkyard-comments.min.js&#xA;&#xA;Looking at it now, I realize I haven&#39;t excluded my (empty) tags page from here, so maybe I&#39;ll do that... eventually... As an aside, I do like Write.as but there is a lot of manual work for some stuff. Its primary focus is writing and I appreciate it a lot, because it minimizes all the distractions that come from other blogging platforms! But that means it doesn&#39;t have a lot of stuff that comes out-of-box from other platforms too (see: this whole post about putting comments up lol).&#xA;&#xA;But moving on, I also customized the CSS for Talkyard to match my personal blog. That&#39;s actually why I haven&#39;t implemented it on this code blog, even though Talkyard allows you to put it on as many sites as you&#39;d like - the theming would clash completely! My personal blog is very bright and pink, while this one is cool blues. The default theme would&#39;ve actually been acceptable on the code blog, but as of now, without learning a whole lot more about Javascript and CSS, I don&#39;t think I&#39;d be able to have two separate themes.&#xA;&#xA;Talkyard says, on its CSS and Javascript page customization page:&#xA;&#xA;  We&#39;ll give you a simpler way to choose colors, later.&#xA;&#xA;so we&#39;ll see if that comes to fruition! My theming was a complete hack job, so I&#39;m looking forward to... not having it be a complete hack job, lol. And that&#39;s why I won&#39;t be sharing the CSS here.&#xA;&#xA;When I tested things out, it seemed to work really nicely. There’s some moderation features, which will be nice if I ever need that (hopefully not!). &#xA;&#xA;Anyway, hopefully this post will help me in the future, or if I’m really lucky, someone else trying to set up Talkyard on their own Write.as blog, haha.&#xA;&#xA;#javascript #css]]&gt;</description>
      <content:encoded><![CDATA[<p>Might be a little silly to have a blog post about implementing comments on WriteAs when this blog itself doesn’t have comments implemented, but I thought I’d put it up here anyway. I have no idea how Javascript works so I only managed to get comments up on my <a href="https://write.as/iman/" rel="nofollow">personal blog</a> thanks to <a href="https://discuss.write.as/t/adding-comments-to-your-blog/1146/16" rel="nofollow">various</a> <a href="https://discuss.write.as/t/installing-a-write-as-theme/4117/3" rel="nofollow">resources</a>, specifically by <a href="https://journal.dinobansigan.com/" rel="nofollow">Dino</a>.</p>

<p>But, it&#39;s code and should probably go up on the code blog!</p>

<p>I wanted a lightweight, privacy-focused commenting system and didn&#39;t want to wait for Remark.as to be open for non-paying Write.as users. Also, I didn&#39;t want to pay through the nose for a system that will probably get like, 2 comments total over the lifetime of my blog. Plus I didn&#39;t want to host it myself, because it&#39;d probably be more of a hassle than it&#39;s worth!</p>

<p>I tried out a couple options that were recommended on the Write.as discussion forums but in the end, I went with <a href="https://forum.talkyard.io/blog-comments" rel="nofollow">Talkyard</a>.</p>



<p>Getting the Javascript up and running was way easier when I could refer to Dino&#39;s implementation of Hyvor Talk, but it did take some finagling, since I don&#39;t really know what I&#39;m doing.</p>

<p>A lot of the implementation methods for Write.as comments involved placing a code snippet at the bottom of each post, often with the Write.as signature function to make things easier – but that would also put comments onto pinned posts, which is sometimes not what you&#39;re going for. But Dino&#39;s code for Hyvor Talk was pretty elegant – it would automatically insert the code at the bottom of each post, eliminating the need to manually copy and paste it each time or use the signature function. He also had a way to exclude your pinned posts – that part would be manual, but one has way fewer pinned posts than regular blog posts!</p>

<p>Anyway, something that I managed to do specifically for Talkyard is take the post slug and use it as the Talkyard ID. This means that as long as I don&#39;t change my post slug, I can automatically port my comments if I change the post title or domain name! Which is super convenient since I&#39;ll probably move off the writeas.com domain at some point for the personal blog – I just haven&#39;t committed yet.</p>

<p>I think the script is relatively readable so I&#39;ve just copied and pasted it below:</p>

<pre><code>var currentURL = window.location.href;
var isAboutPage = /\/about$/i.test(currentURL);
var isArchivePage = /\/archive$/i.test(currentURL);

var element = document.querySelector(&#39;meta[property=&#34;og:url&#34;]&#39;);
var content = element &amp;&amp; element.getAttribute(&#34;content&#34;);
var postSlug = content.split(&#39;/&#39;).pop();

var talkyardServerUrl = &#39;server URL here&#39;;

var talkyardDiv = &#39;&lt;br&gt;&lt;hr&gt;&lt;br&gt;&lt;div class=&#34;talkyard-comments&#34; data-discussion-id=&#34;talkyardID&#34;&gt;&lt;/div&gt;&#39;

talkyardDiv = talkyardDiv.replace(&#34;talkyardID&#34;, postSlug);


if (document.getElementById(&#34;post-body&#34;) &amp;&amp; !isArchivePage &amp;&amp; !isAboutPage) {
    document.getElementsByTagName(&#34;article&#34;)[0].insertAdjacentHTML(&#39;beforeend&#39;, talkyardDiv );
}

// src: https://c1.ty-cdn.net/-/talkyard-comments.min.js
</code></pre>

<p>Looking at it now, I realize I haven&#39;t excluded my (empty) tags page from here, so maybe I&#39;ll do that... eventually... As an aside, I do like Write.as but there is a lot of manual work for some stuff. Its primary focus is <em>writing</em> and I appreciate it a lot, because it minimizes all the distractions that come from other blogging platforms! But that means it doesn&#39;t have a lot of stuff that comes out-of-box from other platforms too (see: this whole post about putting comments up lol).</p>

<p>But moving on, I also customized the CSS for Talkyard to match my personal blog. That&#39;s actually why I haven&#39;t implemented it on this code blog, even though Talkyard allows you to put it on as many sites as you&#39;d like – the theming would clash completely! My personal blog is very bright and pink, while this one is cool blues. The default theme would&#39;ve actually been acceptable on the code blog, but as of now, without learning a whole lot more about Javascript and CSS, I don&#39;t think I&#39;d be able to have two separate themes.</p>

<p>Talkyard says, on its CSS and Javascript page customization page:</p>

<blockquote><p>We&#39;ll give you a simpler way to choose colors, later.</p></blockquote>

<p>so we&#39;ll see if that comes to fruition! My theming was a complete hack job, so I&#39;m looking forward to... not having it be a complete hack job, lol. And that&#39;s why I won&#39;t be sharing the CSS here.</p>

<p>When I tested things out, it seemed to work really nicely. There’s some moderation features, which will be nice if I ever need that (hopefully not!).</p>

<p>Anyway, hopefully this post will help me in the future, or if I’m really lucky, someone else trying to set up Talkyard on their own Write.as blog, haha.</p>

<p><a href="https://iman.codes/tag:javascript" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">javascript</span></a> <a href="https://iman.codes/tag:css" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">css</span></a></p>
]]></content:encoded>
      <guid>https://iman.codes/writeas-comments-talkyard</guid>
      <pubDate>Sun, 26 Feb 2023 17:45:34 +0000</pubDate>
    </item>
  </channel>
</rss>