From 44bf24c5a8c18481a1a993b9e0e9c7067a5bf2c5 Mon Sep 17 00:00:00 2001 From: yzhX <10969mart1n@gmail.com> Date: Sat, 13 Jan 2024 15:07:02 -0800 Subject: [PATCH 1/2] feat: add CourseCard Link in CourseList component add REACT_APP_API_URL in build script --- package.json | 2 +- src/components/CoursesList.tsx | 55 +++++++++++++++------------------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 81f703c5..d8bf6f35 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "docusaurus": "docusaurus", "start": "cross-env REACT_APP_API_URL='http://features-testing-env.eba-mau9qkgr.us-east-1.elasticbeanstalk.com/' docusaurus start", - "build": "docusaurus build", + "build": "cross-env REACT_APP_API_URL='http://features-testing-env.eba-mau9qkgr.us-east-1.elasticbeanstalk.com/' docusaurus build", "build:preview": "docusaurus build", "swizzle": "docusaurus swizzle", "deploy": "docusaurus deploy", diff --git a/src/components/CoursesList.tsx b/src/components/CoursesList.tsx index c00b2979..26396dbb 100644 --- a/src/components/CoursesList.tsx +++ b/src/components/CoursesList.tsx @@ -1,5 +1,4 @@ import React from "react"; -import { useHistory } from "@docusaurus/router"; import { useQuery } from "react-query"; import Tag from "@site/src/components/ui/Tag"; import { Skeleton } from "@site/src/components/ui/Skeleton"; @@ -7,6 +6,7 @@ import { getCourses } from "@site/src/api/course"; import { TCourse } from "../typings/course"; import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; import Translate from "@docusaurus/Translate"; +import Link from "@docusaurus/Link"; type TProps = { course: TCourse; @@ -14,42 +14,35 @@ type TProps = { const CourseCard = (props: TProps) => { const { course } = props; - const history = useHistory(); - - const viewCourse = (path: string) => { - if (path.startsWith("http")) { - window.location.href = path; - } else { - history.push(path); - } - }; return ( -