diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 990d6b4..3d8ad88 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -2,10 +2,14 @@ class ArtistsController < ApplicationController def show artist = Artist.find(params[:id]) albums = selected_albums(artist.albums, params[:album_type]).with_attached_cover.preload(:artist) - tracks = artist.tracks.popularity_ordered.limit(5) + tracks = artist.tracks.popularity_ordered.limit(5 * (params[:tracks_page].to_i + 1)) if turbo_frame_request? - render partial: "discography", locals: {artist:, albums:} + if params[:tracks_page].present? + render partial: "tracks", locals: {artist:, tracks:} + else + render partial: "discography", locals: {artist:, albums:} + end else render action: :show, locals: {artist:, albums:, tracks:} end diff --git a/app/views/artists/_tracks.html.erb b/app/views/artists/_tracks.html.erb new file mode 100644 index 0000000..69cc1d8 --- /dev/null +++ b/app/views/artists/_tracks.html.erb @@ -0,0 +1,15 @@ +<%# locals: (artist:, tracks:, page: params[:tracks_page]) -%> +<%= turbo_frame_tag dom_id(artist, :tracks), target: "_top" do %> + + + <% if page.blank? %> +
  • + + <%= link_to "Load more", artist_path(tracks_page: 1), + class: "text-secondary hover:text-primary transition-colors", + data: {"turbo-frame" => "_self", "turbo-action" => "advance"} %> +
  • + <% end %> +<% end %> diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index f2443fc..33b7d38 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -19,13 +19,7 @@

    Popular

    - +<%= render partial: "tracks", locals: {artist:, tracks:} %>