vscode-front-matter icon indicating copy to clipboard operation
vscode-front-matter copied to clipboard

Enhancement: Enable custom sorting on integer fields

Open michaeltlombardi opened this issue 2 years ago • 8 comments

Is your feature request related to a problem? Please describe.

I'm trying to define a custom sorting option for my content, which logically follows weights by folder and subfolder. Unfortunately, the only valid options for type in frontMatter.content.sorting seem to be date and string. This definition is invalid:

Describe the solution you'd like

I would like for this definition to be valid and order my content by weight from lowest integer value to highest:

"frontMatter.content.sorting": [
  {
    "id": "byWeight",
    "title": "By Weight",
    "name": "weight",
    "order": "asc",
    "type": "integer"
  }
]

Describe alternatives you've considered

I can't think of any, since Front Matter isn't aware of how my static site generator will eventually order my content.

Additional context

N/A

michaeltlombardi avatar Sep 08 '22 13:09 michaeltlombardi

Support has been added. Type should be number as this is how it was already internally implemented for other fields.

estruyf avatar Sep 09 '22 14:09 estruyf

Good news and bad news - good news, the sorting works! Bad news, the configuration file still thinks number is an invalid value.

screenshot of the settings file for a custom sorter hovering on the "number" value for type, displaying a warning that lists the valid values as "string" and "date"

michaeltlombardi avatar Sep 10 '22 19:09 michaeltlombardi

That's great news.

The JSON schema has not yet been updated, that happens when an update to the docs happens. This is why you still see the warning.

estruyf avatar Sep 10 '22 19:09 estruyf

Okay, gotcha! That makes sense to me. Thank you so much for this improvement!

michaeltlombardi avatar Sep 10 '22 20:09 michaeltlombardi

A new schema version was released on the beta docs, which should fix the schema issue.

estruyf avatar Sep 12 '22 08:09 estruyf

I updated to the latest version (according to VS Code, anyway - v8.1.3035820) but no luck.

Screenshot showing the failed validation continues in latest preview

michaeltlombardi avatar Sep 12 '22 13:09 michaeltlombardi

To what URL is the schema set in your frontmatter.json file? Probably https://frontmatter.codes/frontmatter.schema.json? The beta schema is available on: https://beta.frontmatter.codes/frontmatter.schema.json, in some cases it might even get cached.

estruyf avatar Sep 12 '22 13:09 estruyf

Yup! That fixed it for me! 😊 I'll leave it on beta since I'm almost certainly going to stay out on the edge like this 😅

michaeltlombardi avatar Sep 12 '22 16:09 michaeltlombardi