176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
#!/usr/bin/env node
// Writes sitemap.xml, the home page's plain list of links and llms.txt from the home page's cards: a development tool, not
// part of the site. Run it from a git checkout after adding or changing pages.
// Usage: node tools/update-sitemap.mjs [--out <file>]
// The home page comes first, then the Famous effects page (famous/), then every page in the order of the CATS array in
// index.html (the home page's order), at the home page's canonical address. A page's lastmod is the date of the last
// commit that touched its folder (git log -1 --format=%cs -- <folder>), or today's date when the folder has changes that
// are not committed yet (a new page too); the Famous effects page is dated the same way, by famous/. The home page's
// lastmod is the latest of index.html and the files it loads (the page script and the two fonts): a change to a page
// alone does not change the home page. changefreq and priority: weekly and 1.0 for the home page, monthly and 0.8 for
// the Famous effects page, monthly and 0.7 for every page.
// Without --out it rewrites sitemap.xml at the repo root, keeping its line endings; --out writes the same text to
// another file instead, to compare. It prints how many URLs it wrote and how many dates changed.
// Needs git on the PATH. Exit code 1 when a card has no page folder, famous/ has no index.html, or git cannot be read.
import { execFile, execFileSync } from 'node:child_process';
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { promisify } from 'node:util';
import vm from 'node:vm';
const ROOT = fileURLToPath(new URL('..', import.meta.url));
const SITEMAP = join(ROOT, 'sitemap.xml');
const args = process.argv.slice(2);
const outAt = args.indexOf('--out');
if (outAt >= 0 && !args[outAt + 1]) { console.error('--out needs a file name'); process.exit(2); }
const OUT = outAt >= 0 ? args[outAt + 1] : SITEMAP;
const HOME = readFileSync(join(ROOT, 'index.html'), 'utf8');
// Where the bracket that opens at HOME[from] is closed, stepping over strings and // comments (as the tests read it).
function blockEnd(from) {
const open = HOME[from], close = open === '[' ? ']' : '}';
let depth = 0, i = from, quote = null;
for (; i < HOME.length; i++) {
const ch = HOME[i];
if (quote) { if (ch === '\\') i++; else if (ch === quote) quote = null; continue; }
if (ch === '/' && HOME[i + 1] === '/') { while (i < HOME.length && HOME[i] !== '\n') i++; continue; }
if (ch === "'" || ch === '"' || ch === '`') quote = ch;
else if (ch === open) depth++;
else if (ch === close && --depth === 0) break;
}
return i;
}
const start = HOME.indexOf('const CATS=');
if (start < 0) { console.error('index.html has no const CATS='); process.exit(1); }
const from = start + 'const CATS='.length;
const CATS = vm.runInNewContext('(' + HOME.slice(from, blockEnd(from) + 1) + ')');
const BASE = (HOME.match(/<link rel="canonical" href="([^"]+\/)">/) || [])[1];
if (!BASE) { console.error('index.html has no canonical address ending in /'); process.exit(1); }
// A category's folder is written from the root, as in 'animations/01-scroll-based'.
const pages = CATS.flatMap(cat => cat.entries.map(([slug]) => `${cat.folder.replace(/\/$/, '')}/${slug}/`));
const missing = pages.filter(folder => !existsSync(join(ROOT, folder, 'index.html')));
if (missing.length) { console.error(`cards with no page: ${missing.join(', ')}`); process.exit(1); }
// The Famous effects page (docs/superpowers/specs/2026-10-13-famous-effects-design.md) comes right after the home page.
const FAMOUS = 'famous/';
if (!existsSync(join(ROOT, FAMOUS, 'index.html'))) { console.error('famous/ has no index.html'); process.exit(1); }
// The home page's plain list of links: every card as a link under its group's name, with its line, inside the <noscript>
// block, for visitors and crawlers that run no script (the cards themselves are drawn by the page's script). It is written
// between its two comment lines before the dates are read, so a list that changed dates the home page today. Not with --out.
const escape = s => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
const LIST_START = '<!-- plain-links: written by tools/update-sitemap.mjs from the cards; not by hand -->', LIST_END = '<!-- /plain-links -->';
const listAt = HOME.indexOf(LIST_START), listEnd = HOME.indexOf(LIST_END, listAt);
if (listAt < 0 || listEnd < 0) { console.error('index.html has no plain-links comment lines'); process.exit(1); }
const HOME_EOL = HOME.includes('\r\n') ? '\r\n' : '\n';
const list = CATS.map(cat => [`<h3>${escape(cat.name)}</h3>`, '<ul>',
...cat.entries.map(([slug, name, desc]) => `<li><a href="${cat.folder.replace(/\/$/, '')}/${slug}/">${escape(name)}</a>: ${escape(desc)}</li>`),
'</ul>'].join(HOME_EOL)).join(HOME_EOL);
const withList = HOME.slice(0, listAt + LIST_START.length) + HOME_EOL + list + HOME_EOL + HOME.slice(listEnd);
if (outAt < 0) {
if (withList !== HOME) writeFileSync(join(ROOT, 'index.html'), withList);
console.log(`index.html: ${pages.length} plain links, ${withList === HOME ? 'as they were' : 'written again'}`);
}
// llms.txt, at the root: the handbook as one plain list for AI tools that read a site without running its scripts. The title, a
// summary with the count, every card under its group in home order with its live address and its line, then the Famous
// effects page with its own description (white space squeezed). Written with the line endings it had. Not with --out.
const REPO = 'https://github.com/matinmonshizadeh/animation-handbook';
const ENTITIES = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };
const decode = s => s.replace(/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|([A-Za-z][A-Za-z0-9]*));/g, (all, dec, hex, name) => {
if (dec || hex) return String.fromCodePoint(parseInt(dec || hex, dec ? 10 : 16));
if (Object.hasOwn(ENTITIES, name)) return ENTITIES[name];
console.error(`famous/index.html: the entity ${all} is not one this tool reads (add it to ENTITIES in tools/update-sitemap.mjs)`);
process.exit(1);
});
const famousLede = (readFileSync(join(ROOT, FAMOUS, 'index.html'), 'utf8').match(/<meta name="description" content="([^"]+)">/) || [])[1];
if (!famousLede) { console.error('famous/index.html has no description (<meta name="description" content="…">)'); process.exit(1); }
const LLMS = join(ROOT, 'llms.txt');
const llms = ['# Animation Handbook', '',
`> A visual reference of ${pages.length} web animation techniques, each with a live demo and a plain-words prompt for building it with an AI assistant.`, '',
"Each page plays one technique live and gives a ready-made prompt that describes it in plain words, with no code. Most pages also have a few plain settings, such as speed or direction, and the prompt you copy lists your choices. Each technique's folder on GitHub has a README on how it works, the values that matter and production notes.", '',
...CATS.flatMap(cat => [`## ${cat.name}`, '',
...cat.entries.map(([slug, name, desc]) => `- [${name}](${BASE}${cat.folder.replace(/\/$/, '')}/${slug}/): ${desc}`), '']),
'## Famous effects', '', `- [Famous effects](${BASE}${FAMOUS}): ${decode(famousLede).replace(/\s+/g, ' ').trim()}`, '',
'## Optional', '', `- [Source on GitHub](${REPO}): every demo's code and each technique's README`, ''].join('\n');
if (outAt < 0) {
const oldLlms = existsSync(LLMS) ? readFileSync(LLMS, 'utf8') : '';
const text = oldLlms.includes('\r\n') ? llms.replace(/\n/g, '\r\n') : llms;
if (text !== oldLlms) writeFileSync(LLMS, text);
console.log(`llms.txt: ${pages.length} pages, ${text === oldLlms ? 'as it was' : 'written again'}`);
}
const now = new Date();
const TODAY = [now.getFullYear(), now.getMonth() + 1, now.getDate()].map(n => String(n).padStart(2, '0')).join('-');
let changed;
try {
// Every path with changes that are not committed (staged, unstaged or new), one record per path.
changed = execFileSync('git', ['status', '--porcelain=v1', '-z', '--untracked-files=all', '--no-renames'], { cwd: ROOT, encoding: 'utf8' })
.split('\0').filter(Boolean).map(record => record.slice(3));
} catch (err) {
console.error(`git status failed (${err.message.split('\n')[0]}): run this from a git checkout with git on the PATH`);
process.exit(1);
}
const git = promisify(execFile);
// The date of a file or folder: today when it has changes that are not committed, else the date of its last commit.
async function dateOf(target) {
const isFolder = target.endsWith('/');
if (changed.some(p => (isFolder ? p.startsWith(target) : p === target))) return TODAY;
const { stdout } = await git('git', ['log', '-1', '--format=%cs', '--', target], { cwd: ROOT });
return stdout.trim() || TODAY;
}
// A few git calls at a time: one per page is quick enough, all at once is not kind to a busy machine.
async function datesOf(targets, atOnce = 8) {
const dates = new Array(targets.length);
let next = 0;
await Promise.all(Array.from({ length: atOnce }, async () => {
while (next < targets.length) { const i = next++; dates[i] = await dateOf(targets[i]); }
}));
return dates;
}
const pageDates = await datesOf(pages);
const homeDate = (await datesOf(['index.html', 'assets/js/demo-page.js', 'assets/fonts/schibsted-latin.woff2',
'assets/fonts/schibsted-latin-ext.woff2'])).sort().pop();
const famousDate = (await datesOf([FAMOUS]))[0];
const line = (loc, lastmod, changefreq, priority) =>
` <url><loc>${escape(loc)}</loc><lastmod>${lastmod}</lastmod><changefreq>${changefreq}</changefreq><priority>${priority}</priority></url>`;
const lines = ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
line(BASE, homeDate, 'weekly', '1.0'), line(BASE + FAMOUS, famousDate, 'monthly', '0.8'),
...pages.map((folder, i) => line(BASE + folder, pageDates[i], 'monthly', '0.7')), '</urlset>'];
const old = existsSync(SITEMAP) ? readFileSync(SITEMAP, 'utf8') : '';
const EOL = old.includes('\r\n') ? '\r\n' : '\n';
const oldDates = new Map([...old.matchAll(/<loc>([^<]*)<\/loc><lastmod>([^<]*)<\/lastmod>/g)].map(m => [m[1], m[2]]));
const newDates = [[BASE, homeDate], [BASE + FAMOUS, famousDate], ...pages.map((folder, i) => [BASE + folder, pageDates[i]])];
const moved = newDates.filter(([loc, date]) => oldDates.get(loc) !== date).length;
writeFileSync(OUT, lines.join(EOL) + EOL);
console.log(`${OUT}: ${newDates.length} URLs, ${moved} lastmod ${moved === 1 ? 'date' : 'dates'} new or changed`);