diff --git a/src/modules/album/album.go b/src/modules/album/album.go index 13d42fa..9ebca26 100644 --- a/src/modules/album/album.go +++ b/src/modules/album/album.go @@ -43,10 +43,10 @@ func allAlbumsPage(c echo.Context) error { if isHtmxRequest { // return just a fragment - return utils.RenderTempl(c, http.StatusOK, albumsFragment(albums)) + return utils.RenderTempl(c, http.StatusOK, albumsFragment(albums, searchQuery)) } else { // return a full-blown html page - return utils.RenderTempl(c, http.StatusOK, allAlbumsTempl(albums)) + return utils.RenderTempl(c, http.StatusOK, allAlbumsTempl(albums, searchQuery)) } } diff --git a/src/modules/album/album.templ b/src/modules/album/album.templ index 29f680d..fa83a91 100644 --- a/src/modules/album/album.templ +++ b/src/modules/album/album.templ @@ -8,30 +8,41 @@ import ( ) // Renders a page with all albums passed to it -templ allAlbumsTempl(albums []utils.Album) { +templ allAlbumsTempl(albums []utils.Album, query string) { @utils.SkeletonTempl() { -
-

- Albums -

-
-
- -
-
-
-
+ @albumsFragment(albums, query) + } +} + +templ albumsFragment(albums []utils.Album, query string) { +
+

+ Albums +

+
+
+ +
+
+
+
+ if len(albums) == 0 { +

+ No albums found +

+ } else { for _, album := range albums { @index.AlbumCard(album) } @@ -40,20 +51,9 @@ templ allAlbumsTempl(albums []utils.Album) { No albums found

} -
+ }
- } -} - -templ albumsFragment(albums []utils.Album) { - for _, album := range albums { - @index.AlbumCard(album) - } - if len(albums) == 0 { -

- No albums found -

- } +
} // Renders the page of a single Album diff --git a/src/modules/index/index.templ b/src/modules/index/index.templ index edc7235..a5002ba 100644 --- a/src/modules/index/index.templ +++ b/src/modules/index/index.templ @@ -29,7 +29,9 @@ templ IndexTempl(albums []utils.Album) { templ AlbumCard(album utils.Album) {
- +
+ +