Skip to content

Curated website design inspiration gallery, open zero-auth MCP server for AI agents, and shareable moodboard lists.

2.1 KB
Raw Blame
import { readFile, readdir, stat } from "node:fs/promises";
import { resolve, join } from "node:path";
import { JSDOM } from "jsdom";
import assert from "node:assert/strict";
const root = resolve("apps/gallery/out");
let pages = 0,
  links = 0;
async function walk(dir) {
  for (const f of await readdir(dir, { withFileTypes: true })) {
    const p = join(dir, f.name);
    if (f.isDirectory()) await walk(p);
    else if (f.name.endsWith(".html")) {
      const html = await readFile(p, "utf8"),
        dom = new JSDOM(html, { url: "https://designtaste.wtf/" }),
        doc = dom.window.document;
      pages++;
      assert.equal(doc.querySelectorAll("h1").length, 1, p);
      assert.ok(doc.querySelector('meta[property="og:image"]'), p);
      assert.ok(doc.querySelector('link[rel="canonical"]'), p);
      for (const el of doc.querySelectorAll(
        "a[href],img[src],source[srcset],source[src],video[src],video[poster],[data-video],script[src],link[href]",
      )) {
        const urls = [
          el.getAttribute("href"),
          el.getAttribute("src"),
          el.getAttribute("poster"),
          el.getAttribute("data-video"),
          el.getAttribute("srcset")?.split(/[\s,]+/)[0],
        ].filter(Boolean);
        for (const url of urls) {
          if (
            !url.startsWith("/") ||
            url.startsWith("//") ||
            url.startsWith("/_vercel/")
          )
            continue;
          const dest = join(root, url.split(/[?#]/)[0]);
          await stat(url.endsWith("/") ? join(dest, "index.html") : dest).catch(
            () => {
              throw Error(`Broken link in ${p}: ${url}`);
            },
          );
          links++;
        }
      }
      for (const s of doc.querySelectorAll(
        'script[type="application/ld+json"]',
      ))
        JSON.parse(s.textContent);
      dom.window.close();
    }
  }
}
await walk(root);
assert.ok(pages >= 110);
const js = await readFile(join(root, "gallery.js"), "utf8");
assert.doesNotMatch(js, /better-auth|supabase|cloudflare/);
console.log(
  `Checked ${pages} pages, ${links} internal links/assets, structured data, and client bundle.`,
);