@@ -40,13 +40,13 @@ const currentSegment = segmentMatches ? segmentMatches[0] : undefined;
4040// fall back to the version as defined in Hugo.
4141const selected = currentSegment ?? currentVersion ;
4242
43- function appendVersion ( parent , name , url ) {
43+ function appendVersion ( parent , name , segment , url ) {
4444 // The list item
4545 const li = document . createElement ( "li" ) ;
46- if ( name === selected ) {
46+ if ( segment === selected ) {
4747 li . classList . add ( "selected" ) ;
4848 }
49- if ( name === "latest" ) {
49+ if ( segment === "latest" ) {
5050 li . classList . add ( "latest" ) ;
5151 }
5252 parent . appendChild ( li ) ;
@@ -74,7 +74,7 @@ function appendVersion(parent, name, url) {
7474 // Otherwise, stop further event handling and replace the segment
7575 ev . preventDefault ( ) ;
7676 ev . stopPropagation ( ) ;
77- window . location . href = href . replace ( `/${ currentSegment } /` , `/${ name } /` ) ;
77+ window . location . href = href . replace ( `/${ currentSegment } /` , `/${ segment } /` ) ;
7878 } ) ;
7979
8080 // The link text
@@ -100,12 +100,13 @@ fetch(url)
100100 }
101101
102102 // Add a entries for the unstable version and the "latest" shortcut
103- appendVersion ( ul , "unstable" , "https://spec.matrix.org/unstable" ) ;
104- appendVersion ( ul , "latest" , "https://spec.matrix.org/latest" ) ;
103+ appendVersion ( ul , "unstable" , "unstable" , "https://spec.matrix.org/unstable" ) ;
104+ const latestName = versions ?. length ? `latest (${ versions [ 0 ] . name } )` : "latest" ;
105+ appendVersion ( ul , latestName , "latest" , "https://spec.matrix.org/latest" ) ;
105106
106107 // Add an entry for each proper version
107108 for ( const version of versions ) {
108- appendVersion ( ul , version . name , `https://spec.matrix.org/${ version . name } ` ) ;
109+ appendVersion ( ul , version . name , version . name , `https://spec.matrix.org/${ version . name } ` ) ;
109110 }
110111
111112 // For historical versions, simply link to the changelog
0 commit comments