@@ -3,23 +3,6 @@ import { Helmet } from "react-helmet-async";
33const DEFAULT_TITLE = "UpLine" ;
44const TITLE_SEPARATOR = " - " ;
55
6- /**
7- * Utility function to build title from parts
8- */
9- export function buildTitle ( title ?: string , prefix ?: string ) : string {
10- const parts = [ DEFAULT_TITLE ] ;
11-
12- if ( title ) {
13- parts . unshift ( title ) ;
14- }
15-
16- if ( prefix ) {
17- parts . unshift ( prefix ) ;
18- }
19-
20- return parts . join ( TITLE_SEPARATOR ) ;
21- }
22-
236/**
247 * Component to set the page title and meta tags using Helmet
258 */
@@ -31,7 +14,6 @@ interface PageTitleProps {
3114
3215export function PageTitle ( { title, prefix, description } : PageTitleProps ) {
3316 const fullTitle = buildTitle ( title , prefix ) ;
34-
3517 return (
3618 < Helmet >
3719 < title > { fullTitle } </ title >
@@ -43,3 +25,44 @@ export function PageTitle({ title, prefix, description }: PageTitleProps) {
4325 </ Helmet >
4426 ) ;
4527}
28+
29+ /**
30+ * Get environment prefix based on current hostname
31+ */
32+ function getEnvironmentPrefix ( ) : string | undefined {
33+ if ( typeof window === "undefined" ) return undefined ;
34+
35+ const hostname = window . location . hostname ;
36+
37+ if ( hostname === "localhost" || hostname === "127.0.0.1" ) {
38+ return "LOCAL" ;
39+ }
40+
41+ if ( ! hostname . includes ( "getupline.com" ) ) {
42+ return "DEV" ;
43+ }
44+
45+ return undefined ;
46+ }
47+
48+ /**
49+ * Utility function to build title from parts
50+ */
51+ function buildTitle ( title ?: string , prefix ?: string ) : string {
52+ const parts = [ DEFAULT_TITLE ] ;
53+
54+ if ( title ) {
55+ parts . unshift ( title ) ;
56+ }
57+
58+ if ( prefix ) {
59+ parts . unshift ( prefix ) ;
60+ }
61+
62+ const envPrefix = getEnvironmentPrefix ( ) ;
63+ if ( envPrefix ) {
64+ parts . unshift ( envPrefix ) ;
65+ }
66+
67+ return parts . join ( TITLE_SEPARATOR ) ;
68+ }
0 commit comments