Enhancement: Enable custom sorting on integer fields #324

Closed
opened 2026-10-05 02:40:13 +02:00 by adam · 8 comments
Owner

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

**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: ```json "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 <!-- github-sync-id:1366305903 -->
adam closed this issue 2026-10-05 02:40:13 +02:00
Author
Owner

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

Support has been added. Type should be `number` as this is how it was already internally implemented for other fields. <!-- github-comment-id:1242065390 -->
Author
Owner

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"

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"](https://user-images.githubusercontent.com/14190564/189499205-cdd0054a-1cf5-44fc-915e-2c8f564fc565.png) <!-- github-comment-id:1242794269 -->
Author
Owner

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.

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. <!-- github-comment-id:1242795023 -->
Author
Owner

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

Okay, gotcha! That makes sense to me. Thank you so much for this improvement! <!-- github-comment-id:1242797569 -->
Author
Owner

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

A new schema version was released on the beta docs, which should fix the schema issue. <!-- github-comment-id:1243396459 -->
Author
Owner

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

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](https://user-images.githubusercontent.com/14190564/189669587-57d01f63-cbda-4f9d-ae60-12522139bb98.png) <!-- github-comment-id:1243763954 -->
Author
Owner

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.

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. <!-- github-comment-id:1243786063 -->
Author
Owner

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 😅

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 😅 <!-- github-comment-id:1243989685 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#324