<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Pankaj Kumar</title>
    <subtitle>Code explorations, engineering thoughts, and life in between.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://pankaj.xyz/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://pankaj.xyz/"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-10-28T00:00:00+00:00</updated>
    <id>https://pankaj.xyz/atom.xml</id>
    <entry xml:lang="en">
        <title>Serverless, Dependency-Free Article Upvote System for Static Sites</title>
        <published>2026-10-28T00:00:00+00:00</published>
        <updated>2026-10-28T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://pankaj.xyz/posts/serverless-dependency-free-article-upvote-system-for-static-sites/"/>
        <id>https://pankaj.xyz/posts/serverless-dependency-free-article-upvote-system-for-static-sites/</id>
        
        <content type="html" xml:base="https://pankaj.xyz/posts/serverless-dependency-free-article-upvote-system-for-static-sites/">&lt;p&gt;&lt;em&gt;Anonymous per-device votes, one serverless function and one Postgres database. No framework required, no npm packages.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Static sites are fast, cheap and hard to break, but the moment you want a live upvote counter you need somewhere to keep state. This post walks through a small upvote system I built for my blog, which is a static site on &lt;a rel=&quot;noopener nofollow external&quot; target=&quot;_blank&quot; href=&quot;https://pages.cloudflare.com/&quot;&gt;Cloudflare Pages&lt;/a&gt;. Nothing in it depends on a particular site generator: the page side is one HTML snippet, one script and some CSS, and the server side is one function plus three Postgres tables. It was inspired by &lt;a rel=&quot;noopener nofollow external&quot; target=&quot;_blank&quot; href=&quot;https://herman.bearblog.dev/&quot;&gt;Herman’s Bear Blog&lt;/a&gt; and &lt;a rel=&quot;noopener nofollow external&quot; target=&quot;_blank&quot; href=&quot;https://betaveros.bearblog.dev/that-accursed-upvote-button/&quot;&gt;Betaveros’s deep-dive “That Accursed Upvote Button”&lt;/a&gt;, which are both worth reading for the tradeoffs involved.&lt;/p&gt;
