Skip to content

Commit

Permalink
fix: point readme documentation links to latest version (#306)
Browse files Browse the repository at this point in the history
Signed-off-by: Radek Ježek <pc.jezek@gmail.com>
  • Loading branch information
jezekra1 committed Feb 1, 2024
1 parent a7f7f15 commit 0d007b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ pip install --upgrade ibm-generative-ai

### [📚 Documentation](https://ibm.github.io/ibm-generative-ai/)

### [📚 Examples](https://ibm.github.io/ibm-generative-ai/rst_source/main/examples.html)
### [📚 Examples](https://ibm.github.io/ibm-generative-ai/latest/rst_source/examples.html)

### [📚 V2 Migration Guide](https://ibm.github.io/ibm-generative-ai/main/v2_migration_guide.html)
### [📚 V2 Migration Guide](https://ibm.github.io/ibm-generative-ai/latest/v2_migration_guide.html)


## Important Information for Contributors
Expand Down
12 changes: 10 additions & 2 deletions scripts/docs_root_redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,24 @@ def create_not_found_page_redirect(config: RedirectConfig):

dynamic_redirect = f"""<script>
var prefix = '{config.prefix or "/"}'
var pathnameParts = window.location.pathname.replace(new RegExp('^' + prefix), '').split('/')
var pathname = window.location.pathname
var pathnameParts = pathname.replace(new RegExp('^' + prefix), '').replace(new RegExp('^/'), '').split('/')
var fallbackVersions = JSON.parse('{json.dumps(supported_versions)}')
var fallbackVersion = '{config.version}'
var newTarget = "404.html"
var currentVersion = pathnameParts.shift()
if (currentVersion === "latest") {{
currentVersion = fallbackVersion
newTarget = pathnameParts.join('/')
}}
if (!fallbackVersions.includes(currentVersion)) {{
currentVersion = fallbackVersion
}}
var target = [prefix, currentVersion, "404.html"].join('/')
var target = [prefix, currentVersion, newTarget].join('/')
window.location.href = target
</script>"""

Expand Down

0 comments on commit 0d007b6

Please sign in to comment.