-
Notifications
You must be signed in to change notification settings - Fork 4
Persist light theme on refresh #513
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think on balance having a few lines extra JS for a more functional site in the interim is worth the tradeoff, but agree it seems that using an alternative solution for building the site like Material for MkDocs which support this out of the box would be good.
When serving this locally and viewing in Firefox the theme still does not seem to persist between page changes, which from adding some console.log
statements seems to be as the "DOMContentLoaded"
event listener never gets called. As far as I can tell (my JavaScript knowledge is very minimal though!) the syntax for adding the event listener is all correct, so I am not sure if this is just something specific about serving this locally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on does not work for me locally - both on refreshing and changing pages
Migrating to another docs generator sounds like the best option here
This comment was marked as outdated.
This comment was marked as outdated.
Now working for me... Screen.Recording.2025-02-03.at.15.17.38.mov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why it did, but with change to comment this does now work for me locally!
Python is cool. Javascript is not cool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Works well now!
➕ for moving to https://squidfunk.github.io/mkdocs-material as well |
Fixes
... using the workaround suggested in
Worth spending a bit of thought on whether we want more lines of my hacky JS code saving the theme to local storage, which we potentially can't delete until jtd/#1223 is solved nicely upstream.
Question:
Is it worth switching build system to something that supports theme toggling and inferring theme from the browser/os settings? It feels like it's the responsibility of the doc engine/doc theme. E.g. Material for MkDocs supports it.
That said, if you're happy with these lines, I am.