-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
83 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
website/docs/src/unified-plugins/rehype-luigi-oldVersions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import visit from 'unist-util-visit'; | ||
import h from 'hastscript'; | ||
import versions from '../../static/versions.json'; | ||
|
||
export default function oldVersion() { | ||
return function transformer(tree) { | ||
visit(tree, ['comment'], function(node, index, parent) { | ||
if (node.type === 'comment' && node.value.trim() === 'oldVersionsDropdown') { | ||
const wrapper = h('div.custom-select'); | ||
const oldVerDropdown = h('select.oldverdrop'); | ||
oldVerDropdown.properties.onchange = | ||
"window.open('https://github.com/SAP/luigi/blob/' + event.target.value + '/docs/README.md', '_blank'); event.target.value=0;"; | ||
wrapper.children.push(oldVerDropdown); | ||
parent.children.splice(index + 1, 0, wrapper); | ||
const tagLinks = []; | ||
const minors = {}; | ||
versions.forEach(tag => { | ||
if (tag.name.indexOf('v') === 0 && tag.name.indexOf('-') < 0) { | ||
const vInfo = tag.name.split('.'); | ||
if (vInfo && vInfo.length === 3) { | ||
const minor = vInfo[0] + '.' + vInfo[1]; | ||
if (!minors[minor]) { | ||
minors[minor] = tag; | ||
tagLinks.push(tag); | ||
} | ||
} | ||
} | ||
}); | ||
const chooseOption = h('option', 'Choose a version'); | ||
chooseOption.properties.value = '0'; | ||
chooseOption.properties.style = 'display:none;'; | ||
oldVerDropdown.children.push(chooseOption); | ||
tagLinks.slice(1).forEach(tag => { | ||
const tagOption = h('option', tag.name); | ||
oldVerDropdown.children.push(tagOption); | ||
}); | ||
} | ||
}); | ||
}; | ||
} |