frontend
Technical notes on web development, DevOps, and AI integration.
173 articles
- 02:27frontend
fetch Rejected on file://, Search Becomes a Script
A fetch for a neighboring JSON file fails under file:// because local origins are opaque. The search index ships as a script file and IndexedDB stores it.
TL;DR: Browsers treat local files as opaque origins, so fetch can't load a JSON file opened via file://. The fix ships the search index as a JavaScript file assigning a global, loads it with a script tag, and caches it in IndexedDB, re-seeding when a captured_at version changes. A build audit also fails if any screenshot lacks a caption.
#frontend#javascript#documentation - 00:54frontend
24 Pages, Zero Media: Paths Measured from the Wrong Directory
One generator change left 24 documentation pages empty: every media file 404'd because src paths were measured from the repo root, not the page's folder.
TL;DR: A static site generator produced 24 pages where all media 404'd, blamed first on disk-opening but actually caused by src paths written from the repo root instead of each page's folder. Relative URLs resolve against the document's own directory, not the generator's working directory. The fix computes each src via path.relative from pageDir, handling Windows separators.
#html#nodejs#documentation - 21:12frontend
Published in the Admin, Empty on the Pillar Page
A freshly published entity never appeared on the pillar page while the API served it fine. The lesson was one cache option: no-store on fetch, page ISR kept intact.
TL;DR: A published entity never showed on the pillar page grid. The page's ISR config was fine; the real culprit was getEntities fetching without a cache option, so Next.js 14 cached the list at build time forever. Adding cache: "no-store" fixed it, plus an E2E parity test guards the regression.
#nextjs#cache#fetch - 19:13frontend
A Static Folder Was Shadowing the Sports Route
The OLAHRAGA rubric rendered empty while every other rubric matched. A static folder outranked the dynamic segment, and a fetch cache default kept new rows out.
TL;DR: A weekly parity check caught OLAHRAGA showing zero public announcements while the admin feed had several. Root cause: a static page at informasi/olahraga won Next.js route precedence over the dynamic template, then default fetch caching blocked new rows. Fix mirrored the announcements component in both pages and set cache: "no-store".
#nextjs#app-router#routing - 13:02frontend
Breadcrumbs Above the Hero, Labels From Existing Config
Three sibling section pages gained an accessible breadcrumb above the hero, with labels reused from the config object each page already had.
TL;DR: Three KotaPortal section pages lacked breadcrumbs, so the author placed the existing Breadcrumbs component above each HeroSlider instead of inside it. The label reuses each page's PILLAR config name, so no new strings or dependencies. Verification used curl and grep to confirm exactly one aria-current marker appears in the rendered HTML.
#nextjs#react#accessibility - 12:12frontend
A Video Description Box With a Show More That Earns Its Place
A three-line clamp plus a post-mount overflow measurement keeps the show-more toggle honest: it renders only when text is truly cut.
TL;DR: KotaPortal's video descriptions could grow so long that Like and Share buttons fell below the fold. Instead of truncating by character count, the component clamps text to three lines with Tailwind's line-clamp-3, then measures scrollHeight against clientHeight after mount to show a toggle only when needed. The "Deskripsi" label was dropped since the box and toggle make it redundant.
#react#css#tailwindcss - 11:55frontend
Registry First, Redirect Second: Moving URLs into a /videos Tree
Moving flat video URLs into a /videos hub tree in Next.js App Router with a category registry and a 308 permanentRedirect, verified with curl.
TL;DR: KotaPortal's flat /video/[slug] URLs started colliding when two CMS entries shared one slug. The fix rebuilds routes as /videos/[field]/[category]/[slug], with a data-driven registry feeding redirects, sitemap, and hub pages. Legacy routes call permanentRedirect() to return 308s, so Google treats the new URLs as canonical.
#nextjs#seo#redirect - 17:05testing
Retired Terms Must Stay Retired After a Rebrand
A rebrand is a per-surface decision list: five string surfaces, two entries that must not change, and a legacy-guard test that keeps retired terms retired.
TL;DR: Renaming Duta Muda and Jelajah Kota to PESONA meant mapping five surfaces—copy, SEO metadata, admin labels, wordmark, and database rows—instead of a blind find-and-replace. Exceptions like contact emails, a deferred site title, and archived documents stayed untouched. A legacy-guard test with negative assertions keeps retired terms from creeping back in.
#testing#vitest#nextjs - 12:59frontend
One Color Stop, Two Contrast Values
The sed replaced 409 accent classes, yet the button fill stayed at stop 600. WCAG thresholds per role, not taste, explain the two anchors.
TL;DR: The sed swapping 409 emerald text classes wasn't busywork; it enforced a design contract mapping WCAG contrast roles to Tailwind stops. One blue stop can't serve both roles: text needs 4.5:1 (#0369a1 hits 5.93), button fill only needs 3:1 (#0080c9 hits 4.26). Verification paired a luminance script with a compiled-CSS census, plus two documented contrast exceptions.
#css#tailwind#accessibility