Skip to content

Instantly share code, notes, and snippets.

@AndrewIngram
Last active January 9, 2019 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewIngram/04c1901eb5c461961ab3f6ae68d1ae98 to your computer and use it in GitHub Desktop.
Save AndrewIngram/04c1901eb5c461961ab3f6ae68d1ae98 to your computer and use it in GitHub Desktop.
Router API Idea
import { routes, include } from "@framework/router";
import { relayView, xmlView } from "@framework/engine";
const gbRoutes = routes(
route({ path: "/", view: "./views/gb/HomepageGb" }),
route({ path: "/scooter/", view: "./views/gb/ScooterGb" }),
route({ path: "/car/", view: "./views/gb/CarGb" }),
route({ path: "/private-hire/", view: "./views/gb/PrivateHireGb" }),
route({ path: "/blog/:slug/", view: "./views/BlogPost" })
);
const esRoutes = routes(
route({ path: "/es/", view: "./views/gb/HomepageEs" }),
route({ path: "/es/scooter/", view: "./views/gb/ScooterEs" }),
route({ path: "/es/car/", view: "./views/gb/CarEs" }),
route({ path: "/es/private-hire/", view: "./views/gb/PrivateHireEs" }),
route({ path: "/es/blog/:slug/", view: "./views/BlogPost" })
);
export const config = {
defaultEngine: relayView,
notFound: { view: "./views/NotFound", engine: relayView }
};
export default routes(
include(esRoutes, { country: "es", language: "es" }),
route({
path: "/sitemap.xml",
view: "./sitemap/generateSitemap",
engine: xmlView,
serverOnly: true
}),
include(gbRoutes, { country: "gb", language: "en" })
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment