From 59929bb891ea9f3eee40d0cc79fe08bfc7cce65a Mon Sep 17 00:00:00 2001 From: rramiachraf <51409801+rramiachraf@users.noreply.github.com> Date: Wed, 1 May 2024 22:22:54 +0100 Subject: [PATCH] perf: tackle lighthouse issues --- handlers/handler.go | 5 ++++- views/album.templ | 2 +- views/head.templ | 1 + views/layout.templ | 2 +- views/lyrics.templ | 13 +++++++++++-- views/navbar.templ | 4 ++-- views/search.templ | 10 ++++++++-- 7 files changed, 28 insertions(+), 9 deletions(-) diff --git a/handlers/handler.go b/handlers/handler.go index f2a902f..e19b3c3 100644 --- a/handlers/handler.go +++ b/handlers/handler.go @@ -5,10 +5,10 @@ import ( "net/http" "github.com/a-h/templ" + gorillaHandlers "github.com/gorilla/handlers" "github.com/gorilla/mux" "github.com/rramiachraf/dumb/views" "github.com/sirupsen/logrus" - gorillaHandlers "github.com/gorilla/handlers" ) func New(logger *logrus.Logger) *mux.Router { @@ -18,6 +18,9 @@ func New(logger *logrus.Logger) *mux.Router { r.Use(gorillaHandlers.CompressHandler) r.Handle("/", templ.Handler(views.HomePage())) + r.HandleFunc("/robots.txt", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("User-agent: *\nDisallow: /\n")) + }) r.HandleFunc("/albums/{artist}/{albumName}", album(logger)).Methods("GET") r.HandleFunc("/images/{filename}.{ext}", imageProxy(logger)).Methods("GET") r.HandleFunc("/search", search(logger)).Methods("GET") diff --git a/views/album.templ b/views/album.templ index 5e61a04..3cb49fe 100644 --- a/views/album.templ +++ b/views/album.templ @@ -9,7 +9,7 @@ templ AlbumPage(a data.Album) { @layout(fmt.Sprintf("%s - %s", a.Artist, a.Name)) {