Skip to content

Commit 22debb2

Browse files
committed
feat: add index page for product landing page behind a feature flag
`/p` will only be reachable in `development` and `staging` environment
1 parent ec13218 commit 22debb2

File tree

8 files changed

+40
-12
lines changed

8 files changed

+40
-12
lines changed

frontend/components/BcFeatureFlag.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<script setup lang="ts">
2-
import type { FeatureFlag } from '~/types/feature-flags'
3-
42
const props = defineProps<{
53
feature: FeatureFlag,
64
}>()

frontend/composables/useFeatureFlag.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import type { FeatureFlag } from '~/types/feature-flags'
1+
export type FeatureFlag
2+
= | 'feature-account_dashboards'
3+
| 'feature-product-landing'
4+
| 'feature-user_settings'
25

36
export const useFeatureFlag = () => {
4-
type Environment = 'development' | 'production' | 'staging'
5-
6-
const currentEnvironment = useRuntimeConfig().public.deploymentType as Environment
7+
const currentEnvironment = useRuntimeConfig().public.deploymentType
78
if (!currentEnvironment) {
89
throw createError('Environment variable `deploymentType` is not provided.')
910
}
1011

11-
const staging: FeatureFlag[] = []
12+
const staging: FeatureFlag[] = [ 'feature-product-landing' ]
1213
const development: FeatureFlag[] = [
1314
...staging,
1415
'feature-account_dashboards',
1516
'feature-user_settings',
1617
]
17-
const featureCatalog: Record<Environment, FeatureFlag[]> = {
18+
const featureCatalog: Record<typeof currentEnvironment, FeatureFlag[]> = {
1819
development,
1920
production: [],
2021
staging,

frontend/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module 'nuxt/schema' {
2+
interface PublicRuntimeConfig {
3+
deploymentType?: 'development' | 'production' | 'staging',
4+
}
5+
}
6+
export {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script setup lang="ts">
2+
</script>
3+
4+
<template>
5+
<div>
6+
<NuxtLayout name="base">
7+
Product Landing Page
8+
<div>
9+
<BaseButton>
10+
Get Started
11+
</BaseButton>
12+
</div>
13+
</NuxtLayout>
14+
</div>
15+
</template>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default defineNuxtConfig({
2+
$meta: {
3+
name: 'products',
4+
},
5+
})

frontend/middleware/redirect.global.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export default function ({
3838
return redirectToV1('/')
3939
case 'mobile':
4040
return redirectToV1('/mobile')
41+
case 'p':
42+
case 'product':
43+
if (!has('feature-product-landing')) {
44+
return abortNavigation()
45+
}
46+
break
4147
case 'privacy':
4248
return redirect('https://storage.googleapis.com/legal.beaconcha.in/privacy.pdf')
4349
case 'register':

frontend/nuxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default defineNuxtConfig({
6060
apiClient: process.env.PUBLIC_API_CLIENT,
6161
apiKey: process.env.PUBLIC_API_KEY,
6262
chainIdByDefault: process.env.PUBLIC_CHAIN_ID_BY_DEFAULT,
63-
deploymentType: process.env.PUBLIC_DEPLOYMENT_TYPE,
63+
deploymentType: process.env.PUBLIC_DEPLOYMENT_TYPE as undefined,
6464
domain: process.env.PUBLIC_DOMAIN,
6565
gitVersion,
6666
isApiMocked: '',

frontend/types/feature-flags.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)