diff --git a/site/src/components/docs/DocsSidebar.astro b/site/src/components/docs/DocsSidebar.astro index c98cfd2c..a6afb91d 100644 --- a/site/src/components/docs/DocsSidebar.astro +++ b/site/src/components/docs/DocsSidebar.astro @@ -4,7 +4,6 @@ import type { SupportedFramework, SupportedStyle } from '@/types/docs'; import { PreferenceUpdater } from '@/components/docs/PreferenceUpdater'; import SidebarItem from '@/components/docs/SidebarItem.astro'; import { filterSidebar } from '@/utils/docs/sidebar'; -import FilmGrain from '../FilmGrain'; import clsx from 'clsx'; type Props = { diff --git a/site/src/components/docs/DocsSidebarRestoration.astro b/site/src/components/docs/DocsSidebarRestoration.astro new file mode 100644 index 00000000..1bc9304f --- /dev/null +++ b/site/src/components/docs/DocsSidebarRestoration.astro @@ -0,0 +1,90 @@ +--- +/** + * Sidebar state persistence using sessionStorage + * Progressive enhancement - only runs in browsers with view transitions + */ + +interface Props { + docsSidebarId: string; +} +const { docsSidebarId } = Astro.props; +--- + + + +{ + /* + We need to enable view transitions to get access to pageswap and pagereveal + However, something in our app is causing Safari to get all flickery during transitions, + so that's where view-transition-name: none comes in. + (btw, I think it's related to FilmGrain. Stuff doesn't seem to flicker when that's not present) +*/ +} + diff --git a/site/src/components/docs/SidebarItem.astro b/site/src/components/docs/SidebarItem.astro index 6b4c4cec..71e94cb0 100644 --- a/site/src/components/docs/SidebarItem.astro +++ b/site/src/components/docs/SidebarItem.astro @@ -2,6 +2,7 @@ import type { Guide, Section, SupportedFramework, SupportedStyle } from '@/types/docs'; import { isSection } from '@/types/docs'; import { ChevronDown } from 'lucide-react'; +import GithubSlugger from 'github-slugger'; type Props = { item: Guide | Section; @@ -13,6 +14,7 @@ type Props = { const { item, framework, style, docTitles, depth = 0 } = Astro.props; const currentPath = Astro.url.pathname; +const slugger = new GithubSlugger(); // Helper to check if this item or any of its children contains the active path function containsActivePath(item: Guide | Section): boolean { @@ -29,7 +31,12 @@ const isActive = containsActivePath(item); { isSection(item) ? ( -
+
) : ( = { doc: CollectionEntry<'docs'>; @@ -25,10 +26,15 @@ const { doc, framework, style, slug } = Astro.props; // Fetch all docs to get their framework-specific titles const allDocs = await getCollection('docs'); const docTitles = new Map(allDocs.map((d) => [d.id, getDocTitle(d, framework)])); + +const docsSidebarId = 'docs-sidebar'; --- - + + + +
[d.id, getDocTitle(d, framework)]))