1+ import React , { type ReactNode } from 'react' ;
2+ import { useLocation } from '@docusaurus/router' ;
3+ import { useThemeConfig } from '@docusaurus/theme-common' ;
4+ import clsx from 'clsx' ;
5+ import styles from './styles.module.scss' ;
6+
7+ interface ProductConfig {
8+ name : string ;
9+ description : string ;
10+ }
11+
12+ const PRODUCT_CONFIGS : Record < string , ProductConfig > = {
13+ '/sdk/' : {
14+ name : 'MetaMask SDK documentation' ,
15+ description : 'Seamlessly connect to the MetaMask extension and MetaMask Mobile using the SDK.' ,
16+ } ,
17+ '/wallet/' : {
18+ name : 'Wallet API documentation' ,
19+ description : 'Directly integrate your dapp with the MetaMask extension using the Wallet API.' ,
20+ } ,
21+ '/delegation-toolkit/' : {
22+ name : 'MetaMask Delegation Toolkit documentation' ,
23+ description : 'Embed MetaMask smart accounts with new web3 experiences into your dapp.' ,
24+ } ,
25+ '/snaps/' : {
26+ name : 'Snaps documentation' ,
27+ description : 'Create a custom Snap to extend the functionality of MetaMask.' ,
28+ } ,
29+ '/services/' : {
30+ name : 'Services documentation' ,
31+ description : 'Use services provided by MetaMask and Infura to optimize essential development tasks and scale your dapp or Snap.' ,
32+ } ,
33+ '/developer-tools/dashboard/' : {
34+ name : 'Developer dashboard documentation' ,
35+ description : 'Manage Infura API keys, monitor usage, and access account details in the developer dashboard.' ,
36+ } ,
37+ } ;
38+
39+ function getProductConfig ( pathname : string ) : ProductConfig | null {
40+ for ( const [ path , config ] of Object . entries ( PRODUCT_CONFIGS ) ) {
41+ if ( pathname . startsWith ( path ) ) {
42+ return config ;
43+ }
44+ }
45+ return null ;
46+ }
47+
48+ export default function ProductBanner ( ) : ReactNode | null {
49+ const location = useLocation ( ) ;
50+ const productConfig = getProductConfig ( location . pathname ) ;
51+ const { navbar} = useThemeConfig ( ) ;
52+
53+ if ( ! productConfig ) {
54+ return null ;
55+ }
56+
57+ return (
58+ < div className = { clsx ( styles . productBanner ) } >
59+ < div className = { styles . productBannerContent } >
60+ < h2 className = { styles . productName } > { productConfig . name } </ h2 >
61+ < p className = { styles . productDescription } > { productConfig . description } </ p >
62+ </ div >
63+ </ div >
64+ ) ;
65+ }
0 commit comments