Skip to content

Put the ReadTheDocs version switcher in the header navbar #705

@choldgraf

Description

@choldgraf

Context

ReadTheDocs will place a little hover widget over the page for most themes, this allows people to see a dropdown of versions and languages available. For example:

This switcher can be a little hard to spot, and also clashes with the visual style of the theme (e.g., it uses different colors and a UI layout, and doesn't change with dark theme etc).

Proposal

We should have an intentional location for the ReadTheDocs switcher somewhere in our theme layout. It could be placeable with a template component (e.g., readthedocs-switcher.html) and could be styled so that it works with this theme's structure/style.

Suggestion for implementation

ReadTheDocs will use JavaScript to inject this little widget on the server side when the page loads. This means that you can intercept this code and move the component wherever you like with some JavaScript.

Here's an example of code that does this for the book theme. It uses a MutationObserver to watch for the addition of the readthedocs HTML, and moves it to the sidebar:

https://github.com/executablebooks/sphinx-book-theme/blob/af6277a7276112ee915d901984193c49e56d5a76/src/sphinx_book_theme/assets/scripts/index.js#L189-L213

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: enhancementNew feature or requesttag: componentIssues or improvements associated with a given component in the theme

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions