Skip to content

Commit

Permalink
feat: customize homepage env
Browse files Browse the repository at this point in the history
fix: add env at ENVS.md
  • Loading branch information
freepoi authored and atenjin committed Mar 20, 2024
1 parent 55a097c commit fc3476a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions configs/app/meta.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import app from './app';
import { getEnvValue, getExternalAssetFilePath } from './utils';
import { getEnvValue, getExternalAssetFilePath, parseEnvJson } from './utils';

const defaultImageUrl = app.baseUrl + '/static/og_placeholder.png';

const meta = Object.freeze({
promoteBlockscoutInTitle: getEnvValue('NEXT_PUBLIC_PROMOTE_BLOCKSCOUT_IN_TITLE') || 'true',
promoteBlockscoutInTitle: parseEnvJson<boolean>(getEnvValue('NEXT_PUBLIC_PROMOTE_BLOCKSCOUT_IN_TITLE')) ?? true,
og: {
description: getEnvValue('NEXT_PUBLIC_OG_DESCRIPTION') || '',
imageUrl: getExternalAssetFilePath('NEXT_PUBLIC_OG_IMAGE_URL') || defaultImageUrl,
Expand Down
2 changes: 2 additions & 0 deletions configs/app/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ const UI = Object.freeze({
frontendCommit: getEnvValue('NEXT_PUBLIC_GIT_COMMIT_SHA'),
},
homepage: {
title: getEnvValue('NEXT_PUBLIC_HOMEPAGE_TITLE') || 'blockchain explorer',
charts: parseEnvJson<Array<ChainIndicatorId>>(getEnvValue('NEXT_PUBLIC_HOMEPAGE_CHARTS')) || [],
plate: {
title: getEnvValue('NEXT_PUBLIC_HOMEPAGE_PLATE_TITLE') || `${ getEnvValue('NEXT_PUBLIC_NETWORK_NAME') } explorer`,
background: getEnvValue('NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND') || HOMEPAGE_PLATE_BACKGROUND_DEFAULT,
textColor: getEnvValue('NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR') || 'white',
},
Expand Down
2 changes: 2 additions & 0 deletions deploy/tools/envs-validator/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,13 @@ const schema = yup

// 4. UI configuration
// a. homepage
NEXT_PUBLIC_HOMEPAGE_TITLE: yup.string().optional(),
NEXT_PUBLIC_HOMEPAGE_CHARTS: yup
.array()
.transform(replaceQuotes)
.json()
.of(yup.string<ChainIndicatorId>().oneOf([ 'daily_txs', 'coin_price', 'market_cap', 'tvl' ])),
NEXT_PUBLIC_HOMEPAGE_PLATE_TITLE: yup.string().optional(),
NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR: yup.string(),
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND: yup.string(),
NEXT_PUBLIC_HOMEPAGE_SHOW_AVG_BLOCK_TIME: yup.boolean(),
Expand Down
2 changes: 2 additions & 0 deletions docs/ENVS.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ Please be aware that all environment variables prefixed with `NEXT_PUBLIC_` will
| NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR | `string` | Text color of the hero plate on the homepage (escape "#" symbol if you use HEX color codes or use rgba-value instead) | - | `white` | `\#DCFE76` |
| NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND | `string` | Background css value for hero plate on the homepage (escape "#" symbol if you use HEX color codes or use rgba-value instead) | - | `radial-gradient(103.03% 103.03% at 0% 0%, rgba(183, 148, 244, 0.8) 0%, rgba(0, 163, 196, 0.8) 100%), var(--chakra-colors-blue-400)` | `radial-gradient(at 15% 86%, hsla(350,65%,70%,1) 0px, transparent 50%)` \| `no-repeat bottom 20% right 0px/100% url(https://placekitten/1400/200)` |
| NEXT_PUBLIC_HOMEPAGE_SHOW_AVG_BLOCK_TIME | `boolean` | Set to false if average block time is useless for the network | - | `true` | `false` |
| NEXT_PUBLIC_HOMEPAGE_TITLE | `string` | Tab title for homepage | - | - | 'blockchain explorer' |
| NEXT_PUBLIC_HOMEPAGE_PLATE_TITLE | `string` | Plate title in homepage | - | - | `${NEXT_PUBLIC_NETWORK_NAME} explorer` |

&nbsp;

Expand Down
4 changes: 3 additions & 1 deletion lib/metadata/templates/title.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { Route } from 'nextjs-routes';

import config from 'configs/app';

const TEMPLATE_MAP: Record<Route['pathname'], string> = {
'/': 'blockchain explorer',
'/': config.UI.homepage.title,
'/txs': 'transactions',
'/txs/kettle/[hash]': 'kettle %hash% transactions',
'/tx/[hash]': 'transaction %hash%',
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Home = () => {
fontWeight={ 600 }
color={ config.UI.homepage.plate.textColor }
>
{ config.chain.name } explorer
{ config.UI.homepage.plate.title }
</Heading>
<Box display={{ base: 'none', lg: 'flex' }}>
{ config.features.account.isEnabled && <ProfileMenuDesktop isHomePage/> }
Expand Down

0 comments on commit fc3476a

Please sign in to comment.