From da8202208dd3dd01b637fa1be5c386eff64b5084 Mon Sep 17 00:00:00 2001 From: Zvonimir Rudinski Date: Sun, 7 Jul 2024 05:01:33 +0200 Subject: [PATCH] auto-open the saved open section --- src/components/Section.astro | 2 ++ src/pages/index.astro | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/components/Section.astro b/src/components/Section.astro index ada763a..4137e78 100644 --- a/src/components/Section.astro +++ b/src/components/Section.astro @@ -71,11 +71,13 @@ const { title, hasBorder } = Astro.props; extend(section: Element, container: HTMLElement) { container.style.maxHeight = "1000vh"; section.classList.add("open"); + sessionStorage.setItem("openSection", this.id); } collapse(section: Element, container: HTMLElement) { container.style.maxHeight = "0"; section.classList.remove("open"); + sessionStorage.removeItem("openSection"); } } diff --git a/src/pages/index.astro b/src/pages/index.astro index 6807ebf..133b823 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -111,5 +111,21 @@ import { projects } from "../projects"; + +