Last active
July 3, 2017 08:39
-
-
Save MartinMuzatko/cdf7c33fc348340d6f9bfbc4e4793a8e to your computer and use it in GitHub Desktop.
Relink unresolved versioned page
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
## place somewhere at the bottom before </body> - doesn't matter | |
<script> | |
window.spaceKey = '$repository.key' | |
</script> |
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 only works if: | |
// space key equals viewport URL prefix (.com/is511z/...) | |
// the user knows a space to link to which potentially got all pages (otherwise - he will get a 404) | |
// within a document ready function | |
// $(document).ready(function() { | |
$('.unresolved').each(function(){ | |
var replaceVersion = 'latest' // put SPACE KEY | |
$(this).attr('href', $(this).attr('href').replace(spaceKey.toLowerCase(), replaceVersion) ) | |
}) | |
// }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment