$layouts->clone()

I’m developing an infinite slider and made the functionality by cloning first and last slide of the array of slides in js.

But,

I’m using Kirby Layouts to create each of the individual slides, and I was wondering if I could use $layouts->clone() to duplicate the first and last slides of my foreach loop (instead of doing it in js). If so, how should I go about doing this and implement it?

I could use snipets to prevent excessive code duplication, but still…:smiley:

I apologize if this sounds naive or entirely incorrect, but I’m still very new to Kirby.