@@ -310,6 +310,23 @@ defineOgImageComponent('Default', {
310310 description : () => pkg .value ?.license ?? ' ' ,
311311 primaryColor: ' #60a5fa' ,
312312})
313+
314+ // Sidebar visibility
315+ const { settings } = useSettings ()
316+ const isSidebarCollapsed = computed ({
317+ get : () => settings .value .sidebar .collapsed .includes (' code' ),
318+ set : value => {
319+ const collapsed = settings .value .sidebar .collapsed .filter (id => id !== ' code' )
320+ if (value ) {
321+ collapsed .push (' code' )
322+ }
323+ settings .value .sidebar .collapsed = collapsed
324+ },
325+ })
326+
327+ function toggleSidebar() {
328+ isSidebarCollapsed .value = ! isSidebarCollapsed .value
329+ }
313330 </script >
314331
315332<template >
@@ -349,6 +366,7 @@ defineOgImageComponent('Default', {
349366 <div v-else-if =" fileTree" class =" flex flex-1" dir =" ltr" >
350367 <!-- File tree sidebar - sticky with internal scroll -->
351368 <aside
369+ v-show =" !isSidebarCollapsed"
352370 class =" w-64 lg:w-72 border-ie border-border shrink-0 hidden md:block bg-bg-subtle sticky top-25 self-start h-[calc(100vh-7rem)] overflow-y-auto"
353371 >
354372 <CodeFileTree
@@ -365,6 +383,20 @@ defineOgImageComponent('Default', {
365383 class =" sticky z-5 top-25 bg-bg border-b border-border px-4 py-2 flex items-center justify-between gap-2 text-nowrap overflow-x-auto max-w-full"
366384 >
367385 <div class =" flex items-center gap-2" >
386+ <!-- Sidebar toggle button -->
387+ <button
388+ type =" button"
389+ class =" hidden md:flex items-center justify-center w-8 h-8 text-fg-subtle hover:text-fg transition-colors focus-visible:outline-accent/70 rounded"
390+ :aria-label =" $t(isSidebarCollapsed ? 'code.show_sidebar' : 'code.hide_sidebar')"
391+ @click =" toggleSidebar"
392+ >
393+ <span
394+ class =" w-4 h-4"
395+ :class =" isSidebarCollapsed ? 'i-lucide:sidebar-open' : 'i-lucide:sidebar-close'"
396+ aria-hidden =" true"
397+ />
398+ </button >
399+
368400 <div
369401 v-if =" fileContent?.markdownHtml"
370402 class =" flex items-center gap-1 p-0.5 bg-bg-subtle border border-border-subtle rounded-md overflow-x-auto"
0 commit comments