Closed jamestagal closed 2 years ago
Hi @jamestagal ,
Note that the tag and category functionality was a bit "proof-of-concept", to demonstrate that the Plenti pagination functionality could work. That said, my solution was not ideal, so the fix will be a bit of a refactor, however the code will be much cleaner and easier to use and maintain.
I'm working on this right now. it was on my backlog and almost forgot, until I reviewed your issue. The functionality is sorted and I'm working on the refactor and cleanup.
Cheers, Roberto
Hi @jamestagal ,
Please refresh your theme.
I refactored the category and tag logic into something that is easier to understand/maintain, and is more suitable for production. Because the aside component permeates throughout the template the change is pretty pervasive, so you'll likely need to refactor your new components. That said, it should be clear what needs to happen.
Notice on the code snippet, that there is a new object (catgPosts
) that replaces multiple objects (catgList, catgsMap
), but now uses keys values pairs and includes the quantity of posts for each (length).
{#each Object(catgPosts) as {page, name, length}}
<li class="flex">
<a href="catgs/{page}">{name} ({length})</a>
</li>
{/each}
Cheers, Roberto
Thanks @roobyz this part went well in the update. I am seeing the number of posts in each category now. Thanks again
Hi @jimafisk,
I am trying to style the Categories in the
aside.svelte
file to look a little different. see screenshot below. However I don't know how to get the number of posts in each category in Javascript!. At present the only thing i could think of was adding the length of the categories so{catg.length}
but that returns some odd numbers like 19 or 20 which was incorrect. Then I changed it to the following, but that only gives me the total number of categories not the number of posts in each category.{catgList.length}
https://github.com/jamestagal/edtechdesigner/blob/b8612775314b4dc153053bca64ec8be111a48d9c/layouts/components/aside.svelte#L25 So I am stumped. Please help if possible. Regards, Ben