From: Ardis Lu Date: Sun, 30 Jan 2022 06:36:29 +0000 (-0800) Subject: Initial commit X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=4859ea84029c8df36599333a43953eea199a8025;p=minimal-routing Initial commit --- 4859ea84029c8df36599333a43953eea199a8025 diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf6a9a4 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# minimal-routing + +Demo website for the minimum JavaScript required to implement client-side routing. + +## Web server configuration + +This demo website assumes that the web server has been configured to serve `index.html` on all routes **EXCEPT** for the special path: `/errors/404.html`. For `/errors/404.html`, the web server must respond with a `404 Not Found` error and the file `/errors/404.html`. + +Note: this file path is intentionally nested in a folder because some static site hosts (like [Cloudflare Pages](https://developers.cloudflare.com/pages/platform/serving-pages)) use a top-level `404.html` page as a flag to override the desired behavior of serving `index.html` on all routes. + +The desired behavior can be replicated locally using the npm package [local-web-server](https://www.npmjs.com/package/local-web-server): + +``` +ws --spa index.html +``` diff --git a/errors/404.html b/errors/404.html new file mode 100644 index 0000000..54dc4ca --- /dev/null +++ b/errors/404.html @@ -0,0 +1,17 @@ + + + + + + + + + 404 Not Found + + + +

404 Not Found

+

The requested page does not exist.

+ + + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..46dcce4 --- /dev/null +++ b/index.html @@ -0,0 +1,88 @@ + + + + + + + + + minimal-routing + + + +
+ + + + +
+ +
+
+ Hello from the home page! +
+
+ Hello from page 1! +
+
+ Hello from page 2! +
+
+ Hello from page 3! +
+
+ + + + + \ No newline at end of file