Providing a card view and a list view

I am working on a prototype of a document repository using Algolia. I have built a card view, that shows each document in the repository with a description of the document and some tags. I would like to give users the option to select a slimmed down “list” view, akin to the option available on for example Reddit (new design).

I looked through Github, and saw that this has been requested before. The initial assumption was that Algolia might be able to create a widget for this, but I understand this approach has been abandoned.

As well as:

Can anyone point me to documentation or an implementation that shows how to achieve this?

Here’s an implementation with a “hits view switcher”:

Relevant code is here:

Does that help you?