Skip to content

Commit

Permalink
update router
Browse files Browse the repository at this point in the history
  • Loading branch information
seadfeng committed Aug 23, 2024
1 parent b77a8ea commit 54a1007
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/frontend/page/style/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Textarea } from "@/components/ui/textarea";
import { cn } from "@/lib/utils";
import { styleFonts, StyleKey } from "@/slugs";
import { fontKeys } from "@/transforms";
import { usePathname, useRouter } from "next/navigation";
import { useState } from "react";
import { Fonts } from "./fonts";
import { Sidebar } from "./sidebar";
Expand All @@ -20,9 +21,12 @@ export function StyleMain({
}>) {
const { block1, block2 } = markdownContents;
const [content, setContent] = useState<string>(text ? text : "Hello my old friend");

const pathname = usePathname();
const router = useRouter();

const onChange=(e: React.ChangeEvent<HTMLTextAreaElement>)=>{
setContent(e.target.value);
router.replace(`${pathname}?text=${e.target.value}`);
}

const currentFonts = style === "all" ? fontKeys : styleFonts[style];
Expand Down

0 comments on commit 54a1007

Please sign in to comment.