From dc43516488e927eeeb713ad78f54e25ad90199df Mon Sep 17 00:00:00 2001 From: swarooppatilx Date: Sun, 26 Oct 2025 17:16:40 +0530 Subject: [PATCH] feat: improve seo by adding per page metadata --- .../blockexplorer/address/[address]/page.tsx | 7 +++++++ packages/nextjs/app/blockexplorer/layout.tsx | 12 ++++++++---- .../transaction/[txHash]/page.tsx | 8 +++++++- packages/nextjs/app/debug/page.tsx | 13 ++++++++----- packages/nextjs/app/head.tsx | 17 +++++++++++++++++ packages/nextjs/app/layout.tsx | 5 +++++ packages/nextjs/app/sitemap.ts | 12 ++++++++++++ packages/nextjs/public/robots.txt | 2 +- packages/nextjs/public/sitemap.xml | 18 ------------------ 9 files changed, 65 insertions(+), 29 deletions(-) create mode 100644 packages/nextjs/app/head.tsx create mode 100644 packages/nextjs/app/sitemap.ts delete mode 100644 packages/nextjs/public/sitemap.xml diff --git a/packages/nextjs/app/blockexplorer/address/[address]/page.tsx b/packages/nextjs/app/blockexplorer/address/[address]/page.tsx index ca4566b..bd22a4e 100644 --- a/packages/nextjs/app/blockexplorer/address/[address]/page.tsx +++ b/packages/nextjs/app/blockexplorer/address/[address]/page.tsx @@ -1,4 +1,5 @@ import fs from "fs"; +import type { Metadata } from "next"; import path from "path"; import { Address } from "viem"; import { hardhat } from "viem/chains"; @@ -7,6 +8,12 @@ import deployedContracts from "~~/contracts/deployedContracts"; import { isZeroAddress } from "~~/utils/scaffold-eth/common"; import { GenericContractsDeclaration } from "~~/utils/scaffold-eth/contract"; +export const metadata: Metadata = { + robots: { index: false, follow: false }, + title: "Block Explorer — Address", + description: "Local-only block explorer address details", +}; + type PageProps = { params: Promise<{ address: Address }>; }; diff --git a/packages/nextjs/app/blockexplorer/layout.tsx b/packages/nextjs/app/blockexplorer/layout.tsx index c526f28..e622cd9 100644 --- a/packages/nextjs/app/blockexplorer/layout.tsx +++ b/packages/nextjs/app/blockexplorer/layout.tsx @@ -1,9 +1,13 @@ +import type { Metadata } from "next"; import { getMetadata } from "~~/utils/scaffold-eth/getMetadata"; -export const metadata = getMetadata({ - title: "BugChan", - description: "Block Explorer created with 🏗 Scaffold-ETH 2", -}); +export const metadata: Metadata = { + ...getMetadata({ + title: "Block Explorer", + description: "Local-only block explorer utilities", + }), + robots: { index: false, follow: false }, +}; const BlockExplorerLayout = ({ children }: { children: React.ReactNode }) => { return <>{children}; diff --git a/packages/nextjs/app/blockexplorer/transaction/[txHash]/page.tsx b/packages/nextjs/app/blockexplorer/transaction/[txHash]/page.tsx index 8e2c2eb..313b2cf 100644 --- a/packages/nextjs/app/blockexplorer/transaction/[txHash]/page.tsx +++ b/packages/nextjs/app/blockexplorer/transaction/[txHash]/page.tsx @@ -1,8 +1,14 @@ import TransactionComp from "../_components/TransactionComp"; -import type { NextPage } from "next"; +import type { Metadata, NextPage } from "next"; import { Hash } from "viem"; import { isZeroAddress } from "~~/utils/scaffold-eth/common"; +export const metadata: Metadata = { + robots: { index: false, follow: false }, + title: "Block Explorer — Transaction", + description: "Local-only block explorer transaction details", +}; + type PageProps = { params: Promise<{ txHash?: Hash }>; }; diff --git a/packages/nextjs/app/debug/page.tsx b/packages/nextjs/app/debug/page.tsx index e6fb89f..c39ccc7 100644 --- a/packages/nextjs/app/debug/page.tsx +++ b/packages/nextjs/app/debug/page.tsx @@ -1,11 +1,14 @@ import { DebugContracts } from "./_components/DebugContracts"; -import type { NextPage } from "next"; +import type { Metadata, NextPage } from "next"; import { getMetadata } from "~~/utils/scaffold-eth/getMetadata"; -export const metadata = getMetadata({ - title: "Debug Contracts", - description: "Debug your deployed 🏗 Scaffold-ETH 2 contracts in an easy way", -}); +export const metadata: Metadata = { + ...getMetadata({ + title: "Debug Contracts", + description: "Debug your deployed 🏗 Scaffold-ETH 2 contracts in an easy way", + }), + robots: { index: false, follow: false }, +}; const Debug: NextPage = () => { return ( diff --git a/packages/nextjs/app/head.tsx b/packages/nextjs/app/head.tsx new file mode 100644 index 0000000..754c696 --- /dev/null +++ b/packages/nextjs/app/head.tsx @@ -0,0 +1,17 @@ +export default function Head() { + const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://bugchan.xyz"; + const orgJsonLd = { + "@context": "https://schema.org", + "@type": "Organization", + name: "BugChan", + url: siteUrl, + logo: `${siteUrl}/logo.svg`, + sameAs: ["https://x.com", "https://github.com", "https://linkedin.com"], + }; + + return ( + <> +