fix: route home view-all links

This commit is contained in:
TerryM
2026-05-28 16:49:30 +08:00
parent 4c15e01460
commit 5fec82dbba
6 changed files with 90 additions and 68 deletions

View File

@@ -4,7 +4,6 @@ import { Link, Outlet, useLocation, useNavigate } from "react-router-dom";
import { ArkLogoMark } from "../components/ArkLogoMark";
import { useI18n, type Lang } from "../i18n";
import { LANG_OPTIONS } from "../i18nLanguages";
import { isPopularTag, popularTagParam } from "../utils/popularTag";
type PublicNavWhich =
| "home"
@@ -21,7 +20,6 @@ function navIsActive(
search: string,
hash: string,
which: PublicNavWhich,
currentLang: Lang,
): boolean {
const sp = new URLSearchParams(search);
switch (which) {
@@ -39,9 +37,7 @@ function navIsActive(
case "browseRecommended":
return pathname === "/official-recommendations";
case "browsePopular":
return (
pathname === "/browse" && isPopularTag(sp.get("tag") || "", currentLang)
);
return pathname === "/browse" && sp.get("sort") === "popular";
case "favorites":
return (
pathname === "/favorites" || (pathname === "/" && hash === "#favorites")
@@ -277,10 +273,10 @@ export function PublicLayout() {
const nav = useNavigate();
const na = (which: PublicNavWhich) =>
navIsActive(pathname, search, hash, which, lang);
navIsActive(pathname, search, hash, which);
const isHome = pathname === "/";
const footerInContentFlow = pathname === "/browse";
const popularHref = `/browse?tag=${popularTagParam(lang)}`;
const popularHref = "/browse?sort=popular";
const goSearch = () => {
const s = q.trim();