damus.io

damus.io website
git clone git://jb55.com/damus.io
Log | Files | Refs | README | LICENSE

index.tsx (1796B)


      1 import Image from 'next/image'
      2 import { Inter } from 'next/font/google'
      3 import { Hero } from '@/components/sections/Hero'
      4 import Head from "next/head";
      5 import { IntlProvider, useIntl } from 'react-intl'
      6 import English from "../../content/compiled-locales/en.json";
      7 import Japanese from "../../content/compiled-locales/ja.json";
      8 import { BannedInChina } from '@/components/sections/BannedInChina'
      9 import { DamusOnMedia } from '@/components/sections/DamusOnMedia';
     10 import { MeetTheTeam } from '@/components/sections/MeetTheTeam';
     11 import { DamusAroundTheWorld } from '@/components/sections/DamusAroundTheWorld';
     12 import { Footer } from '@/components/sections/Footer';
     13 import { DamusLiveEvents } from '@/components/sections/DamusLiveEvents';
     14 import { Contribute } from '@/components/sections/Contribute';
     15 import { FinalCTA } from '@/components/sections/FinalCTA';
     16 import { Benefits } from '@/components/sections/Benefits';
     17 import { Home } from '@/components/pages/home';
     18 import { useEffect, useMemo } from 'react';
     19 import { useState } from 'react';
     20 
     21 const inter = Inter({ subsets: ['latin'] })
     22 
     23 export default function HomePage() {
     24   // Automatically detect the user's locale based on their browser settings
     25   const [language, setLanguage] = useState("en");
     26   const [messages, setMessages] = useState(English);
     27 
     28   useEffect(() => {
     29     setLanguage(navigator.language);
     30   }, []);
     31 
     32   useEffect(() => {
     33     switch (language) {
     34       case "en":
     35         setMessages(English as any);
     36         break;
     37       case "ja":
     38         setMessages(Japanese as any);
     39         break;
     40       default:
     41         setMessages(English);
     42         break;
     43     }
     44   }, [language]);
     45 
     46   return (<>
     47     <IntlProvider
     48       locale={language}
     49       messages={messages}
     50       onError={() => null}>
     51       <Home />
     52     </IntlProvider>
     53   </>)
     54 }