@@ -179,16 +179,21 @@ const app = createApp({
179179 }
180180
181181 if ( e . code == "KeyM" && e . ctrlKey ) {
182- sidebarShown . value = ! sidebarShown . value ;
182+ toggleSidebar ( ) ;
183183 }
184184 } ) ;
185185
186- const sidebarShown = ref ( false ) ;
186+ const sidebarShown = ref ( localStorage . getItem ( 'sidebarShown' ) ) ;
187187
188188 const smallScreen = computed ( ( ) => {
189189 return ( windowWidth . value || 0 ) < smallScreenSize ;
190190 } ) ;
191191
192+ function toggleSidebar ( ) {
193+ sidebarShown . value = ! sidebarShown . value ;
194+ localStorage . setItem ( 'sidebarShown' , sidebarShown . value ) ;
195+ }
196+
192197 /** @type {import("vue").Ref<"toc" | "search"> } */
193198 const sidebarTab = ref ( "toc" ) ;
194199
@@ -207,13 +212,16 @@ const app = createApp({
207212 watch ( windowWidth , ( newWidth , oldWidth ) => {
208213 //+ 50 so that the side bar diappears before the css media class changes the sidebar to take
209214 // over the full screen
210- if ( newWidth < smallScreenSize ) {
211- sidebarShown . value = false ;
212- }
213- // when making screen bigger reveal sidebar
214- else {
215- if ( ! sidebarShown . value ) {
216- sidebarShown . value = true ;
215+ // If a setting is set in storage already, follow that
216+ if ( sidebarShown . value === null ) {
217+ if ( newWidth < smallScreenSize ) {
218+ sidebarShown . value = false ;
219+ }
220+ // when making screen bigger reveal sidebar
221+ else {
222+ if ( ! sidebarShown . value ) {
223+ sidebarShown . value = true ;
224+ }
217225 }
218226 }
219227 } ) ;
@@ -230,8 +238,11 @@ const app = createApp({
230238 } ) ;
231239
232240 onMounted ( ( ) => {
233- if ( windowWidth . value > smallScreenSize ) {
234- sidebarShown . value = true ;
241+ // If a setting is set in storage already, follow that
242+ if ( sidebarShown . value === null ) {
243+ if ( windowWidth . value > smallScreenSize ) {
244+ sidebarShown . value = true ;
245+ }
235246 }
236247
237248 // Scroll the current selected page in the TOC into view of the TOC.
@@ -304,6 +315,7 @@ const app = createApp({
304315
305316 sidebarShown,
306317 sidebarTab,
318+ toggleSidebar,
307319
308320 smallScreen,
309321
0 commit comments