|
| 1 | +import { providerEndpoints } from 'src/config/chainEndpoints'; |
| 2 | +import { capitalize } from './../hooks/helper/common'; |
| 3 | +import { LOCAL_STORAGE } from './localStorage'; |
| 4 | +import { Path } from 'src/router'; |
| 5 | + |
| 6 | +interface MetaData { |
| 7 | + title: string; |
| 8 | + meta: { |
| 9 | + description: { |
| 10 | + name: string; |
| 11 | + content: string; |
| 12 | + }; |
| 13 | + }; |
| 14 | +} |
| 15 | + |
| 16 | +export const opengraphMeta = (displayName: string, networkName: string) => { |
| 17 | + return { |
| 18 | + ogTitle: { |
| 19 | + property: 'og:title', |
| 20 | + template() { |
| 21 | + return `${networkName} Portal - ${displayName}`; |
| 22 | + }, |
| 23 | + }, |
| 24 | + ogDescription: { |
| 25 | + property: 'og:description', |
| 26 | + template() { |
| 27 | + return `Your one-stop platform for the ${networkName} ecosystem - Wallet / Staking / Bridging`; |
| 28 | + }, |
| 29 | + }, |
| 30 | + ogSiteName: { |
| 31 | + property: 'og:site_name', |
| 32 | + template() { |
| 33 | + return `${networkName} Portal`; |
| 34 | + }, |
| 35 | + }, |
| 36 | + }; |
| 37 | +}; |
| 38 | + |
| 39 | +const networkIdx = localStorage.getItem(LOCAL_STORAGE.NETWORK_IDX); |
| 40 | +const currency = localStorage.getItem(LOCAL_STORAGE.DEFAULT_CURRENCY); |
| 41 | + |
| 42 | +const networkName = capitalize(providerEndpoints[Number(networkIdx)].networkAlias); |
| 43 | + |
| 44 | +export const meta = { |
| 45 | + title: { |
| 46 | + assets: { |
| 47 | + assets: 'Assets', |
| 48 | + transfer: 'Transfer', |
| 49 | + xvmTransfer: 'XVM Transfer', |
| 50 | + }, |
| 51 | + dashboard: 'Dashboard', |
| 52 | + dappsStaking: { |
| 53 | + dappStaking: 'Dapp Staking', |
| 54 | + discoverDapps: 'Discover dApps', |
| 55 | + registerDapp: 'Register dApp', |
| 56 | + stake: 'Stake', |
| 57 | + }, |
| 58 | + }, |
| 59 | + description: { |
| 60 | + assets: `${networkName} Portal is the hub of multi-chain, one-stop platform for managing assets and dApp Staking - build2earn protocol. Asset page provides seem less cross-chain transfers using Polkadot unique technology XCM as well as newly invented Cross Virtual Machine technology XVM.`, |
| 61 | + dappsStaking: `${networkName} dApp Staking is a unique protocol that designed to support builders by providing basic income. Build2Earn program sustains the early stage of builders as well as rewarding the successful projects`, |
| 62 | + dashboard: `${networkName} Portal is the hub of multi-chain, one-stop platform for managing assets and dApp Staking - build2earn protocol. Dashboard page provides statics of ${currency}, blocks of the ${networkName} Network and TVL.`, |
| 63 | + }, |
| 64 | +}; |
| 65 | + |
| 66 | +const buildMeta = ({ title, content }: { title: string; content: string }) => { |
| 67 | + return { |
| 68 | + title, |
| 69 | + meta: { |
| 70 | + description: { |
| 71 | + name: 'description', |
| 72 | + content, |
| 73 | + }, |
| 74 | + }, |
| 75 | + }; |
| 76 | +}; |
| 77 | + |
| 78 | +export const generateMeta = (path: Path): MetaData => { |
| 79 | + switch (path) { |
| 80 | + case Path.Assets: |
| 81 | + return buildMeta({ |
| 82 | + title: meta.title.assets.assets, |
| 83 | + content: meta.description.assets, |
| 84 | + }); |
| 85 | + |
| 86 | + case Path.Transfer: |
| 87 | + return buildMeta({ |
| 88 | + title: meta.title.assets.transfer, |
| 89 | + content: meta.description.assets, |
| 90 | + }); |
| 91 | + |
| 92 | + case Path.XvmTransfer: |
| 93 | + return buildMeta({ |
| 94 | + title: meta.title.assets.xvmTransfer, |
| 95 | + content: meta.description.assets, |
| 96 | + }); |
| 97 | + |
| 98 | + case Path.Discover: |
| 99 | + return buildMeta({ |
| 100 | + title: meta.title.dappsStaking.discoverDapps, |
| 101 | + content: meta.description.dappsStaking, |
| 102 | + }); |
| 103 | + |
| 104 | + case Path.Dapp: |
| 105 | + return buildMeta({ |
| 106 | + title: meta.title.dappsStaking.dappStaking, |
| 107 | + content: meta.description.dappsStaking, |
| 108 | + }); |
| 109 | + |
| 110 | + case Path.Dashboard: |
| 111 | + return buildMeta({ |
| 112 | + title: meta.title.dashboard, |
| 113 | + content: meta.description.dashboard, |
| 114 | + }); |
| 115 | + |
| 116 | + case Path.Register: |
| 117 | + return buildMeta({ |
| 118 | + title: meta.title.dappsStaking.registerDapp, |
| 119 | + content: meta.description.dappsStaking, |
| 120 | + }); |
| 121 | + |
| 122 | + case Path.Stake: |
| 123 | + return buildMeta({ |
| 124 | + title: meta.title.dappsStaking.stake, |
| 125 | + content: meta.description.dappsStaking, |
| 126 | + }); |
| 127 | + |
| 128 | + default: |
| 129 | + return buildMeta({ |
| 130 | + title: meta.title.assets.assets, |
| 131 | + content: meta.description.assets, |
| 132 | + }); |
| 133 | + } |
| 134 | +}; |
0 commit comments