Skip to content

Preview: Serve footer destinations at directory URLs. - #5

Merged
JJJ merged 1 commit into
mainfrom
codex/fix-footer-preview-routes
Sep 8, 2026
Merged

JJJ merged 1 commit into
mainfrom
codex/fix-footer-preview-routes

Conversation

@JJJ

@JJJ JJJ commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Fix local footer navigation: Vite now serves the static Features, Download, CLI, Privacy, and Thanks pages at their directory URLs instead of falling back to the homepage.

Add a preview integration test with a separate temporary dependency cache so tests cannot disrupt the running preview. Audit every generated footer's local page and anchor targets.

Validation: npm test; git diff --check; browser navigation from Home to Privacy and CLI and back after the tests; public footer destinations returned HTTP 200.

Copilot AI lite review requested due to automatic review settings September 8, 2026 16:05
@JJJ
JJJ merged commit ac0e2b2 into main Sep 8, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The audit script currently computes internal target paths incorrectly (dropping dist), and the rewrite plugin doesn’t apply to vite preview without a preview-server hook.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Ensures local navigation to prerendered “footer destination” pages works by rewriting directory URLs to their corresponding index.html files during local serving, and adds automated checks around those routes and footer link targets.

Changes:

  • Add a Vite plugin that rewrites requests like /privacy/ → /privacy/index.html.
  • Add a local-server integration test covering the affected routes.
  • Extend the site audit script to validate footer link destinations/anchors across generated pages.
File summaries
File Description
vite.config.ts Registers the new static-page rewrite plugin alongside React.
scripts/static-pages.ts Implements middleware that rewrites specific directory URLs to index.html.
tests/static-pages.test.mjs Adds an integration test that exercises the rewrite behavior via a local Vite server.
scripts/audit-site.mjs Adds footer destination/link-target validation to the build audit.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/audit-site.mjs
Comment on lines +100 to +103
}
const target = path.join(dist, destination.pathname, "index.html");
const targetHtml = await readFile(target, "utf8");
if (destination.hash) assert.ok(targetHtml.includes(`id="${destination.hash.slice(1)}"`), `Missing footer anchor ${href}`);
Comment thread scripts/static-pages.ts
Comment on lines +4 to +20
export function staticPages(): Plugin {
return {
name: "pasted-static-pages",
configureServer(server) {
server.middlewares.use((request, _response, next) => {
const incoming = request as { url?: string };
if (incoming.url) {
incoming.url = incoming.url.replace(
/^\/(features|download|cli|privacy|thanks)\/?(?=\?|$)/,
"/$1/index.html",
);
}
next();
});
},
};
}
Comment on lines +6 to +16
import { createServer } from "vite";
import { staticPages } from "../scripts/static-pages.ts";

test("preview directory links serve their own pages instead of the SPA homepage", async () => {
const cacheDir = await mkdtemp(path.join(tmpdir(), "pasted-preview-test-"));
const server = await createServer({
cacheDir,
configFile: false,
plugins: [staticPages()],
server: { host: "127.0.0.1", port: 0 },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants