From fe6a1254785d4eaa389de5cc1f53e7e4b6217717 Mon Sep 17 00:00:00 2001 From: Alex Freska Date: Fri, 15 Sep 2023 14:07:01 -0400 Subject: [PATCH] fix: explorer network differences --- apps/explorer/app/opengraph-image.tsx | 6 ++-- apps/explorer/app/page.tsx | 18 +++++------- apps/explorer/components/Faucet/index.tsx | 2 +- .../components/Layout/NavDropdownMenu.tsx | 18 ++++++++---- .../explorer/components/Layout/Navbar.tsx | 29 ++++++++++++++----- apps/explorer/components/Layout/index.tsx | 27 ++++++++++------- apps/explorer/config/index.ts | 4 ++- apps/explorer/config/testnet.ts | 6 ++-- apps/explorer/lib/utils.ts | 4 +-- libs/design-system/src/index.ts | 1 - 10 files changed, 71 insertions(+), 44 deletions(-) rename libs/design-system/src/core/NavbarSite.tsx => apps/explorer/components/Layout/Navbar.tsx (51%) diff --git a/apps/explorer/app/opengraph-image.tsx b/apps/explorer/app/opengraph-image.tsx index d19fdd80a..708df58bd 100644 --- a/apps/explorer/app/opengraph-image.tsx +++ b/apps/explorer/app/opengraph-image.tsx @@ -3,7 +3,7 @@ import { getSiaCentralHostsNetworkMetrics, } from '@siafoundation/sia-central' import { getOGImage } from '../components/OGImage' -import { networkName, siaCentralApi } from '../config' +import { network, siaCentralApi } from '../config' import { humanBytes } from '@siafoundation/sia-js' export const revalidate = 60 @@ -50,9 +50,9 @@ export default async function Image() { return getOGImage( { - title: networkName === 'Sia Mainnet' ? 'siascan' : 'siascan', + title: 'siascan', subtitle: - networkName === 'Sia Mainnet' + network === 'mainnet' ? 'Sia blockchain and host explorer.' : 'Zen testnet blockchain and host explorer.', values, diff --git a/apps/explorer/app/page.tsx b/apps/explorer/app/page.tsx index c1135112e..6ae4779bb 100644 --- a/apps/explorer/app/page.tsx +++ b/apps/explorer/app/page.tsx @@ -1,5 +1,5 @@ import { Metadata } from 'next' -import { appLink, appName, networkName, siaCentralApi } from '../config' +import { appLink, network, siaCentralApi } from '../config' import { Home } from '../components/Home' import { getSiaCentralBlockLatest, @@ -9,23 +9,19 @@ import { getSiaCentralHostsNetworkMetrics, } from '@siafoundation/sia-central' import { range } from 'lodash' +import { buildMetadata } from '../lib/utils' export function generateMetadata(): Metadata { - const title = networkName === 'Sia Mainnet' ? 'siascan' : 'siascan' + const title = 'siascan' const description = - networkName === 'Sia Mainnet' + network === 'mainnet' ? 'Sia blockchain and host explorer.' : 'Zen blockchain and host explorer.' - return { + return buildMetadata({ title, description, - openGraph: { - title, - description, - url: appLink, - siteName: appName, - }, - } + url: appLink, + }) } export const revalidate = 60 diff --git a/apps/explorer/components/Faucet/index.tsx b/apps/explorer/components/Faucet/index.tsx index d860e195f..bdffac592 100644 --- a/apps/explorer/components/Faucet/index.tsx +++ b/apps/explorer/components/Faucet/index.tsx @@ -40,7 +40,7 @@ export function Faucet() { return (
- +
diff --git a/apps/explorer/components/Layout/NavDropdownMenu.tsx b/apps/explorer/components/Layout/NavDropdownMenu.tsx index 94816b243..779284bec 100644 --- a/apps/explorer/components/Layout/NavDropdownMenu.tsx +++ b/apps/explorer/components/Layout/NavDropdownMenu.tsx @@ -7,8 +7,8 @@ import { Link, DropdownMenuGroup, DropdownMenuLabel, + Menu24, } from '@siafoundation/design-system' -import { networkName } from '../../config' type Props = React.ComponentProps & { trigger?: React.ReactNode @@ -20,8 +20,8 @@ export function NavDropdownMenu({ trigger, children, ...props }: Props) { - {networkName} + ) } @@ -30,16 +30,24 @@ export function NavDropdownMenu({ trigger, children, ...props }: Props) { Network - + Sia Mainnet - + Zen Testnet + + Tools + + + Zen Faucet + + + ) } diff --git a/libs/design-system/src/core/NavbarSite.tsx b/apps/explorer/components/Layout/Navbar.tsx similarity index 51% rename from libs/design-system/src/core/NavbarSite.tsx rename to apps/explorer/components/Layout/Navbar.tsx index 2ad46a260..b56b15907 100644 --- a/libs/design-system/src/core/NavbarSite.tsx +++ b/apps/explorer/components/Layout/Navbar.tsx @@ -1,20 +1,27 @@ -import { Container } from './Container' -import { Heading } from './Heading' -import { Link } from './Link' -import { Logo } from './Logo' +import { + Container, + Heading, + Link, + Logo, + Text, +} from '@siafoundation/design-system' type Props = { appName?: string + network?: 'mainnet' | 'zen' homeHref: string children: React.ReactNode } -export function NavbarSite({ appName, homeHref, children }: Props) { +export function Navbar({ appName, network, homeHref, children }: Props) { return (
+ {network !== 'mainnet' && ( +
+ )}
-
+
@@ -22,11 +29,19 @@ export function NavbarSite({ appName, homeHref, children }: Props) { {appName} )} + {network !== 'mainnet' && ( + + {network} + + )}
diff --git a/apps/explorer/components/Layout/index.tsx b/apps/explorer/components/Layout/index.tsx index ed4b6a2b1..4a3d2aef1 100644 --- a/apps/explorer/components/Layout/index.tsx +++ b/apps/explorer/components/Layout/index.tsx @@ -1,34 +1,39 @@ -import { - NavbarSite, - FaucetIcon, - LinkButton, - Tooltip, -} from '@siafoundation/design-system' +import { FaucetIcon, LinkButton, Tooltip } from '@siafoundation/design-system' import { routes } from '../../config/routes' import { Search } from './Search' -import { isMainnet, networkName } from '../../config' +import { isMainnet, networkName, appName } from '../../config' import { NavDropdownMenu } from './NavDropdownMenu' import { Footer } from './Footer' +import { Navbar } from './Navbar' type Props = { + network: 'mainnet' | 'zen' children: React.ReactNode } -export function Layout({ children }: Props) { +export function Layout({ network, children }: Props) { return (
- + {!isMainnet && ( - + )} - +
{children} diff --git a/apps/explorer/config/index.ts b/apps/explorer/config/index.ts index d6ed5265a..b431cb333 100644 --- a/apps/explorer/config/index.ts +++ b/apps/explorer/config/index.ts @@ -1,10 +1,12 @@ import { webLinks } from '@siafoundation/design-system' +export const network = 'mainnet' export const networkName = 'Sia Mainnet' +export const siteName = 'siascan.com' export const appName = 'siascan' export const appLink = webLinks.explore.mainnet export const isMainnet = true // APIs -export const faucetApi = 'https://navigator.sia.tech/faucet/api' +export const faucetApi = 'https://faucet.zen.sia.tech/api' export const siaCentralApi = 'https://api.siacentral.com/v2' diff --git a/apps/explorer/config/testnet.ts b/apps/explorer/config/testnet.ts index 1744d65b6..bdf00befe 100644 --- a/apps/explorer/config/testnet.ts +++ b/apps/explorer/config/testnet.ts @@ -1,10 +1,12 @@ import { webLinks } from '@siafoundation/design-system' +export const network = 'zen' export const networkName = 'Zen Testnet' -export const appName = 'Zen Testnet' +export const siteName = 'zen.siascan.com' +export const appName = 'siascan' export const appLink = webLinks.explore.testnet export const isMainnet = false // APIs -export const faucetApi = 'https://navigator-zen.sia.tech/faucet/api' +export const faucetApi = 'https://faucet.zen.sia.tech/api' export const siaCentralApi = 'https://api.siacentral.com/v2/zen' diff --git a/apps/explorer/lib/utils.ts b/apps/explorer/lib/utils.ts index 66a87fdec..812f14a74 100644 --- a/apps/explorer/lib/utils.ts +++ b/apps/explorer/lib/utils.ts @@ -1,7 +1,7 @@ import { EntityType } from '@siafoundation/design-system' import { routes } from '../config/routes' import { Metadata } from 'next' -import { appName } from '../config' +import { siteName } from '../config' export function getHref(type: EntityType, value: string) { return routes[type].view.replace(':id', value) @@ -23,7 +23,7 @@ export function buildMetadata({ title, description, url, - siteName: appName, + siteName: siteName, }, } } diff --git a/libs/design-system/src/index.ts b/libs/design-system/src/index.ts index 845f12834..625d6b539 100644 --- a/libs/design-system/src/index.ts +++ b/libs/design-system/src/index.ts @@ -1,7 +1,6 @@ // core export * from './core/Accordion' export * from './core/Alert' -export * from './core/NavbarSite' export * from './core/Avatar' export * from './core/Badge' export * from './core/Button'