PontusHorn / Pico-Tags

A plugin for Pico to add tagging functionality.
MIT License
25 stars 9 forks source link

Tags list appears as string, instead of array #17

Open lionkmp opened 1 year ago

lionkmp commented 1 year ago

Hi, I'm not sure if I do something wrong, but when on my front page I iterate the pages array (for page in pages) and read the tags from it (page.meta.tags) this appears as a string, not an array. I'm using the alpha version of Pico 3.0.

Even this: Tags: blog, pancakes appears as string "blog, pancakes"

(I tested with Twig's dump() function.)

When I open a single page, "tags" value of the actual page is correctly an array (meta.tags).

Thanks in advance!

PontusHorn commented 9 months ago

Hi @lionkmp, very sorry for missing this issue. As you've probably guessed I'm not super active as a maintainer of the Pico plugins under my name anymore, due to not using Pico actively myself.

Is this still an issue for you? From what I can tell what you say is true, If I recall correctly something in Pico's design at the time made it hard to update the tags header in the list of pages. It might be easier in newer versions, or may be solvable in some way I didn't think of at the time. Happy to accept PRs here but I don't think I'll be doing it myself anytime soon.

lionkmp commented 9 months ago

Hi @PontusHorn

Thank you for the feedback. Actually, that tag what I mentioned must be written as

Tags:
  * blog
  * pancakes

which makes them appear as an array. But if only one tag is used, in simple Tags: blog format, that will be a string value. Thus even one tag needs to be written as:

Tags:
  * blog

which is inconvenient. But after all, I think this "error" (if error at all) has nothing to do with Tags plugin, but the markup parser of that header in Pico itself. And seeing this behavior it can be considered as correct from a developer point of view - but it's just different than in twas in Pico 2.x. And probably the site failure after site updates made me think it's a "bug".

Temporarily(?) I handled it on template level by checking if the given value is an array or not, and handle it as one tag or for-each of tags. This way the simple format can be still used if there is only one value.

I have 2 more sites to upgrade from 2.x to 3.x, I'll look at them soon and see if I experience the same, and we can close this bug as: "a feature, not bug".

ps: I think Pico CMS is still wonderful, despite no updates since 3.0 alpha. I still do create new sites on it and I hope it will survive. Your plugin is very useful for all my sites. :)