# Trailhead: moving from Astro, Next.js or Gatsby

These are component frameworks: a page is a tree of components, rendered on a server or at build time and, for some of them, run again in the browser. ssqch is a template-and-Markdown generator that ships HTML and only the JavaScript you write. So this move isn't a port of the framework. It's a sort of what you have into three piles:

1. **Content** (Markdown, front matter, data files): moves as it is.
2. **Presentational components** (cards, callouts, layouts, navigation): become templates, with no JavaScript in the browser.
3. **Interactive components** (a search box, tabs with state, a live editor): stay JavaScript, as custom elements that load on the pages that use them, or as an app that lives beside the site.

On the sites studied for this guide, most components were in the second pile: about 80% on one large Astro docs site. A site whose pages are mostly the third pile (a framework's own docs, with a live editor in most pages) is an app, and should stay one.

The [`component-docs`](https://github.com/reverentgeek/sitesquatch/tree/main/examples/sites/component-docs/) example is inspired by a real-world site: components in place of MDX, live examples with their source, and values read from Sass files. [`islands`](https://github.com/reverentgeek/sitesquatch/tree/main/examples/sites/islands/) shows interactive parts as custom elements.

## Is ssqch a fit?

| The site is | Then |
| --- | --- |
| A blog, docs or marketing site with a few interactive widgets | Yes: content and templates in ssqch, widgets as React islands with `reactPlugin()` or as custom elements |
| Docs where every page embeds a live playground | Partly: the prose pages, with the playground as its own bundle that pages load |
| Server-rendered per request (auth, personalization, API routes, ISR) | No: ssqch only builds static files. Keep those routes where they are and move the static section. |
| A framework's own docs | No: they exist to show the framework |

Moving one section at a time works: build the docs or blog with ssqch into a folder, and let the host serve it under its path (`base: "/docs/"`).

## Content

| Astro, Next.js, Gatsby | SiteSquatch |
| --- | --- |
| Markdown with YAML front matter | The same. `title`, `description`, `date`, `tags` are read as they are. |
| A page with no date of its own | Its file's time in ssqch, which a checkout or a save moves: dates and the order of lists change from one build to the next, and on each save `ssqch serve` renders the pages that show it (every page that reads collections, when the site's code sorts by dates). `dateFallback: "git"` gives it its last commit's date (`ssqch scout` counts the pages that have none) |
| Content collections with a Zod schema (`src/content/config.ts`) | `schemas` in the config: `{ posts: { fields: { title: "string", date: "date", tags: "string[]" } } }`, checked on every build, with types from `ssqch types` |
| `getCollection("blog")`, GraphQL page queries, `getStaticProps` | `collections.<tag>` in templates, custom `collections` in the config, and `_data/*.js` files that fetch or read whatever the query did |
| `getStaticPaths`, `[slug].astro`, `createPages` | Pagination over data with a `permalink` per item: one template, one page per entry |
| Remote data at build time | `fetch()` in a data file, with `{ cache: "1h" }` so rebuilds don't refetch |
| File-based routing (`src/pages/about.astro`) | The same idea: `src/about.md` is `/about/`. `permalink` overrides it. |
| `:::tip` containers (Starlight) | The same syntax, built in |
| `{#custom-id}` on headings, `[[toc]]` | `{#custom-id}` works; the table of contents is `toc(page.headings)` in the layout |
| Code blocks with Shiki, line highlighting `{1,3}`, titles | `markdown: { highlight: true }`, `{1,3}` in the fence's info string; a `fence` render hook for titles and copy buttons |
| Extra Shiki languages (Astro `shikiConfig.langs`) | `markdown: { highlight: { languages } }`: an alias (`mdx: "markdown"`), a function that returns tokens, or a `.sublime-syntax` file. Shiki's TextMate JSON grammars don't load as they are (`ssqch docs languages`) |
| Twoslash, or anything that needs a compiler at build time | A `beforeBuild` command that writes HTML or JSON for templates to include |
| `<Image>` / `gatsby-plugin-image` | `imagePlugin()`: every `<img>`, including Markdown images, becomes a responsive `<picture>` |
| Astro's image `quality` (`<Image quality="high">`) | `imagePlugin()`'s `webpQuality`, `avifQuality` and `jpegQuality`: sharp's numbers, as Astro's are, one for each format across the site, with nothing per image. Astro's `low`, `mid`, `high` and `max` are 25, 50, 80 and 100. An image with no `quality` got sharp's defaults, so `imagePlugin({ formats: ["webp"], webpQuality: 80 })` is close to Astro's WebP (ssqch's own is 75). For other formats sharp's are `avifQuality: 50` with `avifEffort: 4`, and `jpegQuality: 80`, though ssqch writes JPEG with mozjpeg, so the same number isn't the same file ([Images](https://sitesquatch.dev/docs/plugins/index.md#images)) |
| `@astrojs/rss`, `gatsby-plugin-feed` | `feedPlugin({ url })` from `ssqch/rss`: an Atom or RSS feed of a collection, no template ([A feed for a blog](https://sitesquatch.dev/docs/plugins/index.md#a-feed-for-a-blog)) |
| i18n routing | Not built in: a folder per language, as [Multilingual sites](https://sitesquatch.dev/docs/multilingual/index.md) does, with the `multilingual` example to copy |

## MDX and components

MDX mixes Markdown with JSX. A site whose components are React keeps them: `reactPlugin()` from `ssqch/react` renders the components a `.md` page imports (`import Callout from "../components/Callout.jsx"`, then `<Callout type="warning">`), with JSX props and children, using the site's own React, react-dom and esbuild, and `hydrate` runs the interactive ones in the browser as islands ([React components](https://sitesquatch.dev/docs/plugins/index.md#react-components)). Rename `.mdx` pages to `.md`; MDX's other syntax (`{expressions}` in text, `export`) needs MDX itself, as an engine ([MDX as written](https://sitesquatch.dev/docs/trailheads/from-docusaurus/index.md#mdx-as-written)).

Without React, the tags can stay: `<Callout type="warning">` renders `_includes/components/Callout.*`, a template in any engine, which gets `component.props` and `component.content` ([components](https://sitesquatch.dev/docs/templates/index.md)). Three things change in the page: `import` lines and `{/* */}` comments print as text, so they come out; Markdown inside a tag needs a blank line after the opening tag and before the closing one; and a Markdown page runs through a template language first (Jinja by default), code blocks too, so a sample with `style={{ color: "red" }}` stops the build. `markdownEngine: false` turns that off, for a site whose pages have no template tags of their own.

A page can call the template language instead. With `markdownEngine: "edge"`, an Edge component reads most like MDX:

```mdx
<Callout type="warning" title="Careful">
  This **cannot** be undone.
</Callout>
```

```md
@component('components/callout', { type: 'warning', title: 'Careful' })
This **cannot** be undone.
@end
```

or, for block content, a container, which keeps the page plain Markdown:

```md
:::warning[Careful]
This **cannot** be undone.
:::
```

| Component | Becomes |
| --- | --- |
| A layout (`<BaseLayout>`, `layout.tsx`) | A layout in `_includes/`, chosen by `layout` in front matter or directory data |
| A presentational component with props (`<Card title>`) | A Jinja macro (`{% macro card(title) %}`, with `caller()` for its body), an Edge component (`_includes/components/card.edge`, with `$props` and slots), or a Handlebars partial |
| A component that wraps Markdown (`<Aside>`, `<Tabs>`) | A container: `_includes/containers/aside.jinja` gets the rendered body as `container.content` |
| Something that changes how Markdown elements render (`components={{ a, h2, pre }}`) | Render hooks: `_includes/hooks/link.*`, `heading.*`, `fence.*` |
| A component that reads data (`Astro.glob`, a `useData()` composable) | The template reads the same data: `collections`, `_data`, front matter |
| `import` of a JSON or YAML file in a page | A file in `_data/`, available by name |
| Styles scoped to a component | A class and a stylesheet; `sassPlugin()` if you use Sass |
| A React component with state or effects | The same component, as an island: `reactPlugin({ hydrate: { Counter: "visible" } })` |
| A Vue component | `vuePlugin()` from `ssqch/vue`, the same way |
| A Svelte, Solid or other component with state or effects | A custom element (below) |

A codemod is worth running when components are used hundreds of times: the one below makes them containers.

### MDX codemod

This is for a site moving its components to containers, so its pages are plain Markdown again. A site keeping React components with `reactPlugin()` doesn't need it. Save it as `codemod.mjs`, put the site's components in `CONTAINERS`, commit, and run `node codemod.mjs src` with the pages' folder. With `CONTAINERS = {}` it only takes out imports and comments and renames the pages, for a site keeping its tags with component templates.

- Each `.mdx` file becomes a `.md` file beside it, and the `.mdx` one is deleted. A page whose `.md` is there already is skipped.
- `import` lines and `{/* */}` comments come out. Code blocks and inline code are left as they are.
- A mapped component on lines of its own becomes a container, its body dedented, with more colons around one that holds others.
- Attributes become the container's arguments: `count={3}` is `count=3`, `open={true}` is `open`, `open={false}` is left out (the text `false` would count as true), and a list written as JSON (`tags={["a", "b"]}`) is `tags='["a","b"]'`.
- A link around one card (`<a href="/trails/">` or `<Link to="/trails/">`, with no other attribute) becomes the card's `href`.
- What it can't do safely it leaves and lists by file and line: a component in a line of text or with no container, a prop that's a variable or a function, `{expressions}` and `export`.

```js
// node codemod.mjs src: each .mdx page becomes a .md page, its components containers
import { existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import path from "node:path";

// The site's components, and the container each becomes (_includes/containers/<name>.*).
const CONTAINERS = { Aside: "aside", Card: "card", CardGrid: "cards", Tabs: "tabs", TabItem: "tab" };

const ATTR = /\s*([A-Za-z_][\w:.-]*)(?:=("[^"]*"|'[^']*'|\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}))?/y;
const NAMES = [...Object.keys(CONTAINERS), "a", "Link"].join("|");

// Code is put aside first, so nothing in it changes. Lines inside a fence are marked apart.
function mask(text) {
	const kept = [];
	const keep = (code, mark = "\u0000") => mark + (kept.push(code) - 1) + mark;
	let fence, quoted;
	const lines = text.split("\n").map((line) => {
		// A blockquote's `>` is before a fence's line only when the fence is in one.
		const [, indent, rest] = (fence && !quoted ? /^([ \t]*)(.*)$/ : /^([ \t]*(?:> ?)*)(.*)$/).exec(line);
		if (fence) {
			if (rest.startsWith(fence) && /^(`+|~+)\s*$/.test(rest)) fence = undefined;
			return indent + keep(rest, "\u0001");
		}
		const open = /^(`{3,}(?=[^`]*$)|~{3,})/.exec(rest);
		if (!open) return line.replace(/(`+)(?:(?!\1).)+\1/g, (code) => keep(code));
		fence = open[1];
		quoted = indent.includes(">");
		return indent + keep(rest);
	});
	return { text: lines.join("\n"), restore: (out) => out.replace(/([\u0000\u0001])(\d+)\1/g, (_, mark, n) => kept[n]) };
}

// The element whose `<` is at `start`: its attributes, what's inside, and where it ends.
function element(text, start) {
	const name = /^<([A-Za-z]\w*)(?=[\s/>])/.exec(text.slice(start))?.[1];
	if (!name) return undefined;
	const attrs = [];
	ATTR.lastIndex = start + name.length + 1;
	let at = ATTR.lastIndex;
	for (let m; (m = ATTR.exec(text)); at = ATTR.lastIndex) attrs.push([m[1], m[2]]);
	const close = /\s*(\/?)>/y;
	close.lastIndex = at;
	const end = close.exec(text);
	if (!end) return undefined;
	const open = close.lastIndex;
	if (end[1]) return { name, attrs, body: "", end: open };
	const tags = new RegExp(`<${name}(?=[\\s/>])|</${name}\\s*>`, "g");
	tags.lastIndex = open;
	for (let depth = 1, m; (m = tags.exec(text)); ) {
		if (m[0].startsWith("</")) depth--;
		else {
			const inner = element(text, m.index);
			if (!inner) return undefined;
			tags.lastIndex = inner.end;
		}
		if (depth === 0) return { name, attrs, body: text.slice(open, m.index), end: tags.lastIndex };
	}
	return undefined;
}

// JSX attributes as a container's arguments, which have no escapes and fit on one line.
function args(attrs) {
	const out = [];
	for (const [name, raw] of attrs) {
		const cant = () => { throw new Error(`\`${name}=${raw}\` can't be a container's argument`); };
		const quoted = (value) => {
			const line = value.replace(/\s+/g, " ");
			if (!line.includes('"')) out.push(`${name}="${line}"`);
			else if (!line.includes("'") && !/^\s*[{[]/.test(line)) out.push(`${name}='${line}'`);
			else cant();
		};
		if (name.includes(":") || name.includes(".")) cant();
		else if (raw === undefined) out.push(name);
		else if (raw[0] !== "{") quoted(raw.slice(1, -1));
		else {
			const code = raw.slice(1, -1).trim();
			const string = /^(["'`])((?:(?!\1)[^\\])*)\1$/.exec(code);
			if (code === "true") out.push(name);
			else if (code === "false") continue; // the text "false" would count as true
			else if (/^-?\d+(\.\d+)?$/.test(code)) out.push(`${name}=${code}`);
			else if (string && !code.includes("${")) quoted(string[2]);
			else {
				let json;
				try { json = JSON.stringify(JSON.parse(code)); } catch { cant(); }
				if (!/^[[{]/.test(json) || json.includes("'")) cant();
				out.push(`${name}='${json}'`);
			}
		}
	}
	return out.map((arg) => " " + arg).join("");
}

// Indented four spaces, Markdown is a code block: take the body's own indent off.
function dedent(body) {
	const sameLine = !/^[ \t]*\n/.test(body);
	const lines = body.replace(/^(?:[ \t]*\n)+/, "").replace(/\s+$/, "").split("\n");
	const indents = lines.slice(sameLine ? 1 : 0).filter((l) => l.trim() && !l.trim().startsWith("\u0001")).map((l) => /^[ \t]*/.exec(l)[0].length);
	const cut = indents.length ? Math.min(...indents) : 0;
	return lines.map((l) => l.slice(Math.min(cut, /^[ \t]*/.exec(l)[0].length)));
}

function convert(text, notes) {
	const starts = new RegExp(`^([ \\t]*)<(?:${NAMES})(?=[\\s/>])`, "gm");
	let out = "", done = 0;
	for (let m; (m = starts.exec(text)); ) {
		let found = element(text, m.index + m[1].length);
		// A tag in a line of text isn't a block: leave it.
		if (!found || !/^[ \t]*(\n|$)/.test(text.slice(found.end))) continue;
		const end = found.end;
		const extra = [];
		if (found.name === "a" || found.name === "Link") {
			// A link around one card: the card takes the link's address.
			const body = found.body.trim();
			const card = element(body, 0);
			const [to] = found.attrs;
			if (!card || !Object.hasOwn(CONTAINERS, card.name) || card.end !== body.length || found.attrs.length !== 1 || !["href", "to"].includes(to[0])) {
				// A container inside a link would be cut in two: leave the link whole.
				if (Object.keys(CONTAINERS).some((n) => new RegExp(`<${n}(?=[\\s/>])`).test(found.body))) {
					notes.add(`<${found.name}> around components: left as it is`);
					starts.lastIndex = end;
				}
				continue;
			}
			extra.push(["href", to[1]]);
			found = card;
		}
		let list;
		try { list = args([...extra, ...found.attrs]); } catch (e) { notes.add(`<${found.name}>: ${e.message}`); starts.lastIndex = end; continue; }
		const body = found.body.trim() ? dedent(convert(found.body, notes)) : [];
		// An outer container needs more colons than any inside it.
		const colons = ":".repeat(Math.max(2, ...body.map((l) => /^\s*(:{3,})/.exec(l)?.[1].length ?? 0)) + 1);
		// A container indented outside a list item isn't read, so only a list's indent stays.
		const above = text.slice(0, m.index).split("\n").findLast((l) => l.trim() && /^[ \t]*/.exec(l)[0].length < m[1].length);
		const indent = /^\s*([-*+]|\d+[.)])\s/.test(above ?? "") ? m[1] : "";
		// Blank lines keep a marker out of an HTML block, where it wouldn't be read.
		const lines = ["", `${colons} ${CONTAINERS[found.name]}${list}`, "", ...body, "", colons, ""];
		out += text.slice(done, m.index) + lines.map((l) => l && indent + l).join("\n");
		done = starts.lastIndex = end;
	}
	return out + text.slice(done);
}

const root = process.argv[2] ?? "src";
for (const file of readdirSync(root, { recursive: true }).filter((f) => f.endsWith(".mdx") && !f.includes("node_modules")).sort()) {
	const from = path.join(root, file), to = from.slice(0, -1);
	if (existsSync(to)) { console.log(`${from}: skipped, ${to} is there already`); continue; }
	const source = readFileSync(from, "utf8").replace(/\r\n/g, "\n");
	const front = /^---\n[\s\S]*?\n---\n/.exec(source)?.[0] ?? "";
	const code = mask(source.slice(front.length));
	const cleaned = code.text
		.replace(/^import\s+(?:[\w$*{}\s,]+\sfrom\s+)?(["'])[^"'\n]+\1;?[ \t]*(?:\n|$)/gm, "")
		.replace(/^[ \t]*\{\/\*(?:(?!\*\/)[\s\S])*\*\/\}[ \t]*\n/gm, "")
		.replace(/\{\/\*(?:(?!\*\/)[\s\S])*\*\/\}/g, "");
	const notes = new Set();
	const result = convert(cleaned, notes).replace(/\n{3,}/g, "\n\n").replace(/^\n+/, front && "\n").replace(/\n+$/, "\n");
	writeFileSync(to, front + code.restore(result));
	rmSync(from);
	// What's left for a person, by its line in the new file.
	const first = front.split("\n").length;
	result.split("\n").forEach((line, i) => {
		for (const [found] of line.matchAll(/<[A-Z][\w.]*|(?<!=)\{(?![#.])[^}]*\}?|^export\b/g)) console.log(`${to}:${first + i}: ${code.restore(found)} left as it is`);
	});
	for (const note of notes) console.log(`${to}: ${note}`);
}
```

On a page it reads:

```mdx
---
title: Cedar Trail
---
import { Card } from "../components/Card.astro";

{/* checked by a ranger */}

<a href="/trails/old-growth/">
  <Card title="Old Growth" count={3}>
    The **long** way.
  </Card>
</a>
```

and writes:

```md
---
title: Cedar Trail
---

::: card href="/trails/old-growth/" title="Old Growth" count=3

The **long** way.

:::
```

Give each container a template, which gets the arguments as `container.props` and the body as `container.content` ([Containers](https://sitesquatch.dev/docs/markdown/index.md)); one without a template is a `<div>` that prints its arguments as a title. The card, for one that may or may not be a link:

```jinja
{# src/_includes/containers/card.jinja #}
<{{ "a" if container.props.href else "div" }} class="card"{% if container.props.href %} href="{{ container.props.href }}"{% endif %}>
  {% if container.props.title %}<p class="card-title">{{ container.props.title }}</p>{% endif %}
  {{ container.content | safe }}
</{{ "a" if container.props.href else "div" }}>
```

Then set `markdownEngine: false` (above) and build: a tag that's left with no template is a warning that names its pages.

## Interactive parts

React components run in the browser with `reactPlugin()`'s `hydrate` (`"load"`, `"idle"` or `"visible"`, for all of them or by name), as `client:load`, `client:idle` and `client:visible` did. For other frameworks, or none, write each one as a custom element, with what a visitor sees before (or without) JavaScript inside the tag:

```html
<like-button count="3"><a href="/likes/">3 likes</a></like-button>
```

`elementsPlugin()` from `ssqch/elements` loads `src/elements/like-button.js` on the pages that have the tag, and on no others, which is what `client:load` did. The other loading directives map too:

| Astro | SiteSquatch |
| --- | --- |
| `client:load` | The default: the script loads with the page |
| `client:idle` | `ssqch:load="idle"` on the tag |
| `client:visible` | `ssqch:load="visible"` |
| `client:only`, a component with no server-rendered HTML | An element with a fallback inside it (a link, a static version, or nothing) |
| `dynamic(() => ..., { ssr: false })` (Next.js) | The same |

An element's script can import your existing framework code: a Preact, Lit or Vue component mounted inside `connectedCallback` is still an island, bundled by your own esbuild or Vite step into the elements folder (`beforeBuild: { run: "esbuild ..." }`). What goes away is hydrating the whole page.

What doesn't have an equivalent: client-side routing between pages (links are ordinary page loads; the browser's View Transitions cover the animation), state shared across pages in memory (use `localStorage`, as the tabs in `ssqch init --starter docs` do), and server components.

## Per framework

- **Astro:** `.astro` components are the closest to templates: the frontmatter script becomes data (front matter, `_data`, or a filter) and the template below it becomes Jinja or Edge. Starlight sites map onto `ssqch init --starter docs`. An `.mdx` page with React components keeps them: rename it to `.md`, keep its imports, and take the `client:*` directives off the tags, since `hydrate` says which components run in the browser. A `client:visible` left on a tag is ignored, and the build warns, naming the `hydrate` setting that does what it did. Before:

  ```mdx
  ---
  title: Cedar Trail
  layout: ../layouts/Trail.astro
  ---
  import Counter from "../components/Counter.jsx";

  <Counter client:visible start={3} label="Pine cones" />
  ```

  After, as `src/trails/cedar.md`, with `layout: trail.jinja` (the `.astro` layout as a template) and the config:

  ```md
  import Counter from "../components/Counter.jsx";

  <Counter start={3} label="Pine cones" />
  ```

  ```js
  import { reactPlugin } from "ssqch/react";

  export default defineConfig({ plugins: [reactPlugin({ hydrate: { Counter: "visible" } })] });
  ```

  The page gets the button as HTML, wrapped in `<ssqch-react data-hydrate="visible">`, and one script that runs it when it scrolls into view. `client:load` and `client:idle` are `"load"` and `"idle"`; `client:only` has no equivalent, since every component renders on the server first.
- **Next.js:** only statically exported pages (`output: "export"`) move. `next/link` and `next/image` become `<a>` and `<img>`; `getStaticProps` becomes a data file, and `generateStaticParams` pagination. `public/` is `passthrough: [{ public: "/" }]`. `ssqch scout` lists the route files and each of these with counts. A route's page (`app/trails/page.jsx`) becomes a template, and the components it renders stay React: `components` makes them tags in every page and layout without an import, and a `"use client"` component is one to hydrate:

  ```js
  // ssqch.config.js
  import { reactPlugin } from "ssqch/react";

  export default defineConfig({
    plugins: [reactPlugin({ components: { Counter: "src/components/Counter.jsx" }, hydrate: { Counter: "visible" } })],
  });
  ```

  ```jinja
  {# src/trails/index.jinja, from app/trails/page.jsx #}
  <main>
    <h1>{{ title }}</h1>
    <Counter start={3} label="Trails hiked" />
  </main>
  ```
- **Gatsby:** source plugins become data files (`fetch`, or reading files with `node:fs`), page queries become collections, and `gatsby-node.js` `createPages` becomes pagination. `ssqch scout` lists them with counts, and each `gatsby-*` plugin with ssqch's way. The usual remark plugins:

| Gatsby | SiteSquatch |
| --- | --- |
| `static/` | `passthrough: [{ static: "/" }]`; `imagePlugin()` finds the pictures there by their URL |
| `gatsby-remark-prismjs` | `markdown: { highlight: { classes: "prism" } }` and the site's Prism theme; a `fence` render hook for the `<div class="gatsby-highlight">` around each block |
| `gatsby-remark-katex` | `markdown: { math: true }`, with `render: "katex"` to render at build time ([Math](https://sitesquatch.dev/docs/markdown/index.md#math-with-katex-or-mathjax)) |
| `gatsby-remark-autolink-headers` | Heading ids are built in; the link inside each heading is a `heading` render hook |
| `gatsby-remark-images` | `imagePlugin()`. It encoded at `quality: 50` unless the site set one, which is lower than ssqch's defaults, so the bytes differ: set `imagePlugin()`'s qualities to match while comparing |
| `gatsby-remark-smartypants` | `markdown: { smartPunctuation: true }` |
| `gatsby-remark-responsive-iframe` | CSS (`aspect-ratio`) on the embeds, or a transform |
| `gatsby-plugin-offline` | A service worker of the site's own, written by Workbox's CLI in `afterBuild` |

Gatsby's own builds vary: its feed has the build's time and posts with the same date in no fixed order, and its sitemap's order changes from build to build. Build the reference with `ssqch baseline "npm run build" --from public --runs 20` and compare with `.cache/ssqch/baseline/ref-common`.

## Beyond the pages

Four things hide outside the Markdown. `ssqch scout` lists Next.js's `getStaticProps`, `getStaticPaths` and `generateStaticParams`, Gatsby's `createPages` and `gatsby-*` plugins, and Astro's `@astrojs/*` packages, but not Astro's `getStaticPaths` files, its other integrations, path aliases or env variables. Find them in the old site:

```sh
git grep -n -E 'getStaticPaths|generateStaticParams|createPages?'
git grep -n -E 'integrations|plugins' -- 'astro.config.*' 'next.config.*' 'gatsby-config.*'
git grep -n -A8 '"paths"' -- '*config.json'
git grep -n -E 'import\.meta\.env|process\.env'
```

- **`getStaticPaths` and its kin:** each file is a template paginated over its data, with a `permalink` per item.
- **Integrations and plugins:** note what each one writes or changes, and find its row above. One that's missed often shows in `ssqch diff` as a removed file (a sitemap, a search index).
- **Path aliases:** Node doesn't read `tsconfig.json`'s `paths`, so a data file that imports `@/lib/trails.js` fails (`package "@/lib" isn't installed`). Use a relative path, or Node's own aliases in `package.json` (`"imports": { "#lib/*": "./src/lib/*" }`, then `import { trails } from "#lib/trails.js"`), with the file's extension either way. A component that `reactPlugin()` bundles takes `esbuild: { alias }`.
- **Env variables:** `import.meta.env` is Vite's. A data file reads `process.env` (`_data/api.js` with `export default { url: process.env.PUBLIC_API_URL }`, then `{{ api.url }}`), and `ssqch.env` says whether it's a production build. ssqch doesn't read `.env` files by itself, so load one in the config:

```js
// ssqch.config.js
import { existsSync } from "node:fs";

const env = new URL(".env", import.meta.url);
if (existsSync(env)) process.loadEnvFile(env);
```

## Checking the move

Build both and compare the output:

```sh
ssqch diff dist-old dist --ignore 'data-astro-[\w-]+(="[^"]*")?' --ignore '<!--\[?-->'
```

For Gatsby, its own markup: `--ignore ' data-react-helmet="true"' --ignore ' id="gatsby-[\w-]+"' --ignore '<style data-href="[^"]*"[^>]*>'` (each checked on a Gatsby 5 build), and `ssqch diff --text` to compare the words while the markup is a different theme's.

`ssqch diff` compares tags and text, so framework noise shows up as markup-only differences: scoped-style attributes, hydration markers, inlined state. `--ignore` takes patterns for those. What's left is what a visitor would notice: the text of each page, its headings and ids, and its links.

**Only dates:** a file whose changes are all dates or years says `only dates changed (2025 -> 2026)`, and the end of the report counts them (`All 12 changed files differ only in dates or years`). The usual cause is a page with no `date` of its own (the [Content](#content) table), dated by its file's time: give it a `date` or set `dateFallback: "git"`, and write a copyright year as `{{ now() | dateformat("%Y") }}`.
