I’m working on a system for auto-inferring which versions of documentation exist based on which folders exist in the content/docs
folder. Thus, if there is a content/docs/1.0
folder and a content/docs/1.1
folder, then I can infer that 1.0 and 1.1 are the available versions and that 1.1 is the “latest” version. Like this:
<!-- Sort versions in descending order -->
{{ $versions := sort (readDir "content/docs") "Name" "desc" }}
<!-- The "latest" version is the first version in the array -->
{{ $latest := (index $versions 0).Name }}
The issue is that that system breaks down if I add version 1.1.1, which is technically “below” version 1.1 when using an ordinary sort
function.
Have any of you come up with a way of maintaining proper sorting based on semver?