I am fairly new to Magento, and am having trouble figuring out what I need to add to do this. I have looked all over for this, but can not find a solution that shows how to do this for magento 2. I am looking for how to create a module that displays all of the subcategories of the category clicked. If there are no more subcategories, then I want to display the products for that category.
I have tried making blocks in the admin panel, and attaching these blocks to the product category. I would really like to just create a module that does this for me though.