diff --git a/src/components/RecommendedCard.tsx b/src/components/RecommendedCard.tsx index 6f8c122..03c4d89 100644 --- a/src/components/RecommendedCard.tsx +++ b/src/components/RecommendedCard.tsx @@ -16,8 +16,13 @@ function isPlaceholderAsset(path: string | undefined | null) { return !path || path.includes("placeholder-cover"); } -const CARD_CLASS = - "group flex w-[208px] shrink-0 flex-col overflow-hidden rounded-xl border bg-[#1D1E23] transition hover:border-ark-gold/55 md:w-[240px] lg:w-[246.4px] min-[1100px]:max-xl:w-[273px] xl:w-[246.4px]"; +const CARD_BASE_CLASS = + "group flex shrink-0 flex-col overflow-hidden rounded-xl border bg-[#1D1E23] transition hover:border-ark-gold/55"; + +const CARD_CAROUSEL_SIZE_CLASS = + "w-[208px] md:w-[240px] lg:w-[246.4px] min-[1100px]:max-xl:w-[273px] xl:w-[246.4px]"; + +const CARD_GRID_SIZE_CLASS = "w-full max-w-[360px] md:max-w-none"; type RecommendedResource = Resource & { downloadPostId?: string; @@ -28,10 +33,12 @@ export function RecommendedCard({ r, visualIndex = 0, useFigmaDesign = false, + layout = "carousel", }: { r: RecommendedResource; visualIndex?: number; useFigmaDesign?: boolean; + layout?: "carousel" | "grid"; }) { const { t } = useI18n(); const [isDownloading, setIsDownloading] = useState(false); @@ -78,7 +85,9 @@ export function RecommendedCard({ return (
{cover ? (
diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index 2bc7e41..07cf491 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -69,7 +69,7 @@ export function Home() { getJSON<{ items: Post[] }>(`/api/posts/recommended${postQ}&limit=12`), getJSON<{ items: Post[] }>(`/api/posts${postQ}&sort=latest&limit=5`), getJSON<{ items: Post[] }>( - `/api/posts${postQ}&sort=popular&limit=5`, + `/api/posts${postQ}&tag=popular&limit=5`, ).catch((): { items: Post[] } => ({ items: [] })), ]) .then(([c, r, l, p]) => { @@ -179,6 +179,7 @@ export function Home() { }, [hash, cats.length, rec.length, latest.length, popular.length]); const latestPlaceholderCount = Math.max(0, 5 - latest.length); + const hasPopular = popular.length > 0 || popularPosts.length > 0; const popularPlaceholderCount = Math.max(0, 5 - popular.length); const recommendedDotCount = rec.length; const activeRecommendedDot = @@ -375,7 +376,7 @@ export function Home() { ))}
-
+
{latest.map((r) => ( ))} @@ -388,31 +389,37 @@ export function Home() {
- +
+
+ {popularPosts.slice(0, 5).map((post) => ( + + ))} +
+
+ {popular.map((r) => ( + + ))} + {Array.from({ length: popularPlaceholderCount }).map((_, index) => ( + + ))} +
+ + ) : null} {categoryUnavailableOpen ? (
- -
+
+ +
+
{items.map((item, index) => ( ))}