Skip to content

Commit 4689d38

Browse files
committed
Rename a query param
1 parent ea52f33 commit 4689d38

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

src/components/tutorial/TutorialWindow.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
useRef,
1010
useState,
1111
} from "react";
12-
import { steps } from "@/data/tutorial";
12+
import { steps as articles } from "@/data/tutorial";
1313
import { useScrollShadow } from "@/hooks/use-scroll-shadow";
1414
import { cn } from "@/lib/utils";
1515
import {
@@ -379,7 +379,7 @@ function FloatingWindow({
379379
isResizing ? "contain-strict" : "contain-none",
380380
)}
381381
>
382-
{steps.map((step) => (
382+
{articles.map((step) => (
383383
<TabsContent
384384
key={step.title}
385385
value={step.title}
@@ -424,20 +424,26 @@ export function TutorialWindow({
424424
}) {
425425
const [isClosed, setIsClosed] = useState(tutorialData.isClosed);
426426

427-
const { step: activeStepFromSearch } = useSearch({ strict: false });
427+
const { article: activeArticleFromSearch } = useSearch({ strict: false });
428428

429429
const [activeStep, setActiveStep] = useState(
430-
tutorialData.tutorialStep || steps[0].title,
430+
tutorialData.tutorialStep || articles[0].title,
431431
);
432432

433433
useEffect(() => {
434-
if (activeStepFromSearch && typeof activeStepFromSearch === "string") {
435-
const stepInSearch = decodeURIComponent(activeStepFromSearch);
436-
if (steps.find((step) => step.title === stepInSearch)) {
437-
setActiveStep(stepInSearch);
434+
if (
435+
activeArticleFromSearch &&
436+
typeof activeArticleFromSearch === "string"
437+
) {
438+
const articleInSearch = decodeURIComponent(
439+
activeArticleFromSearch.toLowerCase(),
440+
);
441+
442+
if (articles.find((a) => a.title === articleInSearch)) {
443+
setActiveStep(articleInSearch);
438444
}
439445
}
440-
}, [activeStepFromSearch]);
446+
}, [activeArticleFromSearch]);
441447

442448
const router = useRouter();
443449

src/components/tutorial/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ export function LinkToArticle({
9999
articleTitle: string;
100100
}) {
101101
const encodedTitle = useMemo(
102-
() => encodeURIComponent(articleTitle),
102+
() => encodeURIComponent(articleTitle.toLowerCase()),
103103
[articleTitle],
104104
);
105105

106106
return (
107107
<Link
108108
to="."
109109
search={{
110-
step: encodedTitle,
110+
article: encodedTitle,
111111
}}
112112
className="text-orange-500 underline hover:text-orange-600 transition-colors cursor-pointer"
113113
>

src/routes/_tutorial.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const Route = createFileRoute("/_tutorial")({
1010
validateSearch: z
1111
.object({
1212
temp_db_missing: z.string().optional(),
13-
step: z.string().optional(),
13+
article: z.string().optional(),
1414
})
1515
.extend(highlightParamSchema.shape),
1616
loader: async () => {

0 commit comments

Comments
 (0)