From cb6b8e1c77bc15fcade3da9c20deb7305f84bdfd Mon Sep 17 00:00:00 2001 From: Ronny Roland Date: Wed, 18 Oct 2023 09:33:45 -0600 Subject: [PATCH] Updates --- docs/site/src/components/Cards/index.tsx | 18 +++++++++++++++--- .../src/pages/{sui-api.js => sui-api-ref.js} | 0 2 files changed, 15 insertions(+), 3 deletions(-) rename docs/site/src/pages/{sui-api.js => sui-api-ref.js} (100%) diff --git a/docs/site/src/components/Cards/index.tsx b/docs/site/src/components/Cards/index.tsx index 4920fcfa46f501..ba9ff36258f191 100644 --- a/docs/site/src/components/Cards/index.tsx +++ b/docs/site/src/components/Cards/index.tsx @@ -1,16 +1,28 @@ // Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -import React from "react"; +import React, { useEffect, useState } from "react"; import { useLocation, useHistory } from "@docusaurus/router"; export function Card(props) { const location = useLocation(); const history = useHistory(); const isHome = location.pathname === "/"; + const [href, setHref] = useState(); - const handleClick = (href) => { - history.push(href); + useEffect(() => { + if (href) { + window.open(href, "_blank"); + } + return true; + }, [href]); + + const handleClick = (loc) => { + if (loc.match(/^https?/)) { + setHref(loc); + } else { + history.push(loc); + } }; let classList = diff --git a/docs/site/src/pages/sui-api.js b/docs/site/src/pages/sui-api-ref.js similarity index 100% rename from docs/site/src/pages/sui-api.js rename to docs/site/src/pages/sui-api-ref.js