jooy2 / vitepress-sidebar

🔌 VitePress Sidebar is a plugin for VitePress that automatically configures and manages the sidebar of your page with simple settings.
https://vitepress-sidebar.cdget.com
MIT License
144 stars 7 forks source link

[Feature Request] sortMenusOrderByDescending for FileNames #137

Closed maxwowpow closed 5 months ago

maxwowpow commented 7 months ago

Current state of things

Currently for the sortMenusOrderByDescending

... This option is only enabled when sortMenusByName or sortMenusByFrontmatterOrder is true.

Proposition

How about making it active for filenames too?

so

2024-02-09-bar.md
2024-02-10-foo.md

with sortMenusOrderByDescending === true

would result in

foo
bar

Reasoning

md filenames are always there and at least for me they are in the order of writing, prefixed with the date (see proposition above).

So basically I wouldn't need any extra order field.

I've never seen blogs with articles sorted by title... rather it's typical to have the articles listed chronologically. So some kind of date is used.

jooy2 commented 5 months ago

Hello! Thank you for your patience.

The following options have been added to VitePress Sidebar 1.22.0: sortMenusByFileDatePrefix

This option in combination with a few others should give you the desired result:

  1. Set value true to sortMenusByFileDatePrefix and removePrefixAfterOrdering option
  2. Set value /[0-9]{4}-[0-9]{2}-[0-9]{2}-/g to prefixSeparator option (This regular expression will remove the prefix from the preceding date format.)

Please check to see if this resolved your request. If you have a new problem, please open a new issue and I will close this one.

Regards,