terry-staging #16

Merged
terry merged 96 commits from terry-staging into main 2026-06-05 16:33:12 +00:00
2 changed files with 13 additions and 4 deletions
Showing only changes of commit 37e6e4901f - Show all commits

View File

@@ -90,7 +90,7 @@ export function PopularRankRow({
browseSort = "popular",
showRank = true,
showDownload = true,
singlePostLink = false,
linkToResource = false,
onFavoriteChange,
}: {
post: Post;
@@ -99,7 +99,13 @@ export function PopularRankRow({
browseSort?: string;
showRank?: boolean;
showDownload?: boolean;
singlePostLink?: boolean;
/**
* When true, the card and download button route to `/resource/:id` so the
* `PostRedirect` page can fall back to the post's source language if the
* current UI language has no translation. Otherwise navigate inside the
* `/browse` stream which assumes the post exists in the current language.
*/
linkToResource?: boolean;
onFavoriteChange?: (postId: string, favorited: boolean) => void;
}) {
const { t, lang } = useI18n();
@@ -143,10 +149,13 @@ export function PopularRankRow({
<button
type="button"
onClick={() => {
if (linkToResource) {
navigate(lp(`/resource/${encodeURIComponent(post.id)}`));
return;
}
const params = new URLSearchParams();
if (browseSort) params.set("sort", browseSort);
params.set("post", post.id);
if (singlePostLink) params.set("single", "1");
navigate(lp(`/browse?${params.toString()}`));
}}
aria-label={r.title}

View File

@@ -201,7 +201,7 @@ export default function Favorites() {
browseSort=""
showRank={false}
showDownload={false}
singlePostLink
linkToResource
onFavoriteChange={(_, favorited) => {
if (!favorited) setReloadKey((value) => value + 1);
}}