From 6dde9f209060cc31b55847d465533afb879bb018 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Sat, 23 Aug 2025 17:24:16 +0300
Subject: fix: preserve selected section in link preview in query params

---
 apps/web/components/dashboard/preview/LinkContentSection.tsx | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'apps/web/components/dashboard/preview/LinkContentSection.tsx')

diff --git a/apps/web/components/dashboard/preview/LinkContentSection.tsx b/apps/web/components/dashboard/preview/LinkContentSection.tsx
index a0a6f580..53559aa0 100644
--- a/apps/web/components/dashboard/preview/LinkContentSection.tsx
+++ b/apps/web/components/dashboard/preview/LinkContentSection.tsx
@@ -1,4 +1,3 @@
-import { useState } from "react";
 import Image from "next/image";
 import Link from "next/link";
 import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
@@ -26,6 +25,7 @@ import {
   ExpandIcon,
   Video,
 } from "lucide-react";
+import { useQueryState } from "nuqs";
 import { ErrorBoundary } from "react-error-boundary";
 
 import {
@@ -108,7 +108,9 @@ export default function LinkContentSection({
   const availableRenderers = contentRendererRegistry.getRenderers(bookmark);
   const defaultSection =
     availableRenderers.length > 0 ? availableRenderers[0].id : "cached";
-  const [section, setSection] = useState<string>(defaultSection);
+  const [section, setSection] = useQueryState("section", {
+    defaultValue: defaultSection,
+  });
 
   if (bookmark.content.type != BookmarkTypes.LINK) {
     throw new Error("Invalid content type");
-- 
cgit v1.2.3-70-g09d2