&lt;p&gt;By the end you will have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;three tables on &lt;a rel=&quot;noopener nofollow external&quot; target=&quot;_blank&quot; href=&quot;https://neon.com/&quot;&gt;Neon&lt;/a&gt; (any Postgres 12 or newer works),&lt;/li&gt;
&lt;li&gt;one serverless function (about 330 lines of plain JavaScript, including comments),&lt;/li&gt;
&lt;li&gt;one HTML snippet, one small client script and a bit of CSS.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The code in this post is complete. File names are only suggestions, so put things wherever your project layout prefers and adjust the paths in the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag and the &lt;code&gt;data-api&lt;/code&gt; attribute to match.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What you need:&lt;/strong&gt; a static site (any generator, or hand-written HTML) hosted somewhere that can run a serverless function on the same domain, and a free Neon account. The function written in this article is specific to Cloudflare Pages Functions, but can be adapted to other platforms.&lt;/p&gt;
&lt;h2 id=&quot;how-it-fits-together&quot;&gt;How it fits together&lt;a class=&quot;zola-anchor&quot; href=&quot;#how-it-fits-together&quot; aria-label=&quot;Anchor link for: how-it-fits-together&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Browser&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  - anonymous voter token kept in localStorage&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  - optimistic UI, rolled back if the server says no&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        |  fetch() GET / POST (same origin)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        v&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Serverless function  /api/upvote-server&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  - validates input, checks Origin and Content-Type&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  - enforces per-IP hourly caps atomically&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  - one SQL statement per vote&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        |&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        |  HTTPS (Neon SQL over HTTP)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        v&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Postgres (Neon)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  - article_upvotes: one running count per post&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  - article_voters:  one row per (post, device)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  - ip_quota:        short-lived per-IP hourly counters&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;design-goals&quot;&gt;Design goals&lt;a class=&quot;zola-anchor&quot; href=&quot;#design-goals&quot; aria-label=&quot;Anchor link for: design-goals&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;No dependencies in the shipped code.&lt;/strong&gt; Plain JavaScript using &lt;code&gt;fetch()&lt;/code&gt;, &lt;code&gt;crypto.subtle&lt;/code&gt; and &lt;code&gt;localStorage&lt;/code&gt;. (You may still want &lt;a rel=&quot;noopener nofollow external&quot; target=&quot;_blank&quot; href=&quot;https://developers.cloudflare.com/workers/wrangler/&quot;&gt;Wrangler&lt;/a&gt; as a local dev tool, covered below.)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fail visibly, never silently.&lt;/strong&gt; If the API is down, the count is hidden instead of showing a made-up number, and a failed vote is rolled back with a short message. The reader is never locked out.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Per-device votes, not per-network.&lt;/strong&gt; One vote must not lock out everyone behind the same router.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Survive URL changes.&lt;/strong&gt; Renaming a post must not orphan its votes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The count can’t drift.&lt;/strong&gt; The aggregate and the voter rows change in one atomic statement.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;design-decisions-worth-explaining&quot;&gt;Design decisions worth explaining&lt;a class=&quot;zola-anchor&quot; href=&quot;#design-decisions-worth-explaining&quot; aria-label=&quot;Anchor link for: design-decisions-worth-explaining&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;1-identify-voters-with-a-token-not-an-ip-address&quot;&gt;1. Identify voters with a token, not an IP address&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-identify-voters-with-a-token-not-an-ip-address&quot; aria-label=&quot;Anchor link for: 1-identify-voters-with-a-token-not-an-ip-address&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The obvious first approach is to store the visitor’s IP and refuse a second vote from it. The problem is NAT: every device behind one router, from a family’s phones to hundreds of people in an office or on a campus, presents the same public IP. One upvote then locks out the whole network.&lt;/p&gt;
&lt;p&gt;Instead, the browser generates a random anonymous &lt;code&gt;voter_token&lt;/code&gt; and keeps it in &lt;code&gt;localStorage&lt;/code&gt;. The database enforces one vote per &lt;code&gt;(post_id, voter_token)&lt;/code&gt; pair, so a laptop and a phone on the same Wi-Fi can each vote once.&lt;/p&gt;
&lt;p&gt;The IP is not thrown away, but it is used for one narrow purpose: generous hourly caps as a fallback against scripted voting. The server turns it into a keyed hash and uses that only as the key of a short-lived counter row. The hash is never stored next to a vote, and the counter rows are deleted after a couple of hours. The caps are deliberately high, so a shared network can still have many legitimate voters.&lt;/p&gt;
&lt;p&gt;The tradeoff is that clearing site data gives you a fresh identity. For a blog upvote button I think that is acceptable.&lt;/p&gt;
&lt;h3 id=&quot;2-don-t-sign-the-vote-request&quot;&gt;2. Don’t sign the vote request&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-don-t-sign-the-vote-request&quot; aria-label=&quot;Anchor link for: 2-don-t-sign-the-vote-request&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;An earlier version of mine handed out a short-lived HMAC token on &lt;code&gt;GET&lt;/code&gt; and verified it on &lt;code&gt;POST&lt;/code&gt;, so a vote couldn’t be redirected to another post. It looked rigorous, and it protected nothing: anyone scripting the endpoint can simply request a token for whichever post they like. It also made the system more fragile, because a tab left open for an hour had an expired token, and a click that landed before the token arrived was sent without one.&lt;/p&gt;
&lt;p&gt;I removed it. What protects the endpoint now is boring and checkable: strict validation of every input, an &lt;code&gt;Origin&lt;/code&gt; check plus a JSON-only content type (which stop &lt;em&gt;other websites&lt;/em&gt; from casting votes through a visitor’s browser), and per-IP caps. If you later need real bot resistance, put a challenge such as Cloudflare Turnstile in front of the &lt;code&gt;POST&lt;/code&gt; and verify its token on the server before touching the database.&lt;/p&gt;
&lt;h3 id=&quot;3-enforce-the-caps-with-counters-not-by-counting-rows&quot;&gt;3. Enforce the caps with counters, not by counting rows&lt;a class=&quot;zola-anchor&quot; href=&quot;#3-enforce-the-caps-with-counters-not-by-counting-rows&quot; aria-label=&quot;Anchor link for: 3-enforce-the-caps-with-counters-not-by-counting-rows&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The natural way to cap votes per IP is to count that IP’s recent rows in the votes table and insert only if the count is under the limit. Under concurrency that check is unreliable: every request reads the same snapshot, so a burst all passes the check at once. In a test with 100 simultaneous requests from one IP against a cap of 20, this approach let 50 through.&lt;/p&gt;
&lt;p&gt;The fix is to move the check onto a row that Postgres locks. Each IP gets a counter row per hour, and the vote runs &lt;code&gt;INSERT ... ON CONFLICT DO UPDATE ... WHERE n &amp;lt; cap&lt;/code&gt;. Concurrent requests queue on that row and each one re-checks the cap against the latest value. The same test then lets through exactly 20.&lt;/p&gt;
&lt;p&gt;Two honest tradeoffs: the window is a fixed clock hour, so a burst that straddles the hour boundary can get up to twice the cap, and an attempt that is refused still uses up a little quota. Both are harmless for this purpose.&lt;/p&gt;
&lt;h3 id=&quot;4-only-trust-the-server-about-whether-you-voted&quot;&gt;4. Only trust the server about whether you voted&lt;a class=&quot;zola-anchor&quot; href=&quot;#4-only-trust-the-server-about-whether-you-voted&quot; aria-label=&quot;Anchor link for: 4-only-trust-the-server-about-whether-you-voted&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;An optimistic UI is nice, but it creates a nasty failure mode. Suppose the click handler writes &lt;code&gt;upvoted = true&lt;/code&gt; to &lt;code&gt;localStorage&lt;/code&gt; and the request then fails. On every later visit the button is stuck in its voted state while the count shows &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The rules I use: &lt;code&gt;localStorage&lt;/code&gt; is only a cache for the first paint. It is written only after the server confirms the vote, and it is deleted whenever a later &lt;code&gt;GET&lt;/code&gt; says the server has no vote. If the API is merely unreachable, the cache is left alone, so a returning voter still sees their vote. The count stays hidden until the server has reported it, and no “+1” is shown while the real number is unknown. A failed vote is rolled back and the button shows the failure for a few seconds.&lt;/p&gt;
&lt;h3 id=&quot;5-use-aria-disabled-not-disabled&quot;&gt;5. Use aria-disabled, not disabled&lt;a class=&quot;zola-anchor&quot; href=&quot;#5-use-aria-disabled-not-disabled&quot; aria-label=&quot;Anchor link for: 5-use-aria-disabled-not-disabled&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A native &lt;code&gt;disabled&lt;/code&gt; button is removed from the tab order and, in several browsers, stops firing mouse events, so hover feedback such as a tooltip silently stops working. &lt;code&gt;aria-disabled=&quot;true&quot;&lt;/code&gt; plus a CSS class keeps the button focusable and hoverable, and screen readers still announce it as unavailable. The click handler simply returns early. The same state is used for the few seconds after a failed vote, so the button can’t be hammered while the failure message is showing.&lt;/p&gt;
&lt;h2 id=&quot;step-1-create-the-database-tables&quot;&gt;Step 1: Create the database tables&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-1-create-the-database-tables&quot; aria-label=&quot;Anchor link for: step-1-create-the-database-tables&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Create a free project in Neon, open &lt;strong&gt;SQL Editor&lt;/strong&gt; and run:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; One running total per post. Reads are a single primary-key lookup.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; EXISTS&lt;/span&gt;&lt;span&gt; article_upvotes (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    id          &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;VARCHAR&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;200&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; PRIMARY KEY&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    count       &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;INTEGER&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      NOT NULL&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; CHECK&lt;/span&gt;&lt;span&gt; (count &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;&amp;gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    updated_at  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;TIMESTAMP&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;TZ&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  NOT NULL&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; NOW&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; One row per (post, anonymous device token). The primary key is what makes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; a vote idempotent.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; EXISTS&lt;/span&gt;&lt;span&gt; article_voters (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    post_id      &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;VARCHAR&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;200&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; NOT NULL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    voter_token  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;VARCHAR&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;40&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  NOT NULL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    created_at   &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;TIMESTAMP&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;TZ&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  NOT NULL&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; NOW&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    PRIMARY KEY&lt;/span&gt;&lt;span&gt; (post_id, voter_token)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Per-IP hourly counters used for the rate caps, one row per&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; (hashed IP, scope, UTC hour). scope is a post id, or &amp;#39;*&amp;#39; for the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; all-posts cap.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;CREATE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; TABLE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; IF&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; NOT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; EXISTS&lt;/span&gt;&lt;span&gt; ip_quota (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ip_hash       &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;VARCHAR&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;64&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  NOT NULL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    scope         &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;VARCHAR&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;200&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; NOT NULL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    window_start  &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;TIMESTAMP&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;TZ&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  NOT NULL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    n             &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;INTEGER&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      NOT NULL&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; DEFAULT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    PRIMARY KEY&lt;/span&gt;&lt;span&gt; (ip_hash, scope, window_start)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;How the pieces work together:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;article_upvotes&lt;/code&gt;&lt;/strong&gt; holds the number you display.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;article_voters&lt;/code&gt;&lt;/strong&gt; holds one row per vote. Its primary key is what stops a device from voting twice on the same post. No IP-derived data lives here.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;ip_quota&lt;/code&gt;&lt;/strong&gt; holds only a keyed hash and a count per hour. The function deletes rows older than two hours, so these hashes never pile up.&lt;/li&gt;
&lt;li&gt;Because the count lives in a separate table from the votes, the two have to change together. The function in Step 2 does that in a single SQL statement, so they can’t drift apart.&lt;/li&gt;
&lt;li&gt;The column sizes match the validation in the function (post IDs up to 200 characters, tokens of exactly 36). The function uses the three-argument form of &lt;code&gt;date_trunc&lt;/code&gt;, which needs Postgres 12 or newer.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then copy your connection string from the Neon dashboard (&lt;strong&gt;Connect&lt;/strong&gt;, then copy the connection string). It looks like this:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;postgresql://USER:PASSWORD@ep-example-123456.us-east-2.aws.neon.tech/neondb?sslmode=require&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;step-2-the-serverless-function&quot;&gt;Step 2: The serverless function&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-2-the-serverless-function&quot; aria-label=&quot;Anchor link for: step-2-the-serverless-function&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;On Cloudflare Pages, any file under a top-level &lt;code&gt;functions/&lt;/code&gt; directory (at the root of the repository, next to your site’s source) is deployed as a function, and the file path becomes the route. Saving this as &lt;code&gt;functions/api/upvote-server.js&lt;/code&gt; serves it at &lt;code&gt;/api/upvote-server&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; functions/api/upvote-server.js&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Cloudflare Pages Function (native Web APIs, zero dependencies).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Route: /api/upvote-server   (same origin as the site, so no CORS headers)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Environment variables (Pages -&amp;gt; Settings -&amp;gt; Variables and Secrets):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   DATABASE_URL   postgres://user:password@ep-xyz.neon.tech/neondb?sslmode=require&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   UPVOTE_SECRET  random string, 16+ chars. Used to HMAC IP addresses.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;                  POST fails closed (503) if it is missing or too short.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Tables: article_upvotes, article_voters, ip_quota (see Step 1)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; API&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   GET  ?id=&amp;lt;post&amp;gt;&amp;amp;voterToken=&amp;lt;token&amp;gt;  -&amp;gt; 200 { id, count, hasVoted }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   POST { id, voterToken, title }      -&amp;gt; 200 { id, count, hasVoted: true, status: &amp;#39;voted&amp;#39; | &amp;#39;duplicate&amp;#39; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;                                          429 { error: &amp;#39;rate_limited&amp;#39;, count }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   Other failures: 400 / 403 / 413 / 415 / 503 with { error }.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Tunables&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; LIMITS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Per-IP caps per clock hour (UTC). Enforced atomically by counter rows in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ip_quota, so concurrent requests cannot overshoot. Because the window is a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; fixed clock hour, a burst straddling the hour boundary can get up to 2x.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  perPostPerHour&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 20&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; distinct voter tokens per IP per post&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  perIpPerHour&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 60&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; across all posts (also bounds junk post IDs per IP)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  quotaRetentionHours&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ip_quota rows older than this are deleted&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  scrubProbability&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;02&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; fraction of successful votes that trigger cleanup&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  dbTimeoutMs&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 5000&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  maxBodyBytes&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2048&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; POST_ID_MAX&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 200&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Segments start alphanumeric, so &amp;quot;.&amp;quot; / &amp;quot;..&amp;quot; segments are impossible.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; POST_ID_RE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;A-Z&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;a-z&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0-9&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;A-Z&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;a-z&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0-9&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;_~-&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;?:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;A-Z&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;a-z&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0-9&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;A-Z&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;a-z&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0-9&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;_~-&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{0,5}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; VOTER_TOKEN_RE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;vtr_&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;a-f&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0-9&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{32}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; SQL&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; One atomic statement:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   gate (already voted?) -&amp;gt; per-post quota -&amp;gt; all-posts quota -&amp;gt; insert voter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   -&amp;gt; bump counter&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; The quota steps are &amp;quot;INSERT ... ON CONFLICT DO UPDATE ... WHERE n &amp;lt; cap&amp;quot;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Postgres locks the quota row and re-checks the cap against its latest&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; version, so racing requests are serialized and the cap is exact.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; $1 post_id, $2 voter_token, $3 ip_hash, $4 per-post cap, $5 per-IP cap&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Returns one row: status (&amp;#39;voted&amp;#39; | &amp;#39;duplicate&amp;#39; | &amp;#39;capped&amp;#39;) and the count.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; VOTE_SQL&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; `&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;WITH gate AS (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  SELECT EXISTS (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    SELECT 1 FROM article_voters WHERE post_id = $1 AND voter_token = $2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  ) AS dup&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;q_post AS (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  INSERT INTO ip_quota (ip_hash, scope, window_start, n)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  SELECT $3, $1, date_trunc(&amp;#39;hour&amp;#39;, NOW(), &amp;#39;UTC&amp;#39;), 1 FROM gate WHERE NOT gate.dup&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  ON CONFLICT (ip_hash, scope, window_start)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    DO UPDATE SET n = ip_quota.n + 1 WHERE ip_quota.n &amp;lt; $4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  RETURNING 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;q_all AS (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  INSERT INTO ip_quota (ip_hash, scope, window_start, n)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  SELECT $3, &amp;#39;*&amp;#39;, date_trunc(&amp;#39;hour&amp;#39;, NOW(), &amp;#39;UTC&amp;#39;), 1 FROM q_post&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  ON CONFLICT (ip_hash, scope, window_start)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    DO UPDATE SET n = ip_quota.n + 1 WHERE ip_quota.n &amp;lt; $5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  RETURNING 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;ins AS (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  INSERT INTO article_voters (post_id, voter_token)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  SELECT $1, $2 FROM q_all&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  ON CONFLICT (post_id, voter_token) DO NOTHING&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  RETURNING 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;bump AS (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  INSERT INTO article_upvotes (id, count, updated_at)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  SELECT $1, 1, NOW() FROM ins&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  ON CONFLICT (id) DO UPDATE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    SET count = article_upvotes.count + 1, updated_at = NOW()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  RETURNING count&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  CASE&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    WHEN EXISTS (SELECT 1 FROM ins) THEN &amp;#39;voted&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    -- Not inserted: already voted, or both quotas passed but ON CONFLICT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    -- skipped the row (two requests racing on the same token).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    WHEN (SELECT dup FROM gate) OR EXISTS (SELECT 1 FROM q_all) THEN &amp;#39;duplicate&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    ELSE &amp;#39;capped&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  END AS status,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  COALESCE(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    (SELECT count FROM bump),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    (SELECT count FROM article_upvotes WHERE id = $1),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  )::int AS count&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;`&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; $1 post_id, $2 voter_token (&amp;#39;&amp;#39; when unknown). Integers only, no booleans, so&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; the result does not depend on how Neon encodes bool values over HTTP.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; STATE_SQL&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; `&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  COALESCE((SELECT count FROM article_upvotes WHERE id = $1), 0)::int AS count,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  (EXISTS (&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    SELECT 1 FROM article_voters WHERE post_id = $1 AND voter_token = $2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  ))::int AS has_voted&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;`&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; SCRUB_SQL&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; `&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;DELETE FROM ip_quota&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;WHERE window_start &amp;lt; date_trunc(&amp;#39;hour&amp;#39;, NOW(), &amp;#39;UTC&amp;#39;) - INTERVAL &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;${&lt;/span&gt;&lt;span&gt;Math&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;floor&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;LIMITS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.&lt;/span&gt;&lt;span&gt;quotaRetentionHours&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; hours&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;`&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Helpers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; BASE_HEADERS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Content-Type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;application/json; charset=utf-8&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Cache-Control&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;no-store&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;X-Content-Type-Options&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;nosniff&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;body&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 200&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; extraHeaders&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Response&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;JSON&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;stringify&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;body&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    status&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    headers&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ...&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;BASE_HEADERS&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ...&lt;/span&gt;&lt;span&gt;extraHeaders&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Accepts &amp;quot;posts/hello-world&amp;quot;, &amp;quot;/posts/hello-world/&amp;quot; etc. Returns the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; normalized ID or null when invalid.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; normalizePostId&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;raw&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;typeof&lt;/span&gt;&lt;span&gt; raw&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; raw&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;trim&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;replace&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;g&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span&gt; id&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; POST_ID_MAX&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;POST_ID_RE&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;test&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;id&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span&gt; id&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Collapse an IP to the unit we rate-limit on: IPv4 as-is, IPv6 as its /64&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; (a single subscriber normally owns a whole /64, so per-address limits would&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; be trivially bypassed).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; ipKey&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;ip&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;ip&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;unknown&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; ip&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;trim&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;toLowerCase&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; mapped&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;match&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;::ffff:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;\d&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{1,3}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;?:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;\d&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{1,3}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{3}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;mapped&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt; mapped&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;v&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;includes&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; halves&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;split&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;halves&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; left&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; halves&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; halves&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;split&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; right&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; halves&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; halves&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; halves&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;split&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  let&lt;/span&gt;&lt;span&gt; groups&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; left&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;halves&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; missing&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; Math&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;max&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; -&lt;/span&gt;&lt;span&gt; left&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; -&lt;/span&gt;&lt;span&gt; right&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    groups&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;...&lt;/span&gt;&lt;span&gt;left&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ...&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;Array&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;missing&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;fill&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ...&lt;/span&gt;&lt;span&gt;right&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;v6:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;span&gt; groups&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;slice&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 4&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;map&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;g&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; g&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;padStart&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;4&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;join&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; hmacHex&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;secret&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; message&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; enc&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; TextEncoder&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; key&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span&gt; crypto&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;subtle&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;importKey&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;raw&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    enc&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;encode&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;secret&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    {&lt;/span&gt;&lt;span&gt; name&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;HMAC&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; hash&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;SHA-256&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    false&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;sign&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  )&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; sig&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span&gt; crypto&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;subtle&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;sign&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;HMAC&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; key&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; enc&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;encode&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;message&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span&gt; Array&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;from&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Uint8Array&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;sig&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;b&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; b&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;toString&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;16&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;padStart&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;2&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;join&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Keyed hash of the (normalized) client IP. Only used as the ip_quota key and&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; never stored next to a vote. Not reversible without the secret.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; getIpHash&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;request&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; secret&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; cf-connecting-ip is always set by Cloudflare. We deliberately do not fall&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; back to x-forwarded-for, which a client could spoof to dodge the caps.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; ip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; ipKey&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;headers&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;cf-connecting-ip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;await&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; hmacHex&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;secret&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;ip:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;span&gt; ip&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;slice&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 32&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Neon SQL-over-HTTP. Throws on any failure (the caller maps that to a 503).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; neonEndpoint&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;databaseUrl&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; u&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; URL&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;databaseUrl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;replace&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;postgres&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;?:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;ql&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;?&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;https://&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; The HTTP endpoint is served on the direct (non &amp;quot;-pooler&amp;quot;) hostname.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; `&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;https://&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;${&lt;/span&gt;&lt;span&gt;u&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.&lt;/span&gt;&lt;span&gt;hostname&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;-pooler&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/sql&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;`&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; query&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;env&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; sql&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; params&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; res&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; fetch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;neonEndpoint&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;env&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;DATABASE_URL&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    method&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;POST&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    headers&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;      &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Content-Type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;application/json&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;      &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Neon-Connection-String&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; env&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;DATABASE_URL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    body&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; JSON&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;stringify&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; query&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; sql&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; params&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    signal&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; AbortSignal&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;timeout&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;LIMITS&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;dbTimeoutMs&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;res&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ok&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    let&lt;/span&gt;&lt;span&gt; detail&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    try&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      detail&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;await&lt;/span&gt;&lt;span&gt; res&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;message&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; catch&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      /*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; non-JSON error body &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    throw&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Neon HTTP &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;${&lt;/span&gt;&lt;span&gt;res&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.&lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;${&lt;/span&gt;&lt;span&gt;detail&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;span&gt; detail&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;`&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; data&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span&gt; res&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !&lt;/span&gt;&lt;span&gt;Array&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;isArray&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;rows&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; throw&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Unexpected Neon response&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;rows&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Neon may return ints as numbers or as text depending on its output mode.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; toInt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;v&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Number&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;v&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span&gt; Number&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;isFinite&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;n&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; Math&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;trunc&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;n&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Handlers&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---------------------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; handleGet&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;context&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; url&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; env&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; context&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;env&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;DATABASE_URL&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    console&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote: DATABASE_URL is not configured&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Service unavailable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 503&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; postId&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; normalizePostId&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;url&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;searchParams&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;postId&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Valid post ID required&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 400&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; The token is optional on GET; an unknown/invalid one just means hasVoted=false.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; rawToken&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; url&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;searchParams&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;voterToken&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; voterToken&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; VOTER_TOKEN_RE&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;test&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;rawToken&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; rawToken&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  try&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; rows&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; query&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;env&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; STATE_SQL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;postId&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; voterToken&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; row&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; rows&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      id&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; postId&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      count&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; toInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;row&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      hasVoted&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; toInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;row&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;has_voted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; catch&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;err&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    console&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote GET failed:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; err&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;message&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Service unavailable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 503&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;async&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; handlePost&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;context&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; request&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; url&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; env&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; context&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Browsers always send Origin on cross-origin POSTs. Together with the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Content-Type check below (which forces a CORS preflight, and we send no&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; CORS headers) this stops other sites from casting votes through a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; visitor&amp;#39;s browser and burning that visitor&amp;#39;s IP quota.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; origin&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;headers&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;origin&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;origin&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; origin&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !==&lt;/span&gt;&lt;span&gt; url&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;origin&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Forbidden&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 403&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; contentType&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;headers&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;content-type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;toLowerCase&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;contentType&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;startsWith&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;application/json&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Content-Type must be application/json&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 415&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;env&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;DATABASE_URL&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    console&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote: DATABASE_URL is not configured&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Service unavailable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 503&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; secret&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; env&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;UPVOTE_SECRET&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;secret&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span&gt; secret&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 16&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    console&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote: UPVOTE_SECRET is missing or shorter than 16 characters&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Service unavailable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 503&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  let&lt;/span&gt;&lt;span&gt; body&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  try&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; text&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span&gt; request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;text&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;text&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; LIMITS&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;maxBodyBytes&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Payload too large&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 413&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    body&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; JSON&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;parse&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;text&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; catch&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Invalid JSON body&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 400&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;body&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; typeof&lt;/span&gt;&lt;span&gt; body&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;object&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span&gt; Array&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;isArray&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;body&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Invalid JSON body&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 400&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Honeypot: the page pre-fills this field and the client clears it on real&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; user interaction, so a non-empty value means no human interaction.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;body&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;title&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Request rejected&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 400&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; postId&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; normalizePostId&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;body&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;id&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;postId&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Valid post ID required&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 400&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; voterToken&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; typeof&lt;/span&gt;&lt;span&gt; body&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;voterToken&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; body&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;voterToken&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;VOTER_TOKEN_RE&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;test&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;voterToken&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Valid voter token required&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 400&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  try&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; ipHash&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; getIpHash&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;request&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; secret&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; rows&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; await&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; query&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;env&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; VOTE_SQL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      postId&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      voterToken&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      ipHash&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;      LIMITS&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;perPostPerHour&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;      LIMITS&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;perIpPerHour&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; row&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; rows&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;row&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; throw&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Vote statement returned no row&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; String&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;row&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; toInt&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;row&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;voted&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span&gt; status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;duplicate&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;voted&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; Math&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;random&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; LIMITS&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;scrubProbability&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;        //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Best-effort cleanup of expired quota rows (hashed IPs).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; scrub&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; query&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;env&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; SCRUB_SQL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; [&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;catch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;e&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          console&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;warn&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote scrub failed:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; e&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;message&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        )&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;typeof&lt;/span&gt;&lt;span&gt; context&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;waitUntil&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; context&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;waitUntil&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;scrub&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; id&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; postId&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; count&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; hasVoted&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; status&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;capped&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; The quota resets at the top of the next UTC hour.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; retryAfter&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; Math&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;max&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; Math&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;ceil&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;3600000&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; -&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;Date&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;now&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; %&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 3600000&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1000&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;rate_limited&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; count&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 429&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Retry-After&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; String&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;retryAfter&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    throw&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Unexpected vote status: &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;${&lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;`&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; catch&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;err&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    console&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;error&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote POST failed:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; err&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;message&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Service unavailable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 503&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; async&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; onRequest&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;context&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; request&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; context&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; url&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; URL&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;url&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;method&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;GET&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; handleGet&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;context&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; url&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;method&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;POST&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; handlePost&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;context&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; request&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; url&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; error&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Method not allowed&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 405&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; Allow&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;GET, POST&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A few notes on this file:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Status codes.&lt;/strong&gt; &lt;code&gt;200&lt;/code&gt; means voted or already voted, &lt;code&gt;400&lt;/code&gt; invalid input, &lt;code&gt;403&lt;/code&gt; a request from another origin, &lt;code&gt;413&lt;/code&gt; body too large, &lt;code&gt;415&lt;/code&gt; wrong content type, &lt;code&gt;429&lt;/code&gt; hourly cap reached, and &lt;code&gt;503&lt;/code&gt; a database error or missing configuration. The client treats &lt;code&gt;429&lt;/code&gt; and every other non-success as a failed vote.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;One statement, three tables.&lt;/strong&gt; Data-modifying CTEs in Postgres all run within one statement, which is atomic. &lt;code&gt;gate&lt;/code&gt; checks whether this device already voted, &lt;code&gt;q_post&lt;/code&gt; and &lt;code&gt;q_all&lt;/code&gt; take a unit from the two hourly quotas, &lt;code&gt;ins&lt;/code&gt; records the vote only if both quotas allowed it, and &lt;code&gt;bump&lt;/code&gt; increments the aggregate only if &lt;code&gt;ins&lt;/code&gt; actually inserted a row. A repeated vote or a concurrent duplicate inserts nothing and changes nothing, so the count and the voter rows can’t disagree.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Input is validated before it touches SQL.&lt;/strong&gt; All values are bound parameters, the post ID is restricted to a conservative character set (letters, digits, &lt;code&gt;._~-&lt;/code&gt; and up to six &lt;code&gt;/&lt;/code&gt;-separated segments), and the voter token must match its exact format.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Why SQL over HTTP?&lt;/strong&gt; A Worker can’t keep a pooled TCP connection around between requests, and an HTTP call is one round trip with nothing to open or close. It is the transport Neon’s own serverless driver uses in HTTP mode. If you would rather depend on a supported client, use &lt;code&gt;@neondatabase/serverless&lt;/code&gt;; the SQL stays the same. The code strips &lt;code&gt;-pooler&lt;/code&gt; from the host name, which is what worked for me.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The client IP.&lt;/strong&gt; &lt;code&gt;cf-connecting-ip&lt;/code&gt; is the header Cloudflare sets with the visitor’s address. On another host, use whichever header your platform sets itself, and never fall back to one a client can send, because a spoofable header lets people dodge the caps. IPv6 addresses are collapsed to their /64, since one subscriber usually owns a whole /64.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The secret.&lt;/strong&gt; &lt;code&gt;UPVOTE_SECRET&lt;/code&gt; only keys the IP hash. Rotating it resets the current quota counts and nothing else. &lt;code&gt;GET&lt;/code&gt; works without it, while &lt;code&gt;POST&lt;/code&gt; returns &lt;code&gt;503&lt;/code&gt; until it is set to at least 16 characters.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cleanup.&lt;/strong&gt; About 2% of successful votes trigger a best-effort delete of expired &lt;code&gt;ip_quota&lt;/code&gt; rows, run with &lt;code&gt;waitUntil&lt;/code&gt; so it never delays the response. Votes and counts are never deleted.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tuning.&lt;/strong&gt; The caps are constants at the top of the file: 20 votes per IP per post per hour, and 60 per IP across all posts. If a post is shared inside a large office or campus, raise them.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;step-3-the-button&quot;&gt;Step 3: The button&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-3-the-button&quot; aria-label=&quot;Anchor link for: step-3-the-button&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;the-markup&quot;&gt;The markup&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-markup&quot; aria-label=&quot;Anchor link for: the-markup&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This is plain HTML, so it works in any template engine or static page. Only the &lt;code&gt;data-id&lt;/code&gt; and the honeypot value need to come from your template.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;html&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-container&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;form&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-form&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; id&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-form&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; data-id&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;posts/hello-world&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; data-api&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/api/upvote-server&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; onsubmit&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; false&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    &amp;lt;!--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Honeypot: pre-filled with any non-empty text, hidden by CSS, and cleared&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;         by the script on the first real mouse, touch or key event. &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;text&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; name&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; value&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Hello, world&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-honeypot&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; tabindex&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;-1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; autocomplete&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;off&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; aria-hidden&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; id&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-btn&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; aria-label&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Upvote this article&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; data-title&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Upvote this article&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-icon&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;svg&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; width&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; height&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; viewBox&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;0 0 24 24&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; fill&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;none&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; stroke&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;currentColor&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;             stroke-width&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; stroke-linecap&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; stroke-linejoin&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;round&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; aria-hidden&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; d&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;m17 11-5-5-5 5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;/&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;path&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; d&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;m17 18-5-5-5 5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;svg&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;span&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-label&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;Upvote&lt;/span&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;span&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; id&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; aria-live&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;polite&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; data-state&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;loading&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;span&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;button&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    &amp;lt;!--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Screen-reader-only announcements for votes and errors &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; role&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;span&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;form&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;div&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; src&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/js/upvote-client.js&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; defer&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;script&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What each part is for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;data-id&lt;/code&gt;&lt;/strong&gt; is the post’s vote ID, and &lt;strong&gt;&lt;code&gt;data-api&lt;/code&gt;&lt;/strong&gt; is the function’s URL. Both are read by the script.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The honeypot&lt;/strong&gt; is a text field a human never sees. The page ships it pre-filled, the script empties it on the first genuine mouse, touch or key event, and the server rejects any vote that arrives with it still filled. That catches scripts that replay the form without interacting. It is a speed bump, not protection. The field name is arbitrary (here it is called &lt;code&gt;title&lt;/code&gt;), but the markup, the script and the function must all agree on it, so change them together.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;data-state=&quot;loading&quot;&lt;/code&gt;&lt;/strong&gt; on the count starts it invisible, with its space reserved, so there is no flash of a wrong number.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The &lt;code&gt;upvote-label&lt;/code&gt; span&lt;/strong&gt; must stay: the script puts failure messages there for a few seconds.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;data-title&lt;/code&gt; and the &lt;code&gt;.custom-tooltip&lt;/code&gt; lookup&lt;/strong&gt; in the script are hooks for a custom tooltip component. If you use a plain &lt;code&gt;title&lt;/code&gt; attribute or no tooltip, you can delete them.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;the-client-script&quot;&gt;The client script&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-client-script&quot; aria-label=&quot;Anchor link for: the-client-script&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Save this as &lt;code&gt;static/js/upvote-client.js&lt;/code&gt;, or wherever your site serves scripts from.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; static/js/upvote-client.js&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Client-side upvote handler (runs in the reader&amp;#39;s browser).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; - The server is the source of truth. The UI updates optimistically on click&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   and is rolled back if the vote is not confirmed.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; - The count stays hidden until the server has reported it, so a stale &amp;quot;0&amp;quot; is&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   never shown. No optimistic +1 happens while the count is unknown.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; - Errors are shown in the button label for a few seconds (works on touch&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   screens, where tooltips do not) and announced to screen readers via&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   .upvote-status. The button is disabled while the error is showing.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; - The anonymous voter token and the &amp;quot;already upvoted&amp;quot; flag live in&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   localStorage, with an in-memory fallback when storage is unavailable.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; - The honeypot field is pre-filled by the template and cleared on real user&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;//&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   interaction; bots that never interact send it filled and are rejected.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;function&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;  &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;use strict&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; DWELL_MS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1500&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; votes are sent no earlier than this after page load&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; MESSAGE_MS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 3000&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; how long an error shows (the button is disabled meanwhile)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; STATUS_MS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 5000&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; how long the screen-reader message stays in the DOM&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; TOKEN_RE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;vtr_&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;a-f&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0-9&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{32}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; TEXT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    idle&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Upvote this article&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    voted&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;You upvoted this article&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; label: shown inside the button; message: announced to screen readers only&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    limited&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; label&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Try again later&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; message&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Please try again later.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    failed&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; label&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Upvote failed&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; message&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Please try again later.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; localStorage that never throws (Safari private mode, blocked storage, ...).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; store&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; mem&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;key&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        try&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;          const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; v&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; window&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;localStorage&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;getItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;key&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;          if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;v&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt; v&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; catch&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;_&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;          /*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; fall through to memory &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; Object&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;prototype&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;hasOwnProperty&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;call&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;mem&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; key&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; mem&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;key&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      set&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;key&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; value&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        mem&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;key&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; value&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        try&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          window&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;localStorage&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;setItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;key&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; value&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; catch&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;_&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;          /*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; memory fallback only &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      remove&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;key&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        delete&lt;/span&gt;&lt;span&gt; mem&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;key&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        try&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          window&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;localStorage&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;removeItem&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;key&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; catch&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;_&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;          /*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ignore &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; randomHex&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;byteCount&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; bytes&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Uint8Array&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;byteCount&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;window&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;crypto&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; typeof&lt;/span&gt;&lt;span&gt; window&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;crypto&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;getRandomValues&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      window&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;crypto&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;getRandomValues&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;bytes&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; else&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      for&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;let&lt;/span&gt;&lt;span&gt; i&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; i&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;lt;&lt;/span&gt;&lt;span&gt; bytes&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;length&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span&gt; i&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;++&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; bytes&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;i&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; Math&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;floor&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;Math&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;random&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; *&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 256&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span&gt; Array&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;from&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;bytes&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;b&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; b&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;toString&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;16&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;padStart&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;2&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;join&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Persistent anonymous device token: &amp;quot;vtr_&amp;quot; + 32 hex chars (the format the&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;  //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; server validates). Anything stored in an older format is replaced.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; getVoterToken&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    let&lt;/span&gt;&lt;span&gt; token&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; store&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;voter_token&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;token&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;TOKEN_RE&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;test&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;token&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      token&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;vtr_&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; randomHex&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;16&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      store&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;set&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;voter_token&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; token&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span&gt; token&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; initUpvote&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; form&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; document&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;getElementById&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-form&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; btn&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; document&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;getElementById&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-btn&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; countEl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; document&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;getElementById&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;form&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !&lt;/span&gt;&lt;span&gt;btn&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !&lt;/span&gt;&lt;span&gt;countEl&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; postId&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; form&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;dataset&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;id&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; apiUrl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; form&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;dataset&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;api&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;postId&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !&lt;/span&gt;&lt;span&gt;apiUrl&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      console&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;warn&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvote: missing data-id or data-api on #upvote-form&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; labelEl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;querySelector&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.upvote-label&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; statusEl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; form&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;querySelector&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.upvote-status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; idleLabelText&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; labelEl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; labelEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;textContent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; storageKey&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvoted_&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;span&gt; postId&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; honeypot&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; form&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;querySelector&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;input[name=&amp;quot;title&amp;quot;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; voterToken&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; getVoterToken&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; pageLoadTime&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; Date&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;now&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    let&lt;/span&gt;&lt;span&gt; inFlight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; false&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; a vote request is pending&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    let&lt;/span&gt;&lt;span&gt; votedThisSession&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; false&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; the server confirmed a vote in this page view&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    let&lt;/span&gt;&lt;span&gt; currentCount&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; null until the server has told us&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    let&lt;/span&gt;&lt;span&gt; cooldown&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; false&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; an error is showing; the button is disabled&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    let&lt;/span&gt;&lt;span&gt; messageTimer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    let&lt;/span&gt;&lt;span&gt; statusTimer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---- count ------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; data-state drives the CSS: loading (hidden, space reserved), ready,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; unavailable (hidden, no space).&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; renderCount&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;n&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      currentCount&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; n&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      countEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;textContent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; String&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;n&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      countEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;dataset&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;ready&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; markCountUnavailable&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;currentCount&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; countEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;dataset&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;unavailable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    countEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;textContent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    countEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;dataset&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;loading&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---- label / tooltip / screen-reader text ------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Keep the custom tooltip text in sync if it is currently showing.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; syncVisibleTooltip&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;text&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; tooltipEl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; document&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;querySelector&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.custom-tooltip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;tooltipEl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; tooltipEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;classList&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;contains&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;visible&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; tooltipEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;textContent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; text&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; setLabel&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;text&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;setAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;data-title&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; text&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;setAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;aria-label&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; text&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;removeAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      syncVisibleTooltip&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;text&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; setStatus&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;text&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;statusEl&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      clearTimeout&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;statusTimer&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      statusEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;textContent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; text&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      statusTimer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; setTimeout&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        statusEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;textContent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; STATUS_MS&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; setUpvotedState&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;isUpvoted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;isUpvoted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;classList&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;add&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;setAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;aria-pressed&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;setAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;        setLabel&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;TEXT&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;voted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; else&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;classList&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;remove&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;removeAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;aria-pressed&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;cooldown&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;setAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        else&lt;/span&gt;&lt;span&gt; btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;removeAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;        setLabel&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;TEXT&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;idle&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Show an error inside the button for a few seconds and announce it to&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; screen readers. The tooltip is left alone. The button is disabled&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; (aria-disabled keeps keyboard focus) so it cannot be spammed meanwhile.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; showError&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;err&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      clearTimeout&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;messageTimer&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      cooldown&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;setAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;labelEl&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; labelEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;textContent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; err&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;label&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      setStatus&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;err&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;message&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      messageTimer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; setTimeout&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;clearError&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; MESSAGE_MS&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; clearError&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      clearTimeout&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;messageTimer&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      cooldown&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; false&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;labelEl&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; labelEl&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;textContent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; idleLabelText&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;classList&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;contains&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;removeAttribute&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---- honeypot ----------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Cleared only by real user interaction.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; clearHoneypot&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;honeypot&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; honeypot&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;value&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    [&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;mousemove&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;touchstart&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;keydown&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;pointerdown&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;forEach&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;evt&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      window&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;addEventListener&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;evt&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; clearHoneypot&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; once&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; passive&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    )&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Instant UI from the local flag; the server reconciles it below.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;    setUpvotedState&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;store&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;storageKey&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---- initial load ------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Fetch the live count and reconcile with the server. Non-blocking.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; loadState&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; url&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        apiUrl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;        &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;?id=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;        encodeURIComponent&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;postId&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;        &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;amp;voterToken=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;        encodeURIComponent&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;voterToken&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      fetch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;url&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; headers&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; Accept&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;application/json&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;res&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;res&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ok&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; res&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;data&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;          //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; This response may have been computed before the user&amp;#39;s vote. Once a&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;          //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; vote is in flight or confirmed, the POST result owns the UI.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;          if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;inFlight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span&gt; votedThisSession&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;          if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; typeof&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;number&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;            markCountUnavailable&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;          renderCount&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;          if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;hasVoted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            store&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;set&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;storageKey&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;            setUpvotedState&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;true&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; else&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            store&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;remove&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;storageKey&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;            setUpvotedState&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;false&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;catch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;          //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Offline or API unavailable: keep whatever the UI shows.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;          if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;inFlight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !&lt;/span&gt;&lt;span&gt;votedThisSession&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; markCountUnavailable&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;requestIdleCallback&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; in&lt;/span&gt;&lt;span&gt; window&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      window&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;requestIdleCallback&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;loadState&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; timeout&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2000&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; else&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      setTimeout&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;loadState&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; ---- voting ------------------------------------------------------------&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; rollback&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;previousCount&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; data&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      setUpvotedState&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;false&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; typeof&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;number&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; renderCount&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      else&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;previousCount&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; renderCount&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;previousCount&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    function&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; sendVote&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;previousCount&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      fetch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;apiUrl&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        method&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;POST&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        headers&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Content-Type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;application/json&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        body&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; JSON&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;stringify&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          id&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; postId&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          voterToken&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; voterToken&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          title&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; honeypot&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span&gt; honeypot&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;value&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; must be empty&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;res&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          res&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;catch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;data&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; ok&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; res&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;ok&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; status&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; res&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        )&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;then&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; ok&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; status&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; data&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          inFlight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; false&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;          if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;ok&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;hasVoted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;            //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; &amp;#39;voted&amp;#39; or &amp;#39;duplicate&amp;#39; (already voted on this device): either&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;            //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; way the server has the vote. Use its authoritative count.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;typeof&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;number&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; renderCount&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;count&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            votedThisSession&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            store&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;set&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;storageKey&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;            setUpvotedState&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;true&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;            setStatus&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;TEXT&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;voted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;          rollback&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;previousCount&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; data&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;          showError&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 429&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ?&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; TEXT&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;limited&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; :&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; TEXT&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;failed&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;catch&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;          inFlight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; false&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;          rollback&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;previousCount&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;          showError&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;TEXT&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;failed&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;addEventListener&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;click&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;e&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      e&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;preventDefault&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Ignore script-generated clicks (element.click() from a bot). Assistive&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; technology and keyboard activation are trusted events and still work.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;!&lt;/span&gt;&lt;span&gt;e&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;isTrusted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;inFlight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span&gt; cooldown&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ||&lt;/span&gt;&lt;span&gt; btn&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;classList&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;contains&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      clearHoneypot&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;      inFlight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Optimistic update. Only bump the number if we actually know it.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; previousCount&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; currentCount&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      setUpvotedState&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;true&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;previousCount&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; null&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; renderCount&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;previousCount&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Dwell-time bot trap: an early click is not dropped, it is sent once&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      //&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; DWELL_MS has passed since page load.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;      const&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; wait&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; Math&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;max&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; DWELL_MS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; -&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;Date&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;now&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; -&lt;/span&gt;&lt;span&gt; pageLoadTime&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;      setTimeout&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; sendVote&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;previousCount&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; wait&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;  if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;document&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;readyState&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;loading&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    document&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;addEventListener&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;DOMContentLoaded&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; initUpvote&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; once&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; else&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;    initUpvote&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What the script takes care of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Instant first paint, then reconciliation.&lt;/strong&gt; It shows the remembered state immediately, then asks the server and corrects anything that disagrees. Requests are deferred with &lt;code&gt;requestIdleCallback&lt;/code&gt;, so the page never waits on them.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Optimistic voting with rollback.&lt;/strong&gt; The click updates the button at once. If the server doesn’t confirm, the count and button go back and the button shows &lt;code&gt;Try again later&lt;/code&gt; (for a &lt;code&gt;429&lt;/code&gt;) or &lt;code&gt;Upvote failed&lt;/code&gt; for a few seconds, disabled so it can’t be hammered.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No misleading numbers.&lt;/strong&gt; The count is hidden until the server reports it, and a click before that doesn’t invent a “+1”.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stale responses are ignored.&lt;/strong&gt; If the initial &lt;code&gt;GET&lt;/code&gt; arrives after the user has already voted, it can’t overwrite the confirmed result.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Three cheap speed bumps.&lt;/strong&gt; The honeypot field, a 1.5 second minimum between page load and the request (an early click is delayed, not dropped), and a check that the click is a real user event rather than a script calling &lt;code&gt;element.click()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Storage that can fail.&lt;/strong&gt; Private modes and blocked storage fall back to memory instead of breaking the page, and tokens in an unexpected format are replaced.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;the-styles&quot;&gt;The styles&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-styles&quot; aria-label=&quot;Anchor link for: the-styles&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Add this to your stylesheet. The custom properties have fallbacks, so it works as is, and you can map them to your own theme tokens.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;css&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Upvote component &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-container&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; flex&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  justify-content&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; center&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  margin&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2.5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0.5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Without JavaScript the button cannot work, so do not show it. &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;media&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;scripting&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; none&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-container&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; none&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; inline-flex&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  align-items&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; center&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  gap&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0.5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  padding&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0.45&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  font&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; inherit&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  font-weight&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 500&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-text-secondary&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;555&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  background-color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-bg-subtle&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;f5f5f5&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  border&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; solid&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-border&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;d0d0d0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  border-radius&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 999&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  cursor&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; pointer&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  user-select&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; none&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  transition&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; background-color &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0.15&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;s&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; border-color &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0.15&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;s&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; color&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0.15&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;s&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; transform &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0.15&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;s&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Hover styles only on devices that really hover. On touch screens :hover&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   sticks after a tap, which would make a rolled-back vote look upvoted. &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;media&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;hover&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; hover&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;hover&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;not&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;not&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-text&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;111&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    background-color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-accent-subtle&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;e8f0ff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    border-color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-accent&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;3366ff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    transform&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; translateY&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;-1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;focus-visible&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  outline&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; solid&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-accent&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;3366ff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  outline-offset&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-icon&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt; svg&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  width&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 18&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  height&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 18&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; block&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; inline-flex&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  align-items&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; center&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  justify-content&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; center&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  min-width&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1.5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  height&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1.5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  padding&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0.4&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  font-size&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0.75&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;rem&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  font-weight&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 600&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  font-variant-numeric&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; tabular-nums&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-text-secondary&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;555&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  background-color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-border&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;d0d0d0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  border-radius&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 999&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  box-shadow&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; inset&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; transparent&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  transition&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; all&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0.15&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;s&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Count states, set by the script via data-state:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   loading     - the server has not answered yet: invisible, space reserved&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   ready       - show the number&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   unavailable - the count could not be loaded: hide the chip entirely &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;data-state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;loading&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  opacity&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;data-state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;unavailable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; none&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;media&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;hover&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; hover&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;hover&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;not&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;not&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-text&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;111&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    background-color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-bg&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;fff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    box-shadow&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; inset&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1.5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-accent&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;3366ff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-text&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;111&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  background-color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-bg&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;fff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  box-shadow&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; inset&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1.5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-accent&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;3366ff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-text&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;111&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  background-color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-accent-subtle&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;e8f0ff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  border-color&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; var&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;--color-accent&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;3366ff&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  cursor&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; default&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  transform&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; none&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Disabled for a few seconds while an error message is showing. &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;not&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  cursor&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; not-allowed&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Screen-reader-only live region for vote results and errors. &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-status&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  position&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; absolute&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  width&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  height&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  margin&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;px&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  padding&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  overflow&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; hidden&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  clip&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; rect&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  white-space&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; nowrap&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  border&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Honeypot: out of the layout and the accessibility tree. The extra&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   .upvote-form in the selector out-ranks a global .sr-only rule, so no&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;   !important is needed. The script can still read its value. &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-form&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-honeypot&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; none&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Respect reduced-motion preferences. Keep this block last so it wins. &lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;media&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;prefers-reduced-motion&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; reduce&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-count&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    transition&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; none&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  .&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvote-button&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;hover&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;not&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;upvoted&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;not&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;aria-disabled&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;]&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    transform&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; none&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;step-4-wire-it-into-your-site&quot;&gt;Step 4: Wire it into your site&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-4-wire-it-into-your-site&quot; aria-label=&quot;Anchor link for: step-4-wire-it-into-your-site&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The only site-specific part is producing a stable ID for each post and printing it into &lt;code&gt;data-id&lt;/code&gt;, plus rendering the snippet on post pages.&lt;/p&gt;
&lt;h3 id=&quot;choosing-the-post-id&quot;&gt;Choosing the post ID&lt;a class=&quot;zola-anchor&quot; href=&quot;#choosing-the-post-id&quot; aria-label=&quot;Anchor link for: choosing-the-post-id&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The ID can be any string that identifies a post and never changes. The post’s path works well, for example &lt;code&gt;posts/hello-world&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The function strips leading and trailing slashes, so &lt;code&gt;/posts/hello-world/&lt;/code&gt; and &lt;code&gt;posts/hello-world&lt;/code&gt; are the same post.&lt;/li&gt;
&lt;li&gt;Allowed characters are letters, digits, &lt;code&gt;.&lt;/code&gt;, &lt;code&gt;_&lt;/code&gt;, &lt;code&gt;~&lt;/code&gt; and &lt;code&gt;-&lt;/code&gt;, in up to six &lt;code&gt;/&lt;/code&gt;-separated segments that each start with a letter or digit, 200 characters at most. If a slug contains anything else, such as spaces or non-ASCII characters, give that post an explicit ID.&lt;/li&gt;
&lt;li&gt;Most generators expose the path directly. For example: &lt;code&gt;page.path&lt;/code&gt; in Zola, &lt;code&gt;.RelPermalink&lt;/code&gt; in Hugo, &lt;code&gt;page.url&lt;/code&gt; in Jekyll and Eleventy, and &lt;code&gt;Astro.url.pathname&lt;/code&gt; in Astro. Check your generator’s docs for the exact output; what matters is that it stays the same for a given post.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To survive renames, add an optional front-matter field (I call mine &lt;code&gt;uid&lt;/code&gt;) and prefer it when it is set:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;data-id = post.uid, if set; otherwise the post&amp;#39;s path&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you later rename a post’s slug, set &lt;code&gt;uid&lt;/code&gt; to the &lt;strong&gt;old&lt;/strong&gt; ID. Votes are keyed on that string, so they follow the post.&lt;/p&gt;
&lt;h3 id=&quot;where-to-render-it&quot;&gt;Where to render it&lt;a class=&quot;zola-anchor&quot; href=&quot;#where-to-render-it&quot; aria-label=&quot;Anchor link for: where-to-render-it&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Render the snippet only on post pages, after the article body, and load the script with &lt;code&gt;defer&lt;/code&gt; on those same pages. If you want a per-post opt-out, a front-matter flag such as &lt;code&gt;upvote: false&lt;/code&gt; that your template checks before rendering both the snippet and the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag is enough.&lt;/p&gt;
&lt;h2 id=&quot;step-5-configure-and-deploy&quot;&gt;Step 5: Configure and deploy&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-5-configure-and-deploy&quot; aria-label=&quot;Anchor link for: step-5-configure-and-deploy&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Cloudflare dashboard&lt;/strong&gt;, open &lt;strong&gt;Workers &amp;amp; Pages&lt;/strong&gt;, pick your Pages project, then &lt;strong&gt;Settings&lt;/strong&gt; and &lt;strong&gt;Variables and Secrets&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Add two secrets for the Production environment (and Preview, if you use preview deployments):
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;DATABASE_URL&lt;/code&gt;: the Neon connection string from Step 1.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;UPVOTE_SECRET&lt;/code&gt;: a long random string of at least 16 characters, for example the output of &lt;code&gt;openssl rand -hex 32&lt;/code&gt;. It keys the IP hashes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Commit the &lt;code&gt;functions/&lt;/code&gt; directory, the snippet, the script and the styles, and push. Variables are only picked up by a new deployment, so if you added them after the last deploy, trigger a redeploy.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;testing-locally&quot;&gt;Testing locally&lt;a class=&quot;zola-anchor&quot; href=&quot;#testing-locally&quot; aria-label=&quot;Anchor link for: testing-locally&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Static-site dev servers only serve files. They do not run Pages Functions, so on a plain dev server the button will hide its count and roll back any click with “Upvote failed”, which is the fail-visibly path working as intended. To exercise the real API locally, build your site and serve the output directory through Wrangler (&lt;code&gt;public&lt;/code&gt; for Zola and Hugo, &lt;code&gt;_site&lt;/code&gt; for Jekyll and Eleventy, &lt;code&gt;dist&lt;/code&gt; for Astro):&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;npx&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; wrangler&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; pages&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; dev&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Put your two variables in a &lt;code&gt;.dev.vars&lt;/code&gt; file at the repository root and add that file to &lt;code&gt;.gitignore&lt;/code&gt;. Point &lt;code&gt;DATABASE_URL&lt;/code&gt; at a separate Neon branch so test votes never touch your real data:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;DATABASE_URL=&amp;quot;postgresql://USER:PASSWORD@ep-example-123456.us-east-2.aws.neon.tech/neondb?sslmode=require&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;UPVOTE_SECRET=&amp;quot;any-long-random-string-of-16-or-more-characters&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then exercise the endpoint with &lt;code&gt;curl&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Read the state of a post&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;http://localhost:8788/api/upvote-server?id=posts/hello-world&amp;amp;voterToken=vtr_00000000000000000000000000000001&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; =&amp;gt; {&amp;quot;id&amp;quot;:&amp;quot;posts/hello-world&amp;quot;,&amp;quot;count&amp;quot;:0,&amp;quot;hasVoted&amp;quot;:false}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Cast a vote (the honeypot field must be empty)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;X&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; POST&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; http://localhost:8788/api/upvote-server&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;H&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Content-Type: application/json&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;{&amp;quot;id&amp;quot;:&amp;quot;posts/hello-world&amp;quot;,&amp;quot;voterToken&amp;quot;:&amp;quot;vtr_00000000000000000000000000000001&amp;quot;,&amp;quot;title&amp;quot;:&amp;quot;&amp;quot;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; =&amp;gt; {&amp;quot;id&amp;quot;:&amp;quot;posts/hello-world&amp;quot;,&amp;quot;count&amp;quot;:1,&amp;quot;hasVoted&amp;quot;:true,&amp;quot;status&amp;quot;:&amp;quot;voted&amp;quot;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Sending the same &lt;code&gt;POST&lt;/code&gt; again returns &lt;code&gt;&quot;status&quot;:&quot;duplicate&quot;&lt;/code&gt; with the count unchanged, and a different &lt;code&gt;voterToken&lt;/code&gt; counts as a new voter.&lt;/p&gt;
&lt;h2 id=&quot;porting-to-another-platform&quot;&gt;Porting to another platform&lt;a class=&quot;zola-anchor&quot; href=&quot;#porting-to-another-platform&quot; aria-label=&quot;Anchor link for: porting-to-another-platform&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The function uses only web-standard APIs (&lt;code&gt;fetch&lt;/code&gt;, &lt;code&gt;Request&lt;/code&gt;, &lt;code&gt;Response&lt;/code&gt;, &lt;code&gt;crypto.subtle&lt;/code&gt; and &lt;code&gt;AbortSignal.timeout&lt;/code&gt;), so the logic moves anywhere that runs them. Three things are platform-specific:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The entry point.&lt;/strong&gt; The handler is &lt;code&gt;onRequest({ request, env, waitUntil })&lt;/code&gt;, which is the Cloudflare Pages shape. On a plain Cloudflare Worker, wrap it:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;export&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; default&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;  fetch&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;request&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; env&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; ctx&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;)&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    const&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; pathname&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; URL&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;request&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;url&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;pathname&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; !==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/api/upvote-server&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; Response&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Not found&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt; status&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 404&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; onRequest&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;{&lt;/span&gt;&lt;span&gt; request&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; env&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; waitUntil&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; ctx&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;waitUntil&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt;bind&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;ctx&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; }&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;}&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On other platforms, read &lt;code&gt;DATABASE_URL&lt;/code&gt; and &lt;code&gt;UPVOTE_SECRET&lt;/code&gt; from wherever your host exposes environment variables and map its request object onto &lt;code&gt;request&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The client IP header.&lt;/strong&gt; Replace &lt;code&gt;cf-connecting-ip&lt;/code&gt; in &lt;code&gt;getIpHash&lt;/code&gt; with the header your platform sets itself, and make sure a client can’t supply it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Same origin.&lt;/strong&gt; The function checks that &lt;code&gt;Origin&lt;/code&gt; matches its own origin and sends no CORS headers, so the page and the function must live on the same origin. If your API is on a different domain, you will need to add CORS headers and loosen that check deliberately.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The SQL runs on any Postgres 12 or newer. If you aren’t using Neon’s HTTP endpoint, replace the &lt;code&gt;query&lt;/code&gt; helper with your own driver call: the statements take the same positional parameters and return the same single row, and the one-statement design works the same over a pooled connection.&lt;/p&gt;
&lt;h2 id=&quot;operating-it&quot;&gt;Operating it&lt;a class=&quot;zola-anchor&quot; href=&quot;#operating-it&quot; aria-label=&quot;Anchor link for: operating-it&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A few queries I keep handy:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;sql&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Top posts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;SELECT&lt;/span&gt;&lt;span&gt; id, count, updated_at &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;FROM&lt;/span&gt;&lt;span&gt; article_upvotes &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;ORDER BY&lt;/span&gt;&lt;span&gt; count &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; LIMIT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 10&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Drift check (should return no rows)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; u&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;id&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;u&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;count&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;COUNT&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;v.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;*&lt;/span&gt;&lt;span&gt;) &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;AS&lt;/span&gt;&lt;span&gt; voters&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;FROM&lt;/span&gt;&lt;span&gt; article_upvotes u &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;LEFT JOIN&lt;/span&gt;&lt;span&gt; article_voters v &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;ON&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; v&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;post_id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; u&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;id&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; u&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;id&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;u&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; HAVING&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; u&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; &amp;lt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; COUNT&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;v.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;*&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Busiest hours (look for bursts)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;SELECT&lt;/span&gt;&lt;span&gt; post_id, date_trunc(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;hour&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;, created_at) &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; hour&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;COUNT&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;*&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;FROM&lt;/span&gt;&lt;span&gt; article_voters &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;GROUP BY&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ORDER BY&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 3&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; DESC&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; LIMIT&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 10&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;--&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Reset one post, for example after testing&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;DELETE&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; FROM&lt;/span&gt;&lt;span&gt; article_voters &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;WHERE&lt;/span&gt;&lt;span&gt; post_id &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;posts/hello-world&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;UPDATE&lt;/span&gt;&lt;span&gt; article_upvotes &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;SET&lt;/span&gt;&lt;span&gt; count &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;span&gt;, updated_at &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; NOW&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; WHERE&lt;/span&gt;&lt;span&gt; id &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;posts/hello-world&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;limitations-and-hardening&quot;&gt;Limitations and hardening&lt;a class=&quot;zola-anchor&quot; href=&quot;#limitations-and-hardening&quot; aria-label=&quot;Anchor link for: limitations-and-hardening&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is a &lt;em&gt;soft&lt;/em&gt; counter. Be clear-eyed about what it does and doesn’t stop:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;It is not abuse-proof.&lt;/strong&gt; Anyone can clear &lt;code&gt;localStorage&lt;/code&gt; and get a fresh voter token. The hourly caps limit what a single network can do, but they don’t stop someone rotating IP addresses. If that matters, add a rate-limiting rule at your CDN for the endpoint, and put a challenge such as &lt;a rel=&quot;noopener nofollow external&quot; target=&quot;_blank&quot; href=&quot;https://developers.cloudflare.com/turnstile/&quot;&gt;Cloudflare Turnstile&lt;/a&gt; in front of the &lt;code&gt;POST&lt;/code&gt;, verifying its token on the server before any database call. For a personal blog I decided that wasn’t worth the effort yet.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tune the caps for your audience.&lt;/strong&gt; The caps are per network. If a post is shared inside a large office or campus, votes beyond the cap in that hour are refused with the “Try again later” message. Raise &lt;code&gt;perPostPerHour&lt;/code&gt; if you expect that.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arbitrary IDs create rows.&lt;/strong&gt; The function validates the &lt;em&gt;format&lt;/em&gt; of the post ID but not that the post exists, so a script can create rows for IDs that were never real. The all-posts cap bounds how many a single network can create per hour. Checking existence would conflict with explicit IDs, since a pinned ID may no longer match a live URL, so if it ever matters, periodically delete the rows for IDs you don’t recognise from both &lt;code&gt;article_voters&lt;/code&gt; and &lt;code&gt;article_upvotes&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The speed bumps are only speed bumps.&lt;/strong&gt; The honeypot, the minimum delay and the real-click check stop naive scripts. A script driving a real browser passes all three.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Privacy.&lt;/strong&gt; No raw IP address is stored. A keyed hash of it exists only in &lt;code&gt;ip_quota&lt;/code&gt;, for about two hours. The voter token is random and anonymous, but it is a persistent per-browser identifier that sits in your database next to every post that browser voted on, so it is worth a line in your privacy notes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cold starts.&lt;/strong&gt; On Neon’s free tier the database can scale to zero, so the first request after an idle period may take noticeably longer. The deferred, non-blocking script means readers never wait on it, but the count may appear a moment late.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping up&lt;a class=&quot;zola-anchor&quot; href=&quot;#wrapping-up&quot; aria-label=&quot;Anchor link for: wrapping-up&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The whole thing is three tables, one function and one small script, and it fails visibly at every layer. The most useful lessons were the unglamorous ones: identify devices rather than networks, treat the server as the only source of truth about whether someone voted, let the database enforce uniqueness, and keep the aggregate and the voter rows consistent in one statement instead of checking in application code. Put limits on a row that Postgres locks rather than counting rows and hoping requests arrive one at a time. And be honest about the difference between cheap speed bumps and real abuse protection, which includes deleting a feature, like the signed token I started with, when it only looks like security.&lt;/p&gt;
&lt;p&gt;Flush!&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Making Your Zola Website AI-Crawler Ready</title>
        <published>2026-07-31T00:00:00+00:00</published>
        <updated>2026-07-31T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://pankaj.xyz/posts/easily-make-zola-websites-ai-crawler-ready/"/>
        <id>https://pankaj.xyz/posts/easily-make-zola-websites-ai-crawler-ready/</id>
        
        <content type="html" xml:base="https://pankaj.xyz/posts/easily-make-zola-websites-ai-crawler-ready/">&lt;p&gt;AI agents and LLM-powered search tools are increasingly fetching live web content to answer queries. The problem: they work best with clean Markdown, but Zola - like every static site generator - compiles everything into HTML by default. HTML carries navigation chrome, footer noise, and nested tags that models have to fight through.&lt;/p&gt;
&lt;p&gt;This post documents exactly how I made &lt;code&gt;pankaj.xyz&lt;/code&gt; fully AI-crawler ready: an &lt;code&gt;llms.txt&lt;/code&gt; index, an &lt;code&gt;llms-full.txt&lt;/code&gt; full corpus, and raw &lt;code&gt;.md&lt;/code&gt; files served at predictable URLs alongside every HTML page. Every step below reflects the implementation that is live on my site today.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt; A working Zola site, Python 3 available in your build environment, and a &lt;code&gt;build.sh&lt;/code&gt; (or &lt;code&gt;Makefile&lt;/code&gt;) you can extend.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;1-directing-ai-bots-with-html-metadata&quot;&gt;1. Directing AI Bots with HTML Metadata&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-directing-ai-bots-with-html-metadata&quot; aria-label=&quot;Anchor link for: 1-directing-ai-bots-with-html-metadata&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The first thing I did was make every HTML page self-announcing. Any AI agent that lands on a standard page should immediately know where to find the clean, machine-readable version. I added a visually hidden &lt;code&gt;&amp;lt;aside&amp;gt;&lt;/code&gt; to &lt;code&gt;templates/base.html&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;html&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;aside&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; class&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;sr-only&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; data-ai-agent-directive&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    This site is available in Markdown format. Markdown is recommended for AI consumption.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    See &lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; href&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;{{ config.base_url | safe }}llms.txt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;/llms.txt&lt;/span&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;a&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; for the full documentation index,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    or &lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; href&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;{{ config.base_url | safe }}llms-full.txt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt;/llms-full.txt&lt;/span&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;a&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;span&gt; for the full site corpus.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;aside&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;.sr-only&lt;/code&gt; class keeps it invisible to human readers while remaining fully legible to crawlers parsing the document body.&lt;/p&gt;
&lt;h2 id=&quot;2-announcing-ai-assets-via-robots-txt&quot;&gt;2. Announcing AI Assets via robots.txt&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-announcing-ai-assets-via-robots-txt&quot; aria-label=&quot;Anchor link for: 2-announcing-ai-assets-via-robots-txt&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Crawlers check &lt;code&gt;robots.txt&lt;/code&gt; before almost anything else. I added three lines pointing directly at my new Markdown endpoints:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Sitemap: https://pankaj.xyz/sitemap.xml&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;LLMs: https://pankaj.xyz/llms.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;LLMs-full: https://pankaj.xyz/llms-full.txt&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;LLMs&lt;/code&gt; and &lt;code&gt;LLMs-full&lt;/code&gt; are not yet part of the robots.txt spec, but major AI crawlers (GPTBot, ClaudeBot, PerplexityBot) already look for them as de-facto conventions.&lt;/p&gt;
&lt;h2 id=&quot;3-semantic-head-tags-link-alternate-json-ld&quot;&gt;3. Semantic Head Tags (link alternate &amp;amp; JSON-LD)&lt;a class=&quot;zola-anchor&quot; href=&quot;#3-semantic-head-tags-link-alternate-json-ld&quot; aria-label=&quot;Anchor link for: 3-semantic-head-tags-link-alternate-json-ld&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Crawlers rely heavily on &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; metadata - often more than the document body. I made two additions to my templates.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;&amp;lt;link rel=&quot;alternate&quot;&amp;gt;&lt;/code&gt;&lt;/strong&gt; in &lt;code&gt;base.html&lt;/code&gt; declares the Markdown endpoints programmatically:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;html&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; rel&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;alternate&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;text/plain&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; title&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;LLMs Index&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; href&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;{{ config.base_url | safe }}llms.txt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; rel&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;alternate&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;text/plain&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; title&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;LLMs Full Corpus&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; href&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;{{ config.base_url | safe }}llms-full.txt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% if page -%}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; rel&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;alternate&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;text/markdown&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; title&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Markdown Source&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; href&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;{{ page.permalink | safe }}{{ page.slug }}.md&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% endif -%}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;JSON-LD schema&lt;/strong&gt; in &lt;code&gt;page.html&lt;/code&gt; gives AI models rich structured context - title, description, word count, dates, publisher - so they can categorize and index an article before even reading the body. I also wired up dynamic OG image resolution here: if the page defines &lt;code&gt;extra.og_preview_img&lt;/code&gt; it uses that; otherwise it falls back to the auto-generated image path at &lt;code&gt;images/og/&amp;lt;page-path&amp;gt;.png&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;html&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% if page.extra.og_preview_img %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  {% set og_image = page.extra.og_preview_img | trim_start(pat=&amp;quot;/&amp;quot;) %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% else %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  {% set path_trimmed = page.path | trim_end(pat=&amp;quot;/&amp;quot;) %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  {% set og_image = &amp;quot;images/og&amp;quot; ~ path_trimmed ~ &amp;quot;.png&amp;quot; %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% endif %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; type&lt;/span&gt;&lt;span&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;application/ld+json&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;@context&amp;quot;: &amp;quot;https://schema.org&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;@type&amp;quot;: &amp;quot;Article&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;headline&amp;quot;: &amp;quot;{{ page.title }}&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;description&amp;quot;: &amp;quot;{{ page.description | default(value=&amp;#39;&amp;#39;) }}&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;url&amp;quot;: &amp;quot;{{ current_url | safe }}&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;image&amp;quot;: &amp;quot;{{ config.base_url ~ og_image | safe }}&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;inLanguage&amp;quot;: &amp;quot;en&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;author&amp;quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;@type&amp;quot;: &amp;quot;Person&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;name&amp;quot;: &amp;quot;{{ config.title }}&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;url&amp;quot;: &amp;quot;{{ config.base_url | safe }}&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;publisher&amp;quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;@type&amp;quot;: &amp;quot;Person&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;name&amp;quot;: &amp;quot;{{ config.title }}&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    &amp;quot;url&amp;quot;: &amp;quot;{{ config.base_url | safe }}&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;datePublished&amp;quot;: &amp;quot;{{ page.date }}&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;dateModified&amp;quot;: &amp;quot;{% if page.updated %}{{ page.updated }}{% else %}{{ page.date }}{% endif %}&amp;quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  &amp;quot;wordCount&amp;quot;: &amp;quot;{{ page.word_count }}&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;/&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);&quot;&gt;script&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;4-exposing-raw-markdown-pages&quot;&gt;4. Exposing Raw Markdown Pages&lt;a class=&quot;zola-anchor&quot; href=&quot;#4-exposing-raw-markdown-pages&quot; aria-label=&quot;Anchor link for: 4-exposing-raw-markdown-pages&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is the most impactful change. I wrote &lt;code&gt;scripts/copy_md_files.py&lt;/code&gt; to mirror the entire &lt;code&gt;content/&lt;/code&gt; directory into &lt;code&gt;public/&lt;/code&gt; as raw &lt;code&gt;.md&lt;/code&gt; files during the build.&lt;/p&gt;
&lt;p&gt;Zola renders &lt;code&gt;my-post.md&lt;/code&gt; into &lt;code&gt;public/my-post/index.html&lt;/code&gt; so the URL is &lt;code&gt;https://yoursite.com/my-post/&lt;/code&gt;. The script places the original Markdown file at &lt;code&gt;public/my-post/my-post.md&lt;/code&gt;. An AI hitting the HTML page can effortlessly request the &lt;code&gt;.md&lt;/code&gt; sibling at a predictable, consistent URL - no parsing required.&lt;/p&gt;
&lt;p&gt;The script reads and respects the TOML frontmatter: draft pages are skipped, so only published content gets mirrored.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; scripts/copy_md_files.py&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;import&lt;/span&gt;&lt;span&gt; os&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;import&lt;/span&gt;&lt;span&gt; shutil&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;import&lt;/span&gt;&lt;span&gt; re&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;import&lt;/span&gt;&lt;span&gt; sys&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;from&lt;/span&gt;&lt;span&gt; pathlib&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; import&lt;/span&gt;&lt;span&gt; Path&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;try&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    import&lt;/span&gt;&lt;span&gt; tomllib&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;except&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; ModuleNotFoundError&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    import&lt;/span&gt;&lt;span&gt; tomli&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; as&lt;/span&gt;&lt;span&gt; tomllib&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; parse_frontmatter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;content&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; str&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt; -&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; dict&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    match&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; re&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;match&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;^&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;\s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;*?&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);font-weight: bold;&quot;&gt;\+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; content&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; re&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;DOTALL&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; not&lt;/span&gt;&lt;span&gt; match&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        return&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    try&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        return&lt;/span&gt;&lt;span&gt; tomllib&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;loads&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;match&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;group&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    except&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; Exception&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        return&lt;/span&gt;&lt;span&gt; {&lt;/span&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; copy_md_files&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    project_root&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; Path&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;__file__&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parent&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    content_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; project_root&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;content&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    public_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; project_root&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; not&lt;/span&gt;&lt;span&gt; public_dir&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;exists&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;        print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Error: public directory does not exist. Run zola build first.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        sys&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;exit&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    copied&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    for&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; in&lt;/span&gt;&lt;span&gt; content_dir&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;rglob&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;*.md&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        if&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;name&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;_index.md&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            continue&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        content&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;read_text&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;utf-8&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        fm&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; parse_frontmatter&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;content&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;        #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Skip drafts&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        if&lt;/span&gt;&lt;span&gt; fm&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;draft&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; True&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            continue&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        slug&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; fm&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;slug&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; not&lt;/span&gt;&lt;span&gt; slug&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            if&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;name&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;index.md&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                slug&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parent&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            else&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                slug&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;stem&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        rel_path&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;relative_to&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;content_dir&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        if&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;name&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;index.md&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            if&lt;/span&gt;&lt;span&gt; rel_path&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parent&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;name&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ==&lt;/span&gt;&lt;span&gt; slug&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                output_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; public_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span&gt; rel_path&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parent&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            else&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                output_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; public_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span&gt; rel_path&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span&gt; slug&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        else&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            if&lt;/span&gt;&lt;span&gt; rel_path&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ==&lt;/span&gt;&lt;span&gt; Path&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                output_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; public_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span&gt; slug&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;            else&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                output_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; public_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span&gt; rel_path&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;parent&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span&gt; slug&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;                &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        output_path&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; output_dir&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; /&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; f&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{&lt;/span&gt;&lt;span&gt;slug&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;.md&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        output_dir&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;mkdir&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;parents&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;True&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; exist_ok&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;True&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;        #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Read the raw bytes and prepend a UTF-8 BOM if missing.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;        #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; This forces LLM crawlers and browsers to decode the file as UTF-8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;        #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; (fixing corrupted characters like ├──) even without HTTP charset headers.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        raw_bytes&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;read_bytes&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; not&lt;/span&gt;&lt;span&gt; raw_bytes&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;startswith&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\xef&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\xbb&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\xbf&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            raw_bytes&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; b&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\xef&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\xbb&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;\xbf&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +&lt;/span&gt;&lt;span&gt; raw_bytes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;            &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        output_path&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;write_bytes&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;raw_bytes&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        shutil&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;copystat&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;md_file&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt; output_path&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;        print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Copied &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{&lt;/span&gt;&lt;span&gt;md_file&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;relative_to&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;project_root&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; to &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{&lt;/span&gt;&lt;span&gt;output_path&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;relative_to&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;project_root&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        copied&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; +=&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;        &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    print&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Successfully copied &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;{&lt;/span&gt;&lt;span&gt;copied&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; markdown files.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; __name__&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; ==&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;__main__&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    copy_md_files&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;5-creating-the-llms-txt-and-llms-full-txt-indexes&quot;&gt;5. Creating the llms.txt and llms-full.txt Indexes&lt;a class=&quot;zola-anchor&quot; href=&quot;#5-creating-the-llms-txt-and-llms-full-txt-indexes&quot; aria-label=&quot;Anchor link for: 5-creating-the-llms-txt-and-llms-full-txt-indexes&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;/llms.txt&lt;/code&gt; is an emerging convention for websites to provide AI models with a curated index of available content - think &lt;code&gt;sitemap.xml&lt;/code&gt; but designed for LLM consumption rather than search engine crawlers.&lt;/p&gt;
&lt;p&gt;I created two Zola templates that generate these files dynamically from the site’s actual published pages.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;templates/llms.html&lt;/code&gt;&lt;/strong&gt; - the index:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Last updated: {{ now() | date(format=&amp;quot;%Y-%m-%d&amp;quot;) }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# {{ config.title | safe }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{{ config.description | safe }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Full corpus (all pages, one document): {{ config.base_url | safe }}llms-full.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;## Pages&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% for section_name in config.extra.featured_sections %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% set sec = get_section(path=section_name ~ &amp;quot;/_index.md&amp;quot;) %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% for page in sec.pages %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% if page.draft %}{% continue %}{% endif %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;- [{{ page.title }}]({{ page.permalink }}){% if page.description %} - {{ page.description }}{% endif %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% endfor %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% endfor %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;templates/llms-full.html&lt;/code&gt;&lt;/strong&gt; - the full corpus. This one uses a small trick: &lt;code&gt;load_data&lt;/code&gt; fetches the raw file from disk, then &lt;code&gt;split(pat=&quot;+++&quot;)&lt;/code&gt; breaks it on the TOML delimiters. TOML frontmatter is wrapped in two &lt;code&gt;+++&lt;/code&gt; fences, which means splitting on &lt;code&gt;+++&lt;/code&gt; gives three parts: an empty string before the first fence, the frontmatter itself, and the Markdown body. &lt;code&gt;parts[2:]&lt;/code&gt; therefore skips the first two parts and leaves only the body content.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# Last updated: {{ now() | date(format=&amp;quot;%Y-%m-%d&amp;quot;) }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# {{ config.title | safe }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{{ config.description | safe }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Index (summary of all pages): {{ config.base_url | safe }}llms.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% for section_name in config.extra.featured_sections %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% set sec = get_section(path=section_name ~ &amp;quot;/_index.md&amp;quot;) %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% for page in sec.pages %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% if page.draft %}{% continue %}{% endif %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;# {{ page.title }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;Source: {{ page.permalink }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% set raw_content = load_data(path=page.relative_path) %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% set parts = raw_content | split(pat=&amp;quot;+++&amp;quot;) %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% set raw_markdown = parts[2:] | join(sep=&amp;quot;+++&amp;quot;) %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{{ raw_markdown | trim }}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% endfor %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;{% endfor %}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These templates are powered by two simple content files - &lt;code&gt;content/llms/index.md&lt;/code&gt; and &lt;code&gt;content/llms-full/index.md&lt;/code&gt; - that do nothing except point to their respective templates.&lt;/p&gt;
&lt;h2 id=&quot;6-fixing-the-file-extensions-in-the-build-process&quot;&gt;6. Fixing the File Extensions in the Build Process&lt;a class=&quot;zola-anchor&quot; href=&quot;#6-fixing-the-file-extensions-in-the-build-process&quot; aria-label=&quot;Anchor link for: 6-fixing-the-file-extensions-in-the-build-process&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Zola’s output model is folder-per-page: &lt;code&gt;llms.md&lt;/code&gt; becomes &lt;code&gt;public/llms.txt/index.html&lt;/code&gt; (if the slug is &lt;code&gt;llms.txt&lt;/code&gt;). The files need to land at &lt;code&gt;public/llms.txt&lt;/code&gt; and &lt;code&gt;public/llms-full.txt&lt;/code&gt; as plain files, not directories. I handle this in &lt;code&gt;build.sh&lt;/code&gt; post-Zola:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;echo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;gt;&amp;gt;&amp;gt; Fixing AI index filenames...&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; llms.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;mv&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms.txt/index.html&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms_tmp.txt&lt;/span&gt;&lt;span&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    rm&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;rf&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms.txt&lt;/span&gt;&lt;span&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    mv&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms_tmp.txt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; llms-full.txt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;mv&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms-full.txt/index.html&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms-full_tmp.txt&lt;/span&gt;&lt;span&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    rm&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;rf&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms-full.txt&lt;/span&gt;&lt;span&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; \&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    mv&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms-full_tmp.txt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; public/llms-full.txt&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; here is intentional: if the initial &lt;code&gt;mv&lt;/code&gt; fails (e.g., the file was never generated), the script stops rather than running &lt;code&gt;rm -rf&lt;/code&gt; on the directory and silently losing your previous output. I mirrored this logic in the &lt;code&gt;Makefile&lt;/code&gt; target for local development so the local build always matches production.&lt;/p&gt;
&lt;aside class=&quot;admonition note&quot; role=&quot;note&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon info &quot; aria-hidden=&quot;true&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot; /&gt;
  &lt;path d=&quot;M12 16v-4&quot; /&gt;
  &lt;path d=&quot;M12 8h.01&quot; /&gt;&lt;/svg&gt;
 Note&lt;/p&gt;
&lt;p&gt;I use Cloudflare Pages to deploy my website.&lt;/p&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;7-the-final-directory-structure&quot;&gt;7. The Final Directory Structure&lt;a class=&quot;zola-anchor&quot; href=&quot;#7-the-final-directory-structure&quot; aria-label=&quot;Anchor link for: 7-the-final-directory-structure&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;After running the full build pipeline - &lt;code&gt;zola build&lt;/code&gt;, then &lt;code&gt;copy_md_files.py&lt;/code&gt;, then the filename fixups - &lt;code&gt;public/&lt;/code&gt; looks like this:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;public/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;├── index.html               ← Standard Zola homepage&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;├── sitemap.xml              ← Standard Zola sitemap&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;├── robots.txt               ← Updated with LLMs/LLMs-full entries&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;├── llms.txt                 ← AI index (renamed from directory by build.sh)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;├── llms-full.txt            ← AI corpus (renamed from directory by build.sh)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;└── my-post/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    ├── index.html           ← Standard Zola HTML post&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    └── my-post.md           ← Raw Markdown injected by copy_md_files.py&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Each post directory ends up with both representations side by side. The HTML page announces the Markdown sibling via &lt;code&gt;&amp;lt;link rel=&quot;alternate&quot;&amp;gt;&lt;/code&gt; in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;, so any crawler that inspects head tags can find the clean version immediately.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;a class=&quot;zola-anchor&quot; href=&quot;#conclusion&quot; aria-label=&quot;Anchor link for: conclusion&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Most static sites are technically accessible to AI crawlers but practically difficult to parse. Noisy HTML, missing structured metadata, and no predictable Markdown endpoint all create friction that degrades the quality of AI-generated answers citing your content.&lt;/p&gt;
&lt;p&gt;With these seven changes - an HTML directive, an updated &lt;code&gt;robots.txt&lt;/code&gt;, semantic head tags, Markdown mirroring, dynamically generated &lt;code&gt;llms.txt&lt;/code&gt; and &lt;code&gt;llms-full.txt&lt;/code&gt;, and build-time fixups - the site now speaks the language AI agents actually prefer. The implementation adds no runtime overhead (everything is generated at build time) and degrades gracefully: every change is purely additive and leaves the human-facing site untouched.&lt;/p&gt;
&lt;p&gt;Flush!&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Syncing a Repo with Its Upstream Template, Without Losing Content</title>
        <published>2026-07-26T00:00:00+00:00</published>
        <updated>2026-07-26T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://pankaj.xyz/rtd/syncing-a-repo-with-its-upstream-template/"/>
        <id>https://pankaj.xyz/rtd/syncing-a-repo-with-its-upstream-template/</id>
        
        <content type="html" xml:base="https://pankaj.xyz/rtd/syncing-a-repo-with-its-upstream-template/">&lt;h2 id=&quot;background&quot;&gt;Background&lt;a class=&quot;zola-anchor&quot; href=&quot;#background&quot; aria-label=&quot;Anchor link for: background&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you build a project on top of an open-source template or boilerplate repo, you eventually hit a fork-management problem: how do you keep pulling in upstream improvements without your own content, config, or custom code getting clobbered every time you merge?&lt;/p&gt;
&lt;p&gt;Here’s the setup I landed on. It uses a second Git remote pointed at the upstream repo, plus a custom merge driver that tells Git to always keep “our” version of specific files and folders. Once it’s wired up, pulling updates becomes a two-command routine.&lt;/p&gt;
&lt;aside class=&quot;admonition note&quot; role=&quot;note&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon info &quot; aria-hidden=&quot;true&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot; /&gt;
  &lt;path d=&quot;M12 16v-4&quot; /&gt;
  &lt;path d=&quot;M12 8h.01&quot; /&gt;&lt;/svg&gt;
 Note&lt;/p&gt;
&lt;p&gt;I’m using a website/theme as the running example below since that’s the situation I was in, but nothing here is specific to websites. This works for any repo that needs to keep tracking an external template, boilerplate, or starter-kit repo - a backend service scaffolded from a starter template, a config repo based on a shared base, and so on. Swap in whatever names make sense for your project; &lt;code&gt;template&lt;/code&gt; is just the remote name I chose, not a requirement.&lt;/p&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;why-not-just-fork-the-upstream-repo&quot;&gt;Why Not Just Fork the Upstream Repo?&lt;a class=&quot;zola-anchor&quot; href=&quot;#why-not-just-fork-the-upstream-repo&quot; aria-label=&quot;Anchor link for: why-not-just-fork-the-upstream-repo&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The usual advice for this kind of setup is: fork the upstream repo, then build your project inside the fork. That way, your repo &lt;em&gt;is&lt;/em&gt; a fork, and pulling upstream changes is just a routine “sync fork” operation.&lt;/p&gt;
&lt;p&gt;That advice assumes you’re starting fresh. I wasn’t. My repo was already live, with its own commit history going back years, long before I decided to move it onto an open-source template published on GitHub. There was no clean way to retroactively turn an existing, live repo into a fork of a repo that didn’t exist yet when mine was created - and I wasn’t willing to throw away my history just to get a tidier Git relationship.&lt;/p&gt;
&lt;p&gt;So instead of forking, I linked the histories after the fact: added the upstream repo as a second remote on my existing repo, did the initial merge, and set up &lt;code&gt;.gitattributes&lt;/code&gt; with a custom merge driver so my content wouldn’t get overwritten by the upstream repo’s own files going forward. If you’re in the same boat - an existing repo that you want to start tracking an external template from, without recreating it as a fork - this is the pattern that worked for me.&lt;/p&gt;
&lt;h2 id=&quot;initial-setup-one-time&quot;&gt;Initial Setup (One-Time)&lt;a class=&quot;zola-anchor&quot; href=&quot;#initial-setup-one-time&quot; aria-label=&quot;Anchor link for: initial-setup-one-time&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This part only needs to happen once, on the repo itself, and it’s what makes everything else possible.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add a &lt;code&gt;.gitattributes&lt;/code&gt; file&lt;/strong&gt; at the root of your repo that marks the paths you want protected with the &lt;code&gt;merge=ours&lt;/code&gt; strategy - for example:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;plain&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;content/** merge=ours&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;static/images/** merge=ours&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;config.toml merge=ours&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Adjust the paths to match your own project’s layout.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Register the custom merge driver locally&lt;/strong&gt; so Git knows how to apply the rule:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; merge.ours.driver&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Commit and push &lt;code&gt;.gitattributes&lt;/code&gt;:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; add&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; .gitattributes&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; commit&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;m&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Add merge=ours rules to protect personal content during template sync&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; push&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Once &lt;code&gt;.gitattributes&lt;/code&gt; is committed and pushed, it’s a permanent part of your repo’s history - it travels with every future clone. You won’t need to do this step again, even on a fresh machine. What &lt;em&gt;doesn’t&lt;/em&gt; travel automatically is the remote pointing to the upstream repo, and the local merge driver registration - that’s the part covered next.&lt;/p&gt;
&lt;h2 id=&quot;setting-this-up-on-a-new-machine-or-fresh-clone&quot;&gt;Setting This Up on a New Machine (or Fresh Clone)&lt;a class=&quot;zola-anchor&quot; href=&quot;#setting-this-up-on-a-new-machine-or-fresh-clone&quot; aria-label=&quot;Anchor link for: setting-this-up-on-a-new-machine-or-fresh-clone&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Git remotes and local Git config don’t travel with a repo - only tracked files like &lt;code&gt;.gitattributes&lt;/code&gt; do. So on a new clone, you need to re-run two commands:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Add the upstream repo as a remote:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; remote&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; add&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; template&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; https://github.com/your-username/your-upstream-repo.git&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Name it whatever makes sense to you - &lt;code&gt;template&lt;/code&gt;, &lt;code&gt;upstream&lt;/code&gt;, &lt;code&gt;theme&lt;/code&gt;, etc. Just stay consistent with whatever name you use in the commands below.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Register the custom merge driver:&lt;/strong&gt;
This tells Git how to honor the &lt;code&gt;merge=ours&lt;/code&gt; rule defined in &lt;code&gt;.gitattributes&lt;/code&gt;, so your own content is protected whenever you merge in upstream changes.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; config&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; merge.ours.driver&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; true&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;ongoing-sync-pulling-updates-from-upstream&quot;&gt;Ongoing Sync: Pulling Updates from Upstream&lt;a class=&quot;zola-anchor&quot; href=&quot;#ongoing-sync-pulling-updates-from-upstream&quot; aria-label=&quot;Anchor link for: ongoing-sync-pulling-updates-from-upstream&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Once the remote and merge driver are set up, syncing is just two steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fetch the latest upstream changes:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; fetch&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; template&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Merge the updates:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;git&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; merge&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; template/master&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(Use whatever the upstream repo’s default branch is called - &lt;code&gt;main&lt;/code&gt;, &lt;code&gt;master&lt;/code&gt;, etc.)&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The &lt;code&gt;.gitattributes&lt;/code&gt; rules do the heavy lifting here - they automatically prevent your own folders and files (in my case, things like &lt;code&gt;content/&lt;/code&gt;, &lt;code&gt;static/images/&lt;/code&gt;, and &lt;code&gt;config.toml&lt;/code&gt;) from being overwritten during the merge. If you want to exclude (or stop excluding) other files or folders from future syncs, just edit &lt;code&gt;.gitattributes&lt;/code&gt; to match your own project’s layout.&lt;/p&gt;
&lt;p&gt;That’s it - no manual cherry-picking, no diffing upstream changes by hand. The merge driver keeps your content safe by default, and you opt files in or out as your setup evolves.&lt;/p&gt;
&lt;p&gt;Flush!&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Sad state of affairs for India&#39;s IT Services Industry</title>
        <published>2026-07-20T00:00:00+00:00</published>
        <updated>2026-07-20T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://pankaj.xyz/posts/sad-state-of-affairs-for-indias-it-services-industry/"/>
        <id>https://pankaj.xyz/posts/sad-state-of-affairs-for-indias-it-services-industry/</id>
        
        <content type="html" xml:base="https://pankaj.xyz/posts/sad-state-of-affairs-for-indias-it-services-industry/">&lt;h2 id=&quot;how-the-it-service-sector-found-the-perfect-excuse-in-ai&quot;&gt;How the IT service sector found the perfect excuse in AI&lt;a class=&quot;zola-anchor&quot; href=&quot;#how-the-it-service-sector-found-the-perfect-excuse-in-ai&quot; aria-label=&quot;Anchor link for: how-the-it-service-sector-found-the-perfect-excuse-in-ai&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Ten years in this industry - across product companies where engineering was treated like a craft, and service companies where it was treated like inventory - has taught me one uncomfortable truth: most IT service organizations never saw developers as developers. We were &lt;code&gt;resources&lt;/code&gt;, billable, fungible, disposable resources.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;AI didn’t create this mindset. It just gave management a new vocabulary to justify it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;the-resource-economy&quot;&gt;The Resource Economy&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-resource-economy&quot; aria-label=&quot;Anchor link for: the-resource-economy&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In a resource economy, nobody asks if the work is good. They ask if the work is &lt;em&gt;fast enough&lt;/em&gt; and &lt;em&gt;cheap enough&lt;/em&gt;. &lt;code&gt;Deliver more in less time&lt;/code&gt; has been the unofficial company motto since long before anyone in the C-suite could spell &lt;code&gt;LLM&lt;/code&gt;. Sprints got shorter, scope got bigger, and the gap between the two was always filled by the same thing: a developer’s personal time, and eventually, their patience for the job itself.&lt;/p&gt;
&lt;p&gt;Management, meanwhile, has rarely led - it has &lt;em&gt;followed&lt;/em&gt;. Whatever term was trending at the last conference became the theme of the next town hall, regardless of whether it fit the actual problem in front of the team. Agile, then hyper-agile, then “we’re basically a startup now,” then digital transformation, then cloud-native everything - &lt;code&gt;a parade of buzzwords&lt;/code&gt;, each one arriving at the direct expense of a developer’s time, respect, and sanity. Client happiness was the only KPI that ever mattered. Developer wellbeing was a line item nobody wanted to own.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;AI is simply the newest costume on the same old mannequin.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;anyone-can-code-said-no-one-who-actually-codes&quot;&gt;“Anyone Can Code” - Said No One Who Actually Codes&lt;a class=&quot;zola-anchor&quot; href=&quot;#anyone-can-code-said-no-one-who-actually-codes&quot; aria-label=&quot;Anchor link for: anyone-can-code-said-no-one-who-actually-codes&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The most tiresome line to come out of this AI moment is the confident, faux-progressive declaration from leadership: &lt;em&gt;“Anyone can code now. You don’t even need to be technical.”&lt;/em&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It’s a convenient thing to say - &lt;code&gt;if you&#39;re not the one being asked to prove it&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If coding were truly that trivial, &lt;strong&gt;HR wouldn’t need developers to build the HR portal&lt;/strong&gt;. &lt;strong&gt;Finance wouldn’t need engineers to fix the billing script&lt;/strong&gt;. The same leadership team repeating this line in every all-hands doesn’t even &lt;strong&gt;try&lt;/strong&gt; to open a code editor themselves. The claim isn’t a technical observation - &lt;em&gt;it’s a rhetorical tool&lt;/em&gt;. Once an organization declares that &lt;code&gt;anyone can code&lt;/code&gt;, it has quietly given itself &lt;code&gt;permission&lt;/code&gt; to stop valuing the people who do. Your work stops being &lt;strong&gt;engineering&lt;/strong&gt; and starts being just another checkbox, because &lt;em&gt;if anyone could’ve done it, then what you delivered was never special to begin with&lt;/em&gt;. That’s not a technology shift. That’s a designed insult.&lt;/p&gt;
&lt;h2 id=&quot;the-ai-town-hall-problem&quot;&gt;The AI Town Hall Problem&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-ai-town-hall-problem&quot; aria-label=&quot;Anchor link for: the-ai-town-hall-problem&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Every town hall now opens with &lt;code&gt;&quot;AI&quot;&lt;/code&gt; and closes with &lt;code&gt;&quot;AI.&quot;&lt;/code&gt; Every tagline has been rewritten to squeeze the word in somewhere, whether or not it changes anything about &lt;em&gt;how the company actually operates&lt;/em&gt;. Cough or sneeze and someone will find a way to relabel it as an &lt;code&gt;&quot;AI-powered initiative.&quot;&lt;/code&gt; This isn’t strategy. It’s &lt;strong&gt;optics&lt;/strong&gt; - a company trying to look relevant to clients and investors, using its own engineering workforce as the backdrop for a slide nobody in leadership actually understands.&lt;/p&gt;
&lt;p&gt;And the cost of that optics campaign always lands on the same desk: the developer’s.&lt;/p&gt;
&lt;h2 id=&quot;harder-growth-sold-as-progress&quot;&gt;Harder Growth, Sold as Progress&lt;a class=&quot;zola-anchor&quot; href=&quot;#harder-growth-sold-as-progress&quot; aria-label=&quot;Anchor link for: harder-growth-sold-as-progress&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Here’s where it stops being annoying and starts being damaging: under the banner of AI, performance bars are quietly being raised while timelines are being cut. The logic, as it’s been explained in more than one review cycle, is simple - &lt;em&gt;“AI makes you faster, so you should be delivering more. And besides, apparently anyone can code now, so the bar for ‘exceptional’ just went up.”&lt;/em&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;It’s a closed loop that management built for itself: &lt;strong&gt;first devalue the skill publicly, then use that devaluation to justify tougher promotion criteria and thinner growth paths&lt;/strong&gt;. Both moves cost the company nothing. Both moves cost the developer everything.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;elephant-in-the-room&quot;&gt;Elephant in the room&lt;a class=&quot;zola-anchor&quot; href=&quot;#elephant-in-the-room&quot; aria-label=&quot;Anchor link for: elephant-in-the-room&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;AI is not here to turn developers into people who are simply good at writing polite English prompts, no matter how badly the AI industry wants to sell that story. And they &lt;em&gt;do&lt;/em&gt; want to sell it - every AI company right now has a vested interest in convincing the market that software development as we know it is over, that agents and prompts and loops are the entire future, that &lt;code&gt;SDLC&lt;/code&gt; is a relic. It’s a good pitch if you’re trying to be indispensable for the next decade. Companies chasing every sector at once, launching a new &lt;strong&gt;AI for this and that&lt;/strong&gt; product every week, aren’t doing that because the technology or the market demands it - they’re doing it so that when the hype eventually cools and settles down, they’re not left irrelevant in a single market they never diversified out of.&lt;/p&gt;
&lt;h2 id=&quot;my-actual-take-on-ai&quot;&gt;My Actual Take on AI&lt;a class=&quot;zola-anchor&quot; href=&quot;#my-actual-take-on-ai&quot; aria-label=&quot;Anchor link for: my-actual-take-on-ai&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Here’s where I’ll push back on the doom, because I don’t think AI is the villain here - I think it’s being &lt;em&gt;used&lt;/em&gt; as one.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When calculators arrived, they didn’t replace accountants. They became a wingman - something that removed the tedious arithmetic so the accountant could focus on judgment, on advising, on the parts of the job that actually required a human. Nobody declared &lt;em&gt;“anyone can do accounting now”&lt;/em&gt; just because a calculator could add numbers.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So no - coding isn’t over, and neither is &lt;code&gt;SDLC&lt;/code&gt;. A prompt doesn’t understand your business logic. It doesn’t know your users, your edge cases, your compliance constraints, or the five-year-old architectural decision that’s still quietly load-bearing. Someone who wasn’t a strong developer before AI won’t magically become one now, and someone who genuinely couldn’t code before still can’t, just with better autocomplete. What AI actually demands is more human judgment, not less - a human in the loop who understands &lt;em&gt;why&lt;/em&gt;, not just &lt;em&gt;what&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The tragedy is that &lt;em&gt;service-based companies were never built to value that kind of human&lt;/em&gt;. They were built to value throughput. And if this AI bet doesn’t pay off the way leadership is promising the clients, the response won’t be introspection - &lt;strong&gt;it’ll be a new hiring post&lt;/strong&gt;, replacing the very team that was told it was replaceable, without so much as a pause.&lt;/p&gt;
&lt;p&gt;We were never &lt;code&gt;developers&lt;/code&gt; to this system. We were always just &lt;code&gt;resources&lt;/code&gt;. AI didn’t change that. It just gave them a more fashionable word for it.&lt;/p&gt;
&lt;p&gt;Flush!&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Setting Up a Highly Available Pi-hole DNS Cluster with Keepalived</title>
        <published>2026-07-01T00:00:00+00:00</published>
        <updated>2026-07-10T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://pankaj.xyz/posts/highly-available-pi-hole-dns-cluster-with-keepalived/"/>
        <id>https://pankaj.xyz/posts/highly-available-pi-hole-dns-cluster-with-keepalived/</id>
        
        <content type="html" xml:base="https://pankaj.xyz/posts/highly-available-pi-hole-dns-cluster-with-keepalived/">&lt;h2 id=&quot;background&quot;&gt;Background&lt;a class=&quot;zola-anchor&quot; href=&quot;#background&quot; aria-label=&quot;Anchor link for: background&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;If you’re running Pi-hole as the DNS resolver for your home network, you’ve probably run into the obvious single point of failure: when that one Raspberry Pi goes down for an update, a reboot, or an SD card failure, every device on your network loses DNS resolution. No DNS, no internet - even devices that don’t rely on Pi-hole for ad-blocking still need it to resolve hostnames.&lt;/p&gt;
&lt;p&gt;The fix is to run two Pi-hole nodes in an &lt;strong&gt;active-active high-availability cluster&lt;/strong&gt;, using &lt;strong&gt;keepalived&lt;/strong&gt; and the VRRP protocol to manage automatic failover between them. This post walks through exactly how to set that up.&lt;/p&gt;
&lt;aside class=&quot;admonition note&quot; role=&quot;note&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon info &quot; aria-hidden=&quot;true&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot; /&gt;
  &lt;path d=&quot;M12 16v-4&quot; /&gt;
  &lt;path d=&quot;M12 8h.01&quot; /&gt;&lt;/svg&gt;
 Note&lt;/p&gt;
&lt;p&gt;None of this is Raspberry Pi-specific. Any pair of machines running a Debian-based OS works - old laptops, mini PCs, VMs, whatever you have lying around. I have used a pair of Raspberry Pi 4Bs (1GB RAM) running DietPi OS, but the steps translate directly to any Debian/Ubuntu-based setup.&lt;/p&gt;
&lt;/aside&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;the-core-idea&quot;&gt;The Core Idea&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-core-idea&quot; aria-label=&quot;Anchor link for: the-core-idea&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Instead of pointing your router at a single Pi-hole IP, you create two &lt;strong&gt;Virtual IPs (VIPs)&lt;/strong&gt; - floating addresses that keepalived moves between nodes automatically. Each node is the preferred owner (“master”) of one VIP and acts as the backup for the other. That gives you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Active-active load distribution&lt;/strong&gt; - both nodes handle real traffic under normal conditions, since your router’s primary and secondary DNS point at different VIPs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Automatic failover&lt;/strong&gt; - if one node’s Pi-hole service (or the node itself) goes down, its peer detects the failure and takes over both VIPs within seconds.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No manual intervention&lt;/strong&gt; - VRRP handles election and failback automatically, including a configurable delay before a recovered node reclaims its VIP, avoiding flapping.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;example-network-layout&quot;&gt;Example Network Layout&lt;a class=&quot;zola-anchor&quot; href=&quot;#example-network-layout&quot; aria-label=&quot;Anchor link for: example-network-layout&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Role&lt;/th&gt;&lt;th&gt;Hostname&lt;/th&gt;&lt;th&gt;Static IP&lt;/th&gt;&lt;th&gt;Owns VIP (Master)&lt;/th&gt;&lt;th&gt;Backs Up VIP&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Node 1&lt;/td&gt;&lt;td&gt;&lt;code&gt;dns1&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;192.168.0.10&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;192.168.0.12&lt;/code&gt; (VIP1)&lt;/td&gt;&lt;td&gt;&lt;code&gt;192.168.0.13&lt;/code&gt; (VIP2)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Node 2&lt;/td&gt;&lt;td&gt;&lt;code&gt;dns2&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;192.168.0.11&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;192.168.0.13&lt;/code&gt; (VIP2)&lt;/td&gt;&lt;td&gt;&lt;code&gt;192.168.0.12&lt;/code&gt; (VIP1)&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;On your router, set:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Primary DNS&lt;/strong&gt; → &lt;code&gt;192.168.0.12&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Secondary DNS&lt;/strong&gt; → &lt;code&gt;192.168.0.13&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both VIPs are always reachable - they just live on whichever node currently holds them.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;a class=&quot;zola-anchor&quot; href=&quot;#prerequisites&quot; aria-label=&quot;Anchor link for: prerequisites&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Two machines running a Debian-based OS (Raspberry Pi, mini PC, VM - anything works), each with a static IP reserved on your router&lt;/li&gt;
&lt;li&gt;Pi-hole installed and configured identically on both nodes (blocklists, upstream DNS, etc. - use Pi-hole’s Teleporter export/import to keep them in sync)&lt;/li&gt;
&lt;li&gt;Root/sudo access on both nodes&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;step-1-create-a-health-check-dns-record&quot;&gt;Step 1: Create a Health-Check DNS Record&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-1-create-a-health-check-dns-record&quot; aria-label=&quot;Anchor link for: step-1-create-a-health-check-dns-record&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Keepalived needs a reliable way to verify that DNS resolution is actually &lt;em&gt;working&lt;/em&gt; on a node - not just that the &lt;code&gt;pihole-FTL&lt;/code&gt; process is running. The cleanest way to do this is to create a local DNS record that keepalived can query on every health check.&lt;/p&gt;
&lt;p&gt;In the Pi-hole web UI, go to &lt;strong&gt;Settings → Local DNS → DNS Records&lt;/strong&gt; and add:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Domain&lt;/th&gt;&lt;th&gt;IP Address&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;dns-probe.internal&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;code&gt;127.0.0.1&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;Repeat this on &lt;strong&gt;both nodes&lt;/strong&gt;. Keepalived’s health check script will query this record locally; if it stops resolving, the node’s VRRP priority drops and its peer takes over.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;.internal&lt;/code&gt; is an IANA-reserved TLD for private use, making it a safe choice for local-only records that should never leak upstream.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;step-2-install-keepalived&quot;&gt;Step 2: Install Keepalived&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-2-install-keepalived&quot; aria-label=&quot;Anchor link for: step-2-install-keepalived&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Run this on &lt;strong&gt;both nodes&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; apt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; install&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; keepalived&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; useradd&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;r&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;s&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; /sbin/nologin&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; keepalived_script&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The dedicated &lt;code&gt;keepalived_script&lt;/code&gt; user is used to run health-check scripts with reduced privileges, per keepalived’s script-security model.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;step-3-configure-each-node&quot;&gt;Step 3: Configure Each Node&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-3-configure-each-node&quot; aria-label=&quot;Anchor link for: step-3-configure-each-node&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Each node runs &lt;strong&gt;two VRRP instances&lt;/strong&gt; - one where it’s the preferred master, and one where it’s a pure backup. This is what creates the active-active effect: both VIPs are “live” somewhere on the network at all times, and each node is actively serving one of them.&lt;/p&gt;
&lt;aside class=&quot;admonition important&quot; role=&quot;note&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon alert-circle &quot; aria-hidden=&quot;true&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot; /&gt;
  &lt;line x1=&quot;12&quot; x2=&quot;12&quot; y1=&quot;8&quot; y2=&quot;12&quot; /&gt;
  &lt;line x1=&quot;12&quot; x2=&quot;12.01&quot; y1=&quot;16&quot; y2=&quot;16&quot; /&gt;&lt;/svg&gt;
 Important&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Change the &lt;code&gt;auth_pass&lt;/code&gt; value&lt;/strong&gt; on both configs mentioned below to a unique shared secret before deploying. You can generate one with &lt;code&gt;openssl rand -base64 6&lt;/code&gt;.&lt;/p&gt;
&lt;/aside&gt;
&lt;h3 id=&quot;node-1&quot;&gt;Node 1&lt;a class=&quot;zola-anchor&quot; href=&quot;#node-1&quot; aria-label=&quot;Anchor link for: node-1&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;/etc/keepalived/keepalived.conf&lt;/code&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;global_defs&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    router_id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; DNS1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    enable_script_security&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    max_auto_priority&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    script_user&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; keepalived_script&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Health check: verify pihole-FTL is running AND DNS resolves&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;vrrp_script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; chk_dns&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/bin/sh -c &amp;#39;/usr/bin/pgrep pihole-FTL &amp;gt; /dev/null &amp;amp;&amp;amp; /usr/bin/dig -4 +short +tries=1 +timeout=2 dns-probe.internal @127.0.0.1 | grep -q .&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    interval&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 5&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;     #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Run check every 5 seconds&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    timeout&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 4&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Fail if check takes longer than 4 seconds&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    weight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;20&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;    #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Subtract 20 from priority on failure&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    fall&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Require 2 consecutive failures before marking DOWN&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    rise&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;      #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Require 2 consecutive successes before marking UP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; VIP1 - preferred owner, reclaims after 60s on recovery&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;vrrp_instance&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; DNS_VIP1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;               BACKUP&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;        #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Must be BACKUP for preempt_delay to work&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    interface&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;           eth0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    virtual_router_id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;   51&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    priority&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;            100&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;           #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Higher priority = wins master election&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    advert_int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;          1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    preempt_delay&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;       60&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;            #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Wait 60s after boot before asserting MASTER&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    unicast_src_ip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  192.168.0.10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    unicast_peer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        192.168.0.11&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;                  #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Send VRRP packets directly (avoids multicast issues)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    authentication&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        auth_type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; PASS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        auth_pass&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; CHANGE_ME&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    virtual_ipaddress&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        192.168.0.12/24&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    track_script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        chk_dns&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; VIP2 - true backup, never preempts the other node&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;vrrp_instance&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; DNS_VIP2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;               BACKUP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    interface&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;           eth0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    virtual_router_id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;   52&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    priority&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;            90&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    advert_int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;          1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    nopreempt&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;                         #&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Never reclaim - the peer is the preferred owner of VIP2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    unicast_src_ip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  192.168.0.10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    unicast_peer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        192.168.0.11&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    authentication&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        auth_type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; PASS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        auth_pass&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; CHANGE_ME&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    virtual_ipaddress&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        192.168.0.13/24&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    track_script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        chk_dns&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;node-2&quot;&gt;Node 2&lt;a class=&quot;zola-anchor&quot; href=&quot;#node-2&quot; aria-label=&quot;Anchor link for: node-2&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;/etc/keepalived/keepalived.conf&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Node 2’s config is a mirror image: it’s the preferred owner of VIP2 and the backup for VIP1.&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;global_defs&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    router_id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; DNS2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    enable_script_security&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    max_auto_priority&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    script_user&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; keepalived_script&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;vrrp_script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; chk_dns&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/bin/sh -c &amp;#39;/usr/bin/pgrep pihole-FTL &amp;gt; /dev/null &amp;amp;&amp;amp; /usr/bin/dig -4 +short +tries=1 +timeout=2 dns-probe.internal @127.0.0.1 | grep -q .&amp;#39;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    interval&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 5&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    timeout&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; 4&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    weight&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;20&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    fall&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    rise&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    2&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; VIP1 - true backup, never preempts Node 1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;vrrp_instance&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; DNS_VIP1&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;               BACKUP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    interface&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;           eth0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    virtual_router_id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;   51&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    priority&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;            90&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    advert_int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;          1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    nopreempt&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    unicast_src_ip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  192.168.0.11&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    unicast_peer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        192.168.0.10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    authentication&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        auth_type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; PASS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        auth_pass&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; CHANGE_ME&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    virtual_ipaddress&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        192.168.0.12/24&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    track_script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        chk_dns&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; VIP2 - preferred owner, reclaims after 60s on recovery&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;vrrp_instance&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; DNS_VIP2&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    state&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;               BACKUP&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    interface&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;           eth0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    virtual_router_id&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;   52&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    priority&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;            100&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    advert_int&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;          1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    preempt_delay&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;       60&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    unicast_src_ip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;  192.168.0.11&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    unicast_peer&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        192.168.0.10&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    authentication&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        auth_type&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; PASS&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        auth_pass&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; CHANGE_ME&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    virtual_ipaddress&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        192.168.0.13/24&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    track_script&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;        chk_dns&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;a-few-design-notes-worth-calling-out&quot;&gt;A few design notes worth calling out&lt;a class=&quot;zola-anchor&quot; href=&quot;#a-few-design-notes-worth-calling-out&quot; aria-label=&quot;Anchor link for: a-few-design-notes-worth-calling-out&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;state BACKUP&lt;/code&gt; on both instances, on both nodes&lt;/strong&gt; - this looks counterintuitive, but it’s required for &lt;code&gt;preempt_delay&lt;/code&gt; to work correctly. Priority determines who actually wins the election.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;nopreempt&lt;/code&gt; vs &lt;code&gt;preempt_delay&lt;/code&gt;&lt;/strong&gt; - these are mutually exclusive per instance. The preferred-owner instance uses &lt;code&gt;preempt_delay&lt;/code&gt; so it reclaims its VIP automatically after recovering (with a grace period to avoid flapping). The backup instance uses &lt;code&gt;nopreempt&lt;/code&gt; so it never snatches the VIP away from a healthy peer.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unicast, not multicast&lt;/strong&gt; - &lt;code&gt;unicast_src_ip&lt;/code&gt; / &lt;code&gt;unicast_peer&lt;/code&gt; sends VRRP advertisements directly between the two nodes rather than relying on multicast, which can be unreliable on consumer routers/switches with IGMP snooping enabled.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;step-4-enable-and-start&quot;&gt;Step 4: Enable and Start&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-4-enable-and-start&quot; aria-label=&quot;Anchor link for: step-4-enable-and-start&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Run on &lt;strong&gt;both nodes&lt;/strong&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; systemctl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; enable&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; keepalived.service&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; systemctl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; start&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; keepalived.service&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; reboot&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;step-5-verify-it-s-working&quot;&gt;Step 5: Verify It’s Working&lt;a class=&quot;zola-anchor&quot; href=&quot;#step-5-verify-it-s-working&quot; aria-label=&quot;Anchor link for: step-5-verify-it-s-working&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Check the service:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; systemctl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; status&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; keepalived.service&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Confirm each node holds its expected VIP:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; addr&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; eth0&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Node 1 should show &lt;code&gt;192.168.0.12/24&lt;/code&gt;; Node 2 should show &lt;code&gt;192.168.0.13/24&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Watch keepalived’s logs live:&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;sudo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; journalctl&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;u&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; keepalived&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt; -&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;f&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;test-an-actual-failover&quot;&gt;Test an actual failover&lt;a class=&quot;zola-anchor&quot; href=&quot;#test-an-actual-failover&quot; aria-label=&quot;Anchor link for: test-an-actual-failover&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Power off Node 1: &lt;code&gt;sudo poweroff&lt;/code&gt; (or &lt;code&gt;sudo shutdown -h now&lt;/code&gt;, depending on your device type)&lt;/li&gt;
&lt;li&gt;On Node 2, check its interface again - it should now hold &lt;strong&gt;both&lt;/strong&gt; VIPs:&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;ip&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; addr&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; show&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; eth0&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt; Should show both 192.168.0.12 and 192.168.0.13&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Power Node 1 back on. Because the backup instance uses &lt;code&gt;nopreempt&lt;/code&gt;, Node 2 keeps serving both VIPs until its own health check fails - there’s no disruptive automatic handback. Node 1 simply rejoins as a healthy backup.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If both checks pass, you have a working active-active Pi-hole cluster: DNS keeps resolving for your whole network even if one node is powered off, rebooting, or being reimaged.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;wrapping-up&quot;&gt;Wrapping Up&lt;a class=&quot;zola-anchor&quot; href=&quot;#wrapping-up&quot; aria-label=&quot;Anchor link for: wrapping-up&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;With this setup, your router never talks to a single point of failure - it talks to two VIPs that are always being served by a healthy node. The health-check script goes a step further than just “is the process alive,” actually confirming DNS resolution end-to-end before considering a node healthy. Combine this with keeping both nodes’ Pi-hole configuration in sync (via Teleporter export/import) and you’ve got a resilient, low-maintenance DNS layer for your home network.&lt;/p&gt;
&lt;p&gt;Flush!&lt;/p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Markdown Syntax &amp; Shortcodes Guide</title>
        <published>2026-06-23T00:00:00+00:00</published>
        <updated>2026-07-06T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://pankaj.xyz/posts/post-syntax-guide/"/>
        <id>https://pankaj.xyz/posts/post-syntax-guide/</id>
        
        <content type="html" xml:base="https://pankaj.xyz/posts/post-syntax-guide/">&lt;p&gt;This post serves as a reference guide to showcase all the various syntax and formatting options available when writing content for this blog.&lt;/p&gt;
&lt;h2 id=&quot;1-headings&quot;&gt;1. Headings&lt;a class=&quot;zola-anchor&quot; href=&quot;#1-headings&quot; aria-label=&quot;Anchor link for: 1-headings&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Headings are created using the &lt;code&gt;#&lt;/code&gt; symbol. The &lt;code&gt;h1&lt;/code&gt; is automatically populated from the title frontmatter, so you should start with &lt;code&gt;h2&lt;/code&gt; (&lt;code&gt;##&lt;/code&gt;) for major sections within your post.&lt;/p&gt;
&lt;h3 id=&quot;this-is-an-h3-sub-heading&quot;&gt;This is an h3 (Sub-heading)&lt;a class=&quot;zola-anchor&quot; href=&quot;#this-is-an-h3-sub-heading&quot; aria-label=&quot;Anchor link for: this-is-an-h3-sub-heading&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Use &lt;code&gt;###&lt;/code&gt; for sub-sections.&lt;/p&gt;
&lt;h4 id=&quot;this-is-an-h4&quot;&gt;This is an h4&lt;a class=&quot;zola-anchor&quot; href=&quot;#this-is-an-h4&quot; aria-label=&quot;Anchor link for: this-is-an-h4&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;And &lt;code&gt;####&lt;/code&gt; for even deeper nesting if absolutely necessary.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;2-text-formatting&quot;&gt;2. Text Formatting&lt;a class=&quot;zola-anchor&quot; href=&quot;#2-text-formatting&quot; aria-label=&quot;Anchor link for: 2-text-formatting&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can format your text in a variety of ways to emphasize certain points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;double asterisks&lt;/strong&gt; for &lt;strong&gt;bold text&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Use &lt;em&gt;single asterisks&lt;/em&gt; or &lt;em&gt;underscores&lt;/em&gt; for &lt;em&gt;italic text&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;You can even combine them for &lt;em&gt;&lt;strong&gt;bold italics&lt;/strong&gt;&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Strikethrough is done using double tildes: &lt;del&gt;this text is crossed out&lt;/del&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;3-inline-code-and-code-blocks&quot;&gt;3. Inline Code and Code Blocks&lt;a class=&quot;zola-anchor&quot; href=&quot;#3-inline-code-and-code-blocks&quot; aria-label=&quot;Anchor link for: 3-inline-code-and-code-blocks&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When mentioning a variable, command, or file path in the middle of a sentence, use single backticks for &lt;code&gt;inline-code&lt;/code&gt;. For example: “Be sure to edit your &lt;code&gt;config.toml&lt;/code&gt; file.”&lt;/p&gt;
&lt;p&gt;For larger snippets, use fenced code blocks. Specify the language for proper syntax highlighting:&lt;/p&gt;
&lt;h3 id=&quot;bash-example&quot;&gt;Bash Example&lt;a class=&quot;zola-anchor&quot; href=&quot;#bash-example&quot; aria-label=&quot;Anchor link for: bash-example&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;#!&lt;/span&gt;&lt;span style=&quot;color: light-dark(#6E7781, #8B949E);&quot;&gt;/bin/bash&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;echo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Hello, world!&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;BACKUP_PATHS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;=&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/mnt/storage&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;/home/pankaj/stacks&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;for&lt;/span&gt;&lt;span&gt; path&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; in&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;{&lt;/span&gt;&lt;span&gt;BACKUP_PATHS&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; do&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0550AE, #79C0FF);&quot;&gt;    echo&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Backing up &lt;/span&gt;&lt;span&gt;$&lt;/span&gt;&lt;span&gt;path&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;...&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;done&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&quot;python-example&quot;&gt;Python Example&lt;a class=&quot;zola-anchor&quot; href=&quot;#python-example&quot; aria-label=&quot;Anchor link for: python-example&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;python&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; fetch_data&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;url&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;    &amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Fetches data from the given URL.&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    response&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; =&lt;/span&gt;&lt;span&gt; requests&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;get&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;url&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;    return&lt;/span&gt;&lt;span&gt; response&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;json&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;4-links&quot;&gt;4. Links&lt;a class=&quot;zola-anchor&quot; href=&quot;#4-links&quot; aria-label=&quot;Anchor link for: 4-links&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Standard links are created using square brackets for the text and parentheses for the URL:
&lt;a rel=&quot;noopener nofollow external&quot; target=&quot;_blank&quot; href=&quot;https://github.com/iPankajKumar93&quot;&gt;Visit my GitHub profile&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;5-lists&quot;&gt;5. Lists&lt;a class=&quot;zola-anchor&quot; href=&quot;#5-lists&quot; aria-label=&quot;Anchor link for: 5-lists&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;unordered-lists&quot;&gt;Unordered Lists&lt;a class=&quot;zola-anchor&quot; href=&quot;#unordered-lists&quot; aria-label=&quot;Anchor link for: unordered-lists&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can use &lt;code&gt;-&lt;/code&gt; or &lt;code&gt;*&lt;/code&gt; for bulleted lists:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;First item&lt;/li&gt;
&lt;li&gt;Second item
&lt;ul&gt;
&lt;li&gt;Nested item A&lt;/li&gt;
&lt;li&gt;Nested item B&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Third item&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;ordered-lists&quot;&gt;Ordered Lists&lt;a class=&quot;zola-anchor&quot; href=&quot;#ordered-lists&quot; aria-label=&quot;Anchor link for: ordered-lists&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Use numbers followed by a period:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First step&lt;/li&gt;
&lt;li&gt;Second step&lt;/li&gt;
&lt;li&gt;Final step&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;6-blockquotes&quot;&gt;6. Blockquotes&lt;a class=&quot;zola-anchor&quot; href=&quot;#6-blockquotes&quot; aria-label=&quot;Anchor link for: 6-blockquotes&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To quote text from another source or highlight an excerpt, use the &lt;code&gt;&amp;gt;&lt;/code&gt; symbol:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“Simplicity is the ultimate sophistication.”&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Leonardo da Vinci&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;7-tables&quot;&gt;7. Tables&lt;a class=&quot;zola-anchor&quot; href=&quot;#7-tables&quot; aria-label=&quot;Anchor link for: 7-tables&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Markdown tables are great for structured data:&lt;/p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style=&quot;text-align: left&quot;&gt;Service&lt;/th&gt;&lt;th style=&quot;text-align: center&quot;&gt;Port&lt;/th&gt;&lt;th style=&quot;text-align: right&quot;&gt;Description&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;strong&gt;Gitea&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;text-align: center&quot;&gt;&lt;code&gt;3000&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;Self-hosted Git service&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;strong&gt;Pi-hole&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;text-align: center&quot;&gt;&lt;code&gt;53&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;Network-wide ad blocking&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: left&quot;&gt;&lt;strong&gt;Grafana&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;text-align: center&quot;&gt;&lt;code&gt;3000&lt;/code&gt;&lt;/td&gt;&lt;td style=&quot;text-align: right&quot;&gt;Observability dashboards&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2 id=&quot;8-images-and-gifs&quot;&gt;8. Images and GIFs&lt;a class=&quot;zola-anchor&quot; href=&quot;#8-images-and-gifs&quot; aria-label=&quot;Anchor link for: 8-images-and-gifs&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There are four main ways to add images depending on your needs.&lt;/p&gt;
&lt;h3 id=&quot;method-a-standard-markdown-image&quot;&gt;Method A: Standard Markdown Image&lt;a class=&quot;zola-anchor&quot; href=&quot;#method-a-standard-markdown-image&quot; aria-label=&quot;Anchor link for: method-a-standard-markdown-image&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The simplest way to embed an image or a GIF:
&lt;img src=&quot;/images/sample-gif.gif&quot; alt=&quot;A sample GIF&quot; /&gt;&lt;/p&gt;
&lt;h3 id=&quot;method-b-image-with-caption-zola-shortcode&quot;&gt;Method B: Image with Caption (Zola Shortcode)&lt;a class=&quot;zola-anchor&quot; href=&quot;#method-b-image-with-caption-zola-shortcode&quot; aria-label=&quot;Anchor link for: method-b-image-with-caption-zola-shortcode&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Use the custom &lt;code&gt;img_caption&lt;/code&gt; shortcode to beautifully display an image with a caption below it:&lt;/p&gt;
&lt;figure&gt;
&lt;img src=&quot;https://pankaj.xyz/images/sample-image.jpeg?h=636744f982fc39579b86&quot; alt=&quot;This is a profile picture with a caption.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; width=&quot;275&quot; height=&quot;183&quot;&gt;
&lt;figcaption&gt;This is a profile picture with a caption.&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h3 id=&quot;method-c-lightbox-image-click-to-zoom&quot;&gt;Method C: Lightbox Image (Click to Zoom)&lt;a class=&quot;zola-anchor&quot; href=&quot;#method-c-lightbox-image-click-to-zoom&quot; aria-label=&quot;Anchor link for: method-c-lightbox-image-click-to-zoom&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you want the user to be able to click the image and view it in a full-screen overlay (lightbox), use this raw HTML snippet:&lt;/p&gt;
&lt;div class=&quot;text-center&quot;&gt;
&lt;a href=&quot;/images/sample-image.jpeg&quot; class=&quot;lightbox-thumbnail&quot; data-featherlight=&quot;image&quot;&gt;
    &lt;img src=&quot;/images/sample-image.jpeg&quot; alt=&quot;Profile Picture&quot; width=&quot;400&quot;&gt;
&lt;/a&gt;
&lt;/div&gt;
&lt;h3 id=&quot;method-d-image-grid-side-by-side-images&quot;&gt;Method D: Image Grid (Side-by-Side Images)&lt;a class=&quot;zola-anchor&quot; href=&quot;#method-d-image-grid-side-by-side-images&quot; aria-label=&quot;Anchor link for: method-d-image-grid-side-by-side-images&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;When you have multiple related images (like progress shots of a homelab build or multiple dashboard screenshots), stacking them vertically takes up too much space. The &lt;code&gt;image-grid&lt;/code&gt; class creates a responsive 2-column grid that automatically handles spacing and scales down to a single column on mobile. It even gracefully centers the last image if there is an odd number of photos!&lt;/p&gt;
&lt;div class=&quot;image-grid&quot;&gt;
&lt;a href=&quot;/images/sample-image.jpeg&quot; class=&quot;lightbox-thumbnail&quot;&gt;&lt;img src=&quot;/images/sample-image.jpeg&quot; alt=&quot;Sample grid image 1&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;/images/sample-image.jpeg&quot; class=&quot;lightbox-thumbnail&quot;&gt;&lt;img src=&quot;/images/sample-image.jpeg&quot; alt=&quot;Sample grid image 2&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;/images/sample-image.jpeg&quot; class=&quot;lightbox-thumbnail&quot;&gt;&lt;img src=&quot;/images/sample-image.jpeg&quot; alt=&quot;Sample grid image 3 centered&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;h2 id=&quot;9-media-embeds-maps-youtube&quot;&gt;9. Media Embeds (Maps &amp;amp; YouTube)&lt;a class=&quot;zola-anchor&quot; href=&quot;#9-media-embeds-maps-youtube&quot; aria-label=&quot;Anchor link for: 9-media-embeds-maps-youtube&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;maps-google-maps-my-maps&quot;&gt;Maps (Google Maps / My Maps)&lt;a class=&quot;zola-anchor&quot; href=&quot;#maps-google-maps-my-maps&quot; aria-label=&quot;Anchor link for: maps-google-maps-my-maps&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You can directly embed custom Google Maps or My Maps using the standard HTML iframe snippet. The site will render it inline perfectly:&lt;/p&gt;
&lt;iframe src=&quot;https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3022.1422937950147!2d-73.98731968482413!3d40.75889497932681!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c25855c6480299%3A0x55194ec5a1ae072e!2sTimes+Square!5e0!3m2!1sen!2sus!4v1560413669145!5m2!1sen!2sus&quot; width=&quot;640&quot; height=&quot;480&quot;&gt;&lt;/iframe&gt;
&lt;h3 id=&quot;youtube-videos&quot;&gt;YouTube Videos&lt;a class=&quot;zola-anchor&quot; href=&quot;#youtube-videos&quot; aria-label=&quot;Anchor link for: youtube-videos&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;There are two primary ways to embed YouTube videos that are used across the site.&lt;/p&gt;
&lt;h4 id=&quot;method-a-native-embed-zola-shortcode&quot;&gt;Method A: Native Embed (Zola Shortcode)&lt;a class=&quot;zola-anchor&quot; href=&quot;#method-a-native-embed-zola-shortcode&quot; aria-label=&quot;Anchor link for: method-a-native-embed-zola-shortcode&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Use the custom &lt;code&gt;youtube&lt;/code&gt; shortcode to embed the full interactive iframe directly into the post:&lt;/p&gt;
&lt;div class=&quot;youtube-embed&quot;&gt;
    &lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ&quot; title=&quot;YouTube video&quot; loading=&quot;lazy&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;h4 id=&quot;method-b-lightweight-image-link&quot;&gt;Method B: Lightweight Image Link&lt;a class=&quot;zola-anchor&quot; href=&quot;#method-b-lightweight-image-link&quot; aria-label=&quot;Anchor link for: method-b-lightweight-image-link&quot;&gt;#&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;For better page-load performance, you can use a thumbnail image that links out to the video instead of loading an iframe:
&lt;a rel=&quot;noopener nofollow external&quot; target=&quot;_blank&quot; href=&quot;https://www.youtube.com/watch?v=dQw4w9WgXcQ&quot;&gt;&lt;img src=&quot;https://img.youtube.com/vi/dQw4w9WgXcQ/0.jpg&quot; alt=&quot;Alternative YouTube Link&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;10-admonitions-callouts&quot;&gt;10. Admonitions / Callouts&lt;a class=&quot;zola-anchor&quot; href=&quot;#10-admonitions-callouts&quot; aria-label=&quot;Anchor link for: 10-admonitions-callouts&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Admonitions are custom Zola shortcodes used to highlight important information, warnings, or notes.&lt;/p&gt;
&lt;aside class=&quot;admonition note&quot; role=&quot;note&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon info &quot; aria-hidden=&quot;true&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot; /&gt;
  &lt;path d=&quot;M12 16v-4&quot; /&gt;
  &lt;path d=&quot;M12 8h.01&quot; /&gt;&lt;/svg&gt;
 Note&lt;/p&gt;
&lt;p&gt;This is a standard note admonition.&lt;/p&gt;
&lt;/aside&gt;
&lt;aside class=&quot;admonition tip&quot; role=&quot;note&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon zap &quot; aria-hidden=&quot;true&quot;&gt;&lt;path
    d=&quot;M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z&quot; /&gt;&lt;/svg&gt;
 Tip&lt;/p&gt;
&lt;p&gt;This is a tip admonition.&lt;/p&gt;
&lt;/aside&gt;
&lt;aside class=&quot;admonition important&quot; role=&quot;note&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon alert-circle &quot; aria-hidden=&quot;true&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot; /&gt;
  &lt;line x1=&quot;12&quot; x2=&quot;12&quot; y1=&quot;8&quot; y2=&quot;12&quot; /&gt;
  &lt;line x1=&quot;12&quot; x2=&quot;12.01&quot; y1=&quot;16&quot; y2=&quot;16&quot; /&gt;&lt;/svg&gt;
 Important&lt;/p&gt;
&lt;p&gt;This is an important admonition.&lt;/p&gt;
&lt;/aside&gt;
&lt;aside class=&quot;admonition warning&quot; role=&quot;alert&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon alert-triangle &quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3&quot; /&gt;
  &lt;path d=&quot;M12 9v4&quot; /&gt;
  &lt;path d=&quot;M12 17h.01&quot; /&gt;&lt;/svg&gt;
 Warning&lt;/p&gt;
&lt;p&gt;This is a warning admonition.&lt;/p&gt;
&lt;/aside&gt;
&lt;aside class=&quot;admonition caution&quot; role=&quot;alert&quot;&gt;
&lt;p class=&quot;admonition-header&quot;&gt;
&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot;
  stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;svg-icon x-octagon &quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;m15 9-6 6&quot; /&gt;
  &lt;path
    d=&quot;M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z&quot; /&gt;
  &lt;path d=&quot;m9 9 6 6&quot; /&gt;&lt;/svg&gt;
 Caution&lt;/p&gt;
&lt;p&gt;This is a caution admonition.&lt;/p&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;11-code-line-differences&quot;&gt;11. Code Line Differences&lt;a class=&quot;zola-anchor&quot; href=&quot;#11-code-line-differences&quot; aria-label=&quot;Anchor link for: 11-code-line-differences&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Zola natively supports diff highlighting in code blocks:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;diff&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#82071E, #FFA198);background-color: light-dark(#FFEBE9, #490202);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: light-dark(#82071E, #FFA198);background-color: light-dark(#FFEBE9, #490202);&quot;&gt; println(&amp;quot;Hello Old World&amp;quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);background-color: light-dark(#DAFBE1, #04260F);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: light-dark(#116329, #7EE787);background-color: light-dark(#DAFBE1, #04260F);&quot;&gt; println(&amp;quot;Hello New World! 👋&amp;quot;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;12-mermaid-diagrams&quot;&gt;12. Mermaid Diagrams&lt;a class=&quot;zola-anchor&quot; href=&quot;#12-mermaid-diagrams&quot; aria-label=&quot;Anchor link for: 12-mermaid-diagrams&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can write technical flowcharts directly in Markdown using Mermaid.js syntax:&lt;/p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color-scheme: light dark; color: light-dark(#1F2328, #E6EDF3); background-color: light-dark(#FFFFFF, #0D1117);&quot; &gt;&lt;code data-lang=&quot;mermaid&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;flowchart&lt;/span&gt;&lt;span style=&quot;color: light-dark(#8250DF, #D2A8FF);&quot;&gt; TD&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    A&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;([&lt;/span&gt;&lt;span&gt;📝&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt; Hashnode&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;])&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt; --&amp;gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Export Posts&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; B&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;60 Markdown Files&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    B &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;--&amp;gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;AI Asset Rescue&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; C&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;[(&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Local Images&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;)]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    B &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; D&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;[[&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Zola Build&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;]]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    C &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;--&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; D&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt;    D &lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;--&amp;gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;Wrangler Deploy&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color: light-dark(#953800, #FFA657);&quot;&gt; E&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;([&lt;/span&gt;&lt;span&gt;☁&lt;/span&gt;&lt;span style=&quot;color: light-dark(#0A3069, #A5D6FF);&quot;&gt;️ Cloudflare Edge&lt;/span&gt;&lt;span style=&quot;color: light-dark(#CF222E, #FF7B72);&quot;&gt;])&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;13-inline-html-elements&quot;&gt;13. Inline HTML Elements&lt;a class=&quot;zola-anchor&quot; href=&quot;#13-inline-html-elements&quot; aria-label=&quot;Anchor link for: 13-inline-html-elements&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Because Markdown fully supports raw HTML, you can use semantic tags to enhance your text:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Abbreviations:&lt;/strong&gt; &lt;abbr title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/abbr&gt; is awesome.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Superscript:&lt;/strong&gt; E = mc&lt;sup&gt;2&lt;/sup&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Subscript:&lt;/strong&gt; H&lt;sub&gt;2&lt;/sub&gt;O is water.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Keyboard inputs:&lt;/strong&gt; Press &lt;kbd&gt;Ctrl&lt;/kbd&gt; + &lt;kbd&gt;C&lt;/kbd&gt; to copy.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Highlighted text:&lt;/strong&gt; You can &lt;mark&gt;highlight important information&lt;/mark&gt; using the mark tag.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;14-footnotes&quot;&gt;14. Footnotes&lt;a class=&quot;zola-anchor&quot; href=&quot;#14-footnotes&quot; aria-label=&quot;Anchor link for: 14-footnotes&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can add footnotes to your text by using standard markdown footnote syntax. Here is a sentence with a footnote.&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-1-1&quot;&gt;&lt;a href=&quot;https://pankaj.xyz/posts/post-syntax-guide/#fn-1&quot;&gt;[1]&lt;/a&gt;&lt;/sup&gt;&lt;br /&gt;
You can also add multiple footnotes in the same document.&lt;sup class=&quot;footnote-reference&quot; id=&quot;fr-2-1&quot;&gt;&lt;a href=&quot;https://pankaj.xyz/posts/post-syntax-guide/#fn-2&quot;&gt;[2]&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;h2 id=&quot;15-math-rendering-katex&quot;&gt;15. Math Rendering (KaTeX)&lt;a class=&quot;zola-anchor&quot; href=&quot;#15-math-rendering-katex&quot; aria-label=&quot;Anchor link for: 15-math-rendering-katex&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can render mathematical equations cleanly using KaTeX.&lt;/p&gt;
&lt;p&gt;For inline equations, wrap your math in single dollar signs: $E=mc^2$.&lt;/p&gt;
&lt;p&gt;For block equations, wrap them in double dollar signs:&lt;/p&gt;
&lt;p&gt;$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This concludes the syntax reference guide. Happy writing!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Flush!&lt;/p&gt;
&lt;section class=&quot;footnotes&quot;&gt;
&lt;ol class=&quot;footnotes-list&quot;&gt;
&lt;li id=&quot;fn-1&quot;&gt;
&lt;p&gt;This is the text of the footnote that appears when the superscript number is clicked. &lt;a href=&quot;https://pankaj.xyz/posts/post-syntax-guide/#fr-1-1&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id=&quot;fn-2&quot;&gt;
&lt;p&gt;This is the second footnote. Zola will automatically number and link them in order! &lt;a href=&quot;https://pankaj.xyz/posts/post-syntax-guide/#fr-2-1&quot;&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Hello World</title>
        <published>2026-06-14T00:00:00+00:00</published>
        <updated>2026-06-14T00:00:00+00:00</updated>
        
        <author>
          <name>Unknown</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://pankaj.xyz/posts/hello-world/"/>
        <id>https://pankaj.xyz/posts/hello-world/</id>
        
        <content type="html" xml:base="https://pankaj.xyz/posts/hello-world/">&lt;p&gt;Hello World!&lt;/p&gt;
&lt;p&gt;This site has existed since 2018, yet &lt;strong&gt;write more&lt;/strong&gt; never made it out of the backlog. The site itself has gone through &lt;strong&gt;three complete overhauls&lt;/strong&gt; since 2018 - chasing the right look, the right tool, the right feel. Each time I’d convince myself the theme and layout were the problem. Turns out, the writing was. I’ve finally landed on a Zola-based static site: lightweight, fast, and built around plain Markdown files that feel natural to a developer. No more tinkering (for now 😛).&lt;/p&gt;
&lt;p&gt;This is my first article on the updated blog, and genuinely only my second attempt at writing.&lt;/p&gt;
&lt;p&gt;Flush!&lt;/p&gt;
</content>
        
    </entry>
</feed>
