Skip to content

Commit

Permalink
chore: Remove deprecated code and environment variables
Browse files Browse the repository at this point in the history
This commit removes deprecated code and environment variables that are no longer used in the application. The `.env`, `.env.local`, and `.env.production` files have been updated to remove the `NEXT_PUBLIC_BASE` and `NEXT_PUBLIC_ANALYTICS` variables. Additionally, the `inter` font import in the `layout.tsx` file has been removed, as it is no longer needed. The `useTitle` hook in the `useTitle.tsx` file has been marked as deprecated and a comment has been added to suggest using Next.js metadata instead. Finally, the `base` property in the `environment.ts` file has been removed, as it is no longer used.
  • Loading branch information
codemile committed Jun 1, 2024
1 parent 025bb50 commit 8b0face
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 27 deletions.
2 changes: 0 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
NEXT_PUBLIC_BRAND_NAME=Tetromino
NEXT_PUBLIC_GITHUB=https://github.com/reactgular/tetromino
NEXT_PUBLIC_STORAGE_KEY=tetromino
# Base path for loading audio files
NEXT_PUBLIC_BASE=/tetromino
NEXT_PUBLIC_ANALYTICS=
1 change: 0 additions & 1 deletion .env.local
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
NEXT_PUBLIC_BASE=/
NEXT_PUBLIC_ANALYTICS=
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Please change to your Google Analytics ID
NEXT_PUBLIC_ANALYTICS=UA-141015392-3
NEXT_PUBLIC_ANALYTICS=
13 changes: 5 additions & 8 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import type {Metadata} from 'next';
import {Inter} from 'next/font/google';
import './globals.css';

const inter = Inter({subsets: ['latin']});
import {PropsWithChildren} from 'react';
import {environment} from '../environment/environment';

export const metadata: Metadata = {
title: 'Create Next App',
title: `${environment.brandName}`,
description: 'Generated by create next app'
};

export default function RootLayout({
children
}: Readonly<{
children: React.ReactNode;
}>) {
}: Readonly<PropsWithChildren>) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
<body>{children}</body>
</html>
);
}
3 changes: 3 additions & 0 deletions src/components/particles/hooks/useTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const STATUS_TITLE = {
[GameStatus.FINISHED]: 'Game Over'
};

/**
* @deprecated use NextJs metadata instead
*/
export const useTitle = () => {
const status = useSelector(GameSelectors.status);
const title = useMemo(
Expand Down
16 changes: 1 addition & 15 deletions src/environment/environment.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,16 @@
const endsInSlash = (str: string): string => str.endsWith('/') ? str : `${str}/`;

export interface Environment {
analytics: string;

/**
* @deprecated use basePath from router instead
*/
base: string;

brandName: string;

github: string;

storageKey: string;

/**
* @deprecated
*/
version: string;
}

export const environment: Environment = {
analytics: process.env.NEXT_PUBLIC_ANALYTICS as string,
brandName: process.env.NEXT_PUBLIC_BRAND_NAME as string,
github: process.env.NEXT_PUBLIC_GITHUB as string,
storageKey: process.env.NEXT_PUBLIC_STORAGE_KEY as string,
version: process.env.NEXT_PUBLIC_VERSION as string,
base: endsInSlash(process.env.NEXT_PUBLIC_BASE as string ?? '/')
storageKey: process.env.NEXT_PUBLIC_STORAGE_KEY as string
};

0 comments on commit 8b0face

Please sign in to comment.