Skip to content

Commit

Permalink
ENH: add optional per version url in version-switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
tupui committed Jan 20, 2022
1 parent 0371d3f commit cdb4295
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/user_guide/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,16 @@ Add a JSON file to define your switcher's versions

First, write a JSON file stating which versions of your docs will be listed in
the switcher's dropdown menu. That file should contain a list of entries that
each have one or two fields:
each can have the following fields:

- ``version``: a version string. This will be inserted into
``switcher['url_template']`` to create the links to other docs versions, and
also checked against ``switcher['version_match']`` to provide styling to the
switcher.
- ``name``: an optional name to display in the switcher dropdown instead of the
version string (e.g., "latest", "stable", "dev", etc).
- ``url``: an optional URL. If provided, it links the version to ``url``
not taking into account ``switcher['url_template']``.

Here is an example JSON file:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
node.textContent = `${entry.name}`;
// get the base URL for that doc version, add the current page's
// path to it, and set as `href`
entry.url = buildURL(entry);
if (!("url" in entry)) {
entry.url = buildURL(entry);
}
node.setAttribute("href", `${entry.url}${currentFilePath}`);
// on click, AJAX calls will check if the linked page exists before
// trying to redirect, and if not, will redirect to the homepage
Expand Down

0 comments on commit cdb4295

Please sign in to comment.