From a6cadf8a79f2e41d7b62df90761d7d0099ff8861 Mon Sep 17 00:00:00 2001 From: Friedjoff Trautwein Date: Mon, 28 Mar 2022 17:56:47 +0200 Subject: [PATCH] add example code --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c23a214..a6663a3 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,25 @@ Generate Nginx routes configuration file for Next.js static HMTL export. +This [NPM package](https://www.npmjs.com/package/next-nginx-routes) allows you to convert Next.js routes like: + +```json +{ + "page": "/[foo]", + "regex": "^/([^/]+?)(?:/)?$", + "routeKeys": { "foo": "foo" }, + "namedRegex": "^/(?[^/]+?)(?:/)?$" +} +``` + +... into Nginx routes like: + +```nginx +location ~ ^/([^/]+?)(?:/)?$ { + try_files /[foo].html /index.html; +} +``` + ## Getting started ### Installation @@ -28,7 +47,7 @@ yarn run export ### Include Nginx configuration file -Finally include the generated configuration file `next-routes.conf` and the Next.js output in your Nginx site configuration file. See `example` folder for a minimal Docker example. +Finally include the generated configuration file `next-routes.conf` and the Next.js output in your Nginx site configuration file. ## Requirements @@ -37,4 +56,5 @@ Finally include the generated configuration file `next-routes.conf` and the Next ## More -- TODO: blog post +- See [`example`](https://github.com/geops/next-nginx-routes/tree/main/example) folder for a minimal Docker example. +- Read more about this approach in our [blog post](https://geops.ch/en/blog/next-nginx-routes).