completely refactored utilities for direct rendering, killed iframes
This commit is contained in:
parent
12dd2c6c06
commit
f08a7456ee
37 changed files with 1824 additions and 1350 deletions
|
|
@ -23,6 +23,8 @@ import { NextResponse, NextRequest } from "next/server";
|
|||
/** Directus base (used to remotely validate the token after restarts). */
|
||||
const DIRECTUS = (process.env.NEXT_PUBLIC_API_BASE_URL || process.env.DIRECTUS_URL || "").replace(/\/$/, "");
|
||||
|
||||
type MapResult = { pathname: string; query?: Record<string, string> };
|
||||
|
||||
/** Helper: does the path start with any prefix in a list? */
|
||||
function startsWithAny(pathname: string, prefixes: string[]) {
|
||||
return prefixes.some((p) => pathname.startsWith(p));
|
||||
|
|
@ -176,8 +178,6 @@ import { NextResponse, NextRequest } from "next/server";
|
|||
return NextResponse.next();
|
||||
}
|
||||
|
||||
type MapResult = { pathname: string; query?: Record<string, string> };
|
||||
|
||||
function legacyMap(pathname: string): MapResult | null {
|
||||
// Never map the homepage, and if we’re already inside the portal, don’t remap again.
|
||||
if (pathname === "/" || pathname.startsWith("/portal")) return null;
|
||||
|
|
@ -192,6 +192,8 @@ import { NextResponse, NextRequest } from "next/server";
|
|||
[/^\/co2-galvo-settings\/([^/]+)\/?$/i, (m) => ({ pathname: "/portal/laser-settings", query: { t: "co2-galvo", id: m[1] } })],
|
||||
[/^\/co2-gantry-settings\/([^/]+)\/?$/i, (m) => ({ pathname: "/portal/laser-settings", query: { t: "co2-gantry", id: m[1] } })],
|
||||
[/^\/co2gantry-settings\/([^/]+)\/?$/i, (m) => ({ pathname: "/portal/laser-settings", query: { t: "co2-gantry", id: m[1] } })],
|
||||
[/^\/laser-toolkit\/?$/i, { pathname: "/portal/utilities", query: { t: "laser-toolkit" } }],
|
||||
[/^\/files\/?$/i, { pathname: "/portal/utilities", query: { t: "files" } }],
|
||||
|
||||
// Materials
|
||||
[/^\/materials\/([^/]+)\/?$/i, (m) => ({ pathname: "/portal/materials", query: { t: "materials", id: m[1] } })],
|
||||
|
|
@ -204,12 +206,21 @@ import { NextResponse, NextRequest } from "next/server";
|
|||
|
||||
// 2) LIST PAGES: legacy lists → portal lists (with tab param) or sections
|
||||
const listRules: Array<[RegExp, MapResult]> = [
|
||||
// ── Canonicals for direct, public URLs ───────────────────────────────────
|
||||
// https://makearmy.io/background-remover → /portal/utilities?t=background-remover
|
||||
[/^\/background-remover\/?$/i, { pathname: "/portal/utilities", query: { t: "background-remover" } }],
|
||||
|
||||
// https://makearmy.io/buying-guide → /portal/buying-guide
|
||||
[/^\/buying-guide\/?$/i, { pathname: "/portal/buying-guide" }],
|
||||
|
||||
// ── Existing rules (keep your current ones below) ────────────────────────
|
||||
// Laser settings lists
|
||||
[/^\/fiber-settings\/?$/i, { pathname: "/portal/laser-settings", query: { t: "fiber" } }],
|
||||
[/^\/uv-settings\/?$/i, { pathname: "/portal/laser-settings", query: { t: "uv" } }],
|
||||
[/^\/co2-galvo-settings\/?$/i, { pathname: "/portal/laser-settings", query: { t: "co2-galvo" } }],
|
||||
[/^\/co2-ganry-settings\/?$/i, { pathname: "/portal/laser-settings", query: { t: "co2-gantry" } }], // typo catch
|
||||
[/^\/co2-gantry-settings\/?$/i, { pathname: "/portal/laser-settings", query: { t: "co2-gantry" } }],
|
||||
[/^\/co2ganry-settings\/?$/i, { pathname: "/portal/laser-settings", query: { t: "co2-gantry" } }], // typo catch variant (if needed)
|
||||
[/^\/co2gantry-settings\/?$/i, { pathname: "/portal/laser-settings", query: { t: "co2-gantry" } }], // old alias
|
||||
|
||||
// Materials lists
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue