Ordered metadata #131
-
Is there a way to get metadata in the order in which those are declared in a YAML file for example? Let say I have the following
I would like to be able to render in the same order declared in the file. I cannot find a way to achieve that, any idea appreciated? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Unfortunately the metadata is inherently unordered because it's implemented at a very low level as a dictionary. Very early in the project I experimented with some sort of ordering for metadata, but it quickly became intractable because of the way metadata is layered from global settings all the way down through document cloning, etc. There are just too many places it could come from and be overridden to establish a single ordering methodology. That said, what you want to do here isn't an unusual pattern. I usually accomplish it by adding an |
Beta Was this translation helpful? Give feedback.
Unfortunately the metadata is inherently unordered because it's implemented at a very low level as a dictionary. Very early in the project I experimented with some sort of ordering for metadata, but it quickly became intractable because of the way metadata is layered from global settings all the way down through document cloning, etc. There are just too many places it could come from and be overridden to establish a single ordering methodology.
That said, what you want to do here isn't an unusual pattern. I usually accomplish it by adding an
order
item (I.e.order: 1
, etc.) and then sorting on that where it needs to be ordered. There's even a strongly-typedKeys.Order
key you can use in t…