sunpy/ablog

Use list rather than set when stripping values for postlist

JoeZiminski opened this issue · 2 comments

Describe the feature

We have multiple authors on blog posts and would like to specify their order as appears on the postlist. At present we are using the :author: key in the blog post and :format: {title} by {author}, {date} in the index.rst. Using this approach, the list of authors is randomised on the blog index.

When building the postlist, this function strips the value names for display and returns as a set. Returning as set results in the order being randomised. If instead a list is returned, the order as specified in the blog header is maintained on the postlist.

Can this be changed to return a set, or at least changed only for author lists? Maybe there is another way to specify the authors in a non-random manner.

Proposed solution

_strip returns a list instead of set.

I'm happy to make a PR but unsure of any unintended consequences. Scope of change could be limited by having a separate function _strip_list that returns as list, and is used only in the author field.

I'm happy to make a PR but unsure of any unintended consequences.

I think it makes more sense to keep the order of any lists created by an author.
So we can just have it return the list as is instead of a set for everything to avoid randomization of the elements.

Great thanks @nabobalis I will make a PR now.