From 6e1c82dabfaa56ba754c512a6d87e6079aa75839 Mon Sep 17 00:00:00 2001 From: Cooper Ransom Date: Fri, 15 Mar 2024 22:10:59 -0400 Subject: [PATCH] Add direct link to content on TopFlix.tsx --- src/pages/TopFlix.tsx | 49 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/src/pages/TopFlix.tsx b/src/pages/TopFlix.tsx index 66e96976..c6aaeebe 100644 --- a/src/pages/TopFlix.tsx +++ b/src/pages/TopFlix.tsx @@ -2,7 +2,6 @@ import classNames from "classnames"; import { ReactNode, useEffect, useState } from "react"; import { Link } from "react-router-dom"; // Import Link from react-router-dom -import { getMediaPoster } from "@/backend/metadata/tmdb"; import { ThiccContainer } from "@/components/layout/ThinContainer"; import { Divider } from "@/components/utils/Divider"; import { Heading1, Paragraph } from "@/components/utils/Text"; @@ -32,17 +31,44 @@ function Button(props: { ); } -function ConfigValue(props: { name: string; children?: ReactNode }) { +function isShowOrMovie(tmdbFullId: string): "show" | "movie" | "unknown" { + if (tmdbFullId.includes("show-")) { + return "show"; + } + if (tmdbFullId.includes("movie-")) { + return "movie"; + } + return "unknown"; +} + +function directLinkToContent(tmdbFullId: string) { + const currentDomain = window.location.href.split("#")[0]; + if (isShowOrMovie(tmdbFullId) === "show") { + return `${currentDomain}media/tmdb-movie-${tmdbFullId.split("-")[1]}`; + } + if (isShowOrMovie(tmdbFullId) === "movie") { + return `${currentDomain}media/tmdb-tv-${tmdbFullId.split("-")[1]}`; + } + return null; +} + +function ConfigValue(props: { + name: string; + id: string; + children?: ReactNode; +}) { + const link = directLinkToContent(props.id); return ( <>

- - {props.name} - + {link ? ( + + {props.name} + + ) : ( +

{props.name}

+ )}

{props.children}

@@ -175,9 +201,12 @@ export function TopFlix() { {getItemsForCurrentPage().map((item) => { - const coverUrl = getMediaPoster(item.tmdbFullId); return ( - + {`${item.providerId} - Views: `} {item.count}