File tree Expand file tree Collapse file tree 4 files changed +22
-10
lines changed Expand file tree Collapse file tree 4 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 5
5
### New features
6
6
7
7
- Add support for applying arbitrary properties to documentation versions
8
+ - Add support for hiding specific versions from the selector when using the
9
+ default themes
8
10
- Deploy aliases using symbolic links by default; this can be configured via
9
11
` --alias-type ` on the command line or ` alias_type ` in the ` mike ` MkDocs plugin
10
12
- Avoid creating empty commits by default; if you want empty commits, pass
Original file line number Diff line number Diff line change @@ -248,6 +248,10 @@ is handled.
248
248
Each version of your documentation can have any arbitrary properties assigned to
249
249
it that you like. You can use these properties to hold extra metadata, and then
250
250
your documentation theme can consult those properties to do whatever you like.
251
+ When using the built-in MkDocs themes, mike supports one property : ` hidden` .
252
+ When this is `true`, that version will be hidden from the version selector
253
+ (unless it's the current version).
254
+
251
255
You can get properties via `props` command :
252
256
253
257
` ` ` sh
Original file line number Diff line number Diff line change @@ -34,13 +34,13 @@ window.addEventListener("DOMContentLoaded", function() {
34
34
var ABS_BASE_URL = expandPath ( base_url ) ;
35
35
var CURRENT_VERSION = ABS_BASE_URL . match ( / \/ ( [ ^ \/ ] + ) \/ $ / ) [ 1 ] ;
36
36
37
- function makeSelect ( options , selected ) {
37
+ function makeSelect ( options ) {
38
38
var select = document . createElement ( "select" ) ;
39
39
select . classList . add ( "form-control" ) ;
40
40
41
41
options . forEach ( function ( i ) {
42
42
var option = new Option ( i . text , i . value , undefined ,
43
- i . value === selected ) ;
43
+ i . selected ) ;
44
44
select . add ( option ) ;
45
45
} ) ;
46
46
@@ -55,9 +55,12 @@ window.addEventListener("DOMContentLoaded", function() {
55
55
i . aliases . includes ( CURRENT_VERSION ) ;
56
56
} ) . version ;
57
57
58
- var select = makeSelect ( versions . map ( function ( i ) {
59
- return { text : i . title , value : i . version } ;
60
- } ) , realVersion ) ;
58
+ var select = makeSelect ( versions . filter ( function ( i ) {
59
+ return i . version === realVersion || ! i . properties || ! i . properties . hidden ;
60
+ } ) . map ( function ( i ) {
61
+ return { text : i . title , value : i . version ,
62
+ selected : i . version === realVersion } ;
63
+ } ) ) ;
61
64
select . addEventListener ( "change" , function ( event ) {
62
65
window . location . href = ABS_BASE_URL + "../" + this . value + "/" ;
63
66
} ) ;
Original file line number Diff line number Diff line change @@ -34,12 +34,12 @@ window.addEventListener("DOMContentLoaded", function() {
34
34
var ABS_BASE_URL = expandPath ( base_url ) ;
35
35
var CURRENT_VERSION = ABS_BASE_URL . match ( / \/ ( [ ^ \/ ] + ) \/ $ / ) [ 1 ] ;
36
36
37
- function makeSelect ( options , selected ) {
37
+ function makeSelect ( options ) {
38
38
var select = document . createElement ( "select" ) ;
39
39
40
40
options . forEach ( function ( i ) {
41
41
var option = new Option ( i . text , i . value , undefined ,
42
- i . value === selected ) ;
42
+ i . selected ) ;
43
43
select . add ( option ) ;
44
44
} ) ;
45
45
@@ -54,9 +54,12 @@ window.addEventListener("DOMContentLoaded", function() {
54
54
i . aliases . includes ( CURRENT_VERSION ) ;
55
55
} ) . version ;
56
56
57
- var select = makeSelect ( versions . map ( function ( i ) {
58
- return { text : i . title , value : i . version } ;
59
- } ) , realVersion ) ;
57
+ var select = makeSelect ( versions . filter ( function ( i ) {
58
+ return i . version === realVersion || ! i . properties || ! i . properties . hidden ;
59
+ } ) . map ( function ( i ) {
60
+ return { text : i . title , value : i . version ,
61
+ selected : i . version === realVersion } ;
62
+ } ) ) ;
60
63
select . id = "version-selector" ;
61
64
select . addEventListener ( "change" , function ( event ) {
62
65
window . location . href = ABS_BASE_URL + "../" + this . value + "/" ;
You can’t perform that action at this time.
0 commit comments