Skip to content

Multiple books on the same host contaminate each other #455

Open
@Michael-F-Bryan

Description

@Michael-F-Bryan

If multiple books are on the same host, changing the theme on one can magically change the theme on all the others.

Steps to Reproduce:

  1. Open up the first and second versions of the Rust Book in separate tabs
  2. Go to the first book and change its theme
  3. Refresh the second book's tab

You'll probably also see this if you use mdbook on multiple projects and have them hosted on GitHub Pages.

This is somewhat related to rust-lang/rust#44704 (see @steveklabnik's comment) in that local storage keys aren't handled as well as they could be.

mdbook stores the current theme in localstorage. This did change in newer/older mdbook, but it looks like this, basically:

   var theme = localStorage.getItem('theme');
   if (theme === null) { theme = 'light'; }

Ideally instead of using a key like "theme", it'd be namespaced. So in the case of the first Rust Book you might use "/book/first-edition:theme".

There may also be other cases where local storage handling allows cross-book contamination.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions