Skip to content

Commit

Permalink
chore: Optimize seo (#1381)
Browse files Browse the repository at this point in the history
  • Loading branch information
oktapodia authored Oct 8, 2024
1 parent 4289478 commit 6c5f4d4
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 48 deletions.
69 changes: 28 additions & 41 deletions src/app/[lng]/scan/[[...segments]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,36 @@
'use client';
import { LiFiExplorer } from '@lifi/explorer';
import type { PaletteMode } from '@mui/material';
import { alpha, Box, useTheme } from '@mui/material';
import { useMemo } from 'react';
import { ClientOnly } from 'src/components/ClientOnly';
import { fallbackLng } from 'src/i18n';
import { JUMPER_SCAN_PATH } from '@/const/urls';
import ScanPage from '@/app/ui/scan/ScanPage';
import type { Metadata } from 'next';

export async function generateMetadata({
params: { segments },
}: {
params: {
segments: string[];
};
}): Promise<Metadata> {
const slugToTitle: { [key: string]: string } = {
tx: 'Transaction',
block: 'Block',
wallet: 'wallet',
};

const [slug, address] = segments;

return {
title: `Jumper Scan | ${slugToTitle[slug]} ${address}`,
description:
'Jumper Scan is a blockchain explorer that allows you to search and explore transactions, blocks, and wallets on multiple blockchains.',
alternates: {
canonical: `${process.env.NEXT_PUBLIC_SITE_URL}/scan/${segments.join('/')}`,
},
};
}

export default function Page({
params: { lng },
}: {
children: React.ReactNode;
params: { lng: string };
}) {
const theme = useTheme();

const explorerConfig = useMemo(
() => ({
appearance: 'light' as PaletteMode, //theme.palette.mode, // This controls light and dark mode
integrator: process.env.NEXT_PUBLIC_WIDGET_INTEGRATOR, // TODO: change as needed
base: `${lng !== fallbackLng ? `${lng}` : ''}${JUMPER_SCAN_PATH}`, // Important for the routing and having everything served under /scan. Do not remove!
theme: {
// These colors and values correspond to the figma design
shape: { borderRadiusSecondary: 900, borderRadius: 12 },
palette: {
background: {
default: alpha(theme.palette.white.main, 0.8),
paper: alpha(theme.palette.white.main, 0.8),
},
},
},
}),
[lng, theme.palette.mode, theme.palette.white.main],
);

return (
<ClientOnly>
<Box
sx={{
p: 4,
paddingBottom: 8,
}}
>
<LiFiExplorer config={explorerConfig} />
</Box>
</ClientOnly>
);
return <ScanPage lng={lng} />;
}
7 changes: 1 addition & 6 deletions src/app/[lng]/scan/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { ThemeProviderV2 } from '@/providers/ThemeProviderV2';
import { ThemeProvider as NextThemeProvider } from 'next-themes';
import { cookies } from 'next/headers';
import React from 'react';
import { Layout } from 'src/Layout';

export default async function PartnerThemeLayout({
export default async function RootLayout({
children,
params: { partnerTheme },
}: {
children: React.ReactNode;
params: { partnerTheme: string };
}) {
const cookiesHandler = cookies();

return (
<NextThemeProvider
themes={['light']}
Expand Down
44 changes: 44 additions & 0 deletions src/app/ui/scan/ScanPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use client';

import { ClientOnly } from '@/components/ClientOnly';
import { alpha, Box, type PaletteMode, useTheme } from '@mui/material';
import { LiFiExplorer } from '@lifi/explorer';
import { useMemo } from 'react';
import { fallbackLng } from 'src/i18n';
import { JUMPER_SCAN_PATH } from '@/const/urls';

export default function ScanPage({ lng }: { lng: string }) {
const theme = useTheme();

const explorerConfig = useMemo(
() => ({
appearance: 'light' as PaletteMode, //theme.palette.mode, // This controls light and dark mode
integrator: process.env.NEXT_PUBLIC_WIDGET_INTEGRATOR, // TODO: change as needed
base: `${lng !== fallbackLng ? `${lng}` : ''}${JUMPER_SCAN_PATH}`, // Important for the routing and having everything served under /scan. Do not remove!
theme: {
// These colors and values correspond to the figma design
shape: { borderRadiusSecondary: 900, borderRadius: 12 },
palette: {
background: {
default: alpha(theme.palette.white.main, 0.8),
paper: alpha(theme.palette.white.main, 0.8),
},
},
},
}),
[lng, theme.palette.mode, theme.palette.white.main],
);

return (
<ClientOnly>
<Box
sx={{
p: 4,
paddingBottom: 8,
}}
>
<LiFiExplorer config={explorerConfig} />
</Box>
</ClientOnly>
);
}
2 changes: 1 addition & 1 deletion src/components/Menus/WalletMenu/WalletCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const WalletCard = ({ account }: WalletCardProps) => {

const handleScanButton = () => {
account.chainId && closeAllMenus();
const url = `${JUMPER_SCAN_PATH}/wallet/${account.address}/`;
const url = `${JUMPER_SCAN_PATH}/wallet/${account.address}`;

trackEvent({
category: TrackingCategory.WalletMenu,
Expand Down

0 comments on commit 6c5f4d4

Please sign in to comment.