Skip to content

initial pageload has "light" set as the theme #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
steveklabnik opened this issue Sep 19, 2017 · 2 comments · Fixed by #449
Closed

initial pageload has "light" set as the theme #448

steveklabnik opened this issue Sep 19, 2017 · 2 comments · Fixed by #449

Comments

@steveklabnik
Copy link
Member

steveklabnik commented Sep 19, 2017

Originally found in rust-lang/rust#44704 (comment)

mdbook stores the current theme in localstorage. This changed between 0.0.23 and 0.0.25, with https://github.com/azerupi/mdBook/pull/337 and https://github.com/azerupi/mdBook/pull/324

It basically looks like this:

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

However, if you visit a book generated by 0.0.25, and run this in your JS console:

>> localStorage.getItem("theme")
"\"light\""

See the quotes? If you go back to a 0.0.23 generated book, and delete the theme from localstorage, and then refresh, it works, and

>> localStorage.getItem("theme")
"light"
@steveklabnik
Copy link
Member Author

/me sighs
store

@steveklabnik
Copy link
Member Author

So, one possible solution here is to pick a new key, so that the older mdbooks don't get their theme stuff clobbered. It's not ideal, but at least it works...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant