Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Enable custom sorting on integer fields #402

Closed
michaeltlombardi opened this issue Sep 8, 2022 · 8 comments
Closed

Enhancement: Enable custom sorting on integer fields #402

michaeltlombardi opened this issue Sep 8, 2022 · 8 comments
Labels
enhancement New feature or request Project: v8.1.0

Comments

@michaeltlombardi
Copy link

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

@estruyf
Copy link
Owner

estruyf commented Sep 9, 2022

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

@michaeltlombardi
Copy link
Author

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"

@estruyf
Copy link
Owner

estruyf commented Sep 10, 2022

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.

@michaeltlombardi
Copy link
Author

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

@estruyf
Copy link
Owner

estruyf commented Sep 12, 2022

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

@michaeltlombardi
Copy link
Author

michaeltlombardi commented Sep 12, 2022

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

@estruyf
Copy link
Owner

estruyf commented Sep 12, 2022

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.

@michaeltlombardi
Copy link
Author

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 😅

@estruyf estruyf closed this as completed Sep 22, 2022
@estruyf estruyf mentioned this issue Sep 22, 2022
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Project: v8.1.0
Projects
None yet
Development

No branches or pull requests

2 participants