From ef968e8e75a0d60191921c9e4a54f48101fe5c50 Mon Sep 17 00:00:00 2001 From: MacRat Date: Sun, 24 Mar 2024 21:21:38 +0900 Subject: [PATCH 1/2] fix(builder): fix not found page handling --- builder/autoindex.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/builder/autoindex.go b/builder/autoindex.go index a10facb3..31bfea04 100644 --- a/builder/autoindex.go +++ b/builder/autoindex.go @@ -581,7 +581,7 @@ func (g *IndexGenerator) generateConfig(dst fs.Writable, as ArticleList, conf Co Continue bool `json:"continue,omitempty"` } - routes := make([]Route, 0, len(as)+len(conf.Redirects)+len(conf.Headers)+4) + routes := make([]Route, 0, len(as)+len(conf.Redirects)+len(conf.Headers)+5) routes = append(routes, Route{ Src: "/(.*)/", @@ -636,6 +636,12 @@ func (g *IndexGenerator) generateConfig(dst fs.Writable, as ArticleList, conf Co }) } + routes = append(routes, Route{ + Handle: "miss", + Dest: "/404.html", + Status: 404, + }) + err = json.NewEncoder(output).Encode(map[string]any{ "version": 3, "routes": routes, From abc72d739caa0df09f79d11b197850adfc37e4a9 Mon Sep 17 00:00:00 2001 From: MacRat Date: Sun, 24 Mar 2024 21:41:30 +0900 Subject: [PATCH 2/2] fix(builder): fix syntax of config for Vercel --- builder/autoindex.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/builder/autoindex.go b/builder/autoindex.go index 31bfea04..db6891c6 100644 --- a/builder/autoindex.go +++ b/builder/autoindex.go @@ -576,12 +576,13 @@ func (g *IndexGenerator) generateConfig(dst fs.Writable, as ArticleList, conf Co Src string `json:"src,omitempty"` Dest string `json:"dest,omitempty"` Handle string `json:"handle,omitempty"` + Check bool `json:"check,omitempty"` Headers map[string]string `json:"headers,omitempty"` Status int `json:"status,omitempty"` Continue bool `json:"continue,omitempty"` } - routes := make([]Route, 0, len(as)+len(conf.Redirects)+len(conf.Headers)+5) + routes := make([]Route, 0, len(as)+len(conf.Redirects)+len(conf.Headers)+6) routes = append(routes, Route{ Src: "/(.*)/", @@ -638,7 +639,10 @@ func (g *IndexGenerator) generateConfig(dst fs.Writable, as ArticleList, conf Co routes = append(routes, Route{ Handle: "miss", + }, Route{ + Src: "/(.*)", Dest: "/404.html", + Check: true, Status: 404, })