-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathindex.js
More file actions
177 lines (151 loc) · 6.02 KB
/
Copy pathindex.js
File metadata and controls
177 lines (151 loc) · 6.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// _____________________________________________________________________
// Serafin O. Gargantiel III - Contribution
// Refactored UI Design
// _____________________________________________________________________
// Imports for React and Docusaurus Resources
import React, { useEffect } from 'react'
import clsx from 'clsx'
import Layout from '@theme/Layout'
import Link from '@docusaurus/Link'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
import useBaseUrl from '@docusaurus/useBaseUrl'
import Translate from '@docusaurus/Translate'
// Import of swiper, the carousel/slider library
import { Swiper, SwiperSlide } from 'swiper/react'
import { Autoplay } from 'swiper'
import 'swiper/css'
import 'swiper/css/pagination'
// Custom components and data
import Feature from './components/Feature'
import StructuredData from '../components/StructuredData'
import styles from './styles.module.css'
import { features } from '../constants'
// _____________________________________________________________________
//Home() - A refactored UI blog design for the site's home page
function Home() {
const context = useDocusaurusContext() //Access site's global configuration (docusarus.config.js)
useEffect(() => autoRedirect(), []) //Calls autoRedirect function when page loads
const { siteConfig = {} } = context //Pulls the site's configuration from the context
// Return UI/UX Design
// ________________________________________________________________________________________________
return (
<>
{/* Injects SEO metadata into the page head */}
{/* Search Engine Optization */}
<StructuredData />
<Layout
title={`${siteConfig.title} · ${siteConfig.tagline}`}
description={`${siteConfig.tagline}`}
>
{/* Hero Section */}
{/* --------------------------------------------------------- */}
{/* Banners with Site Title */}
<header className={clsx('hero--primary', styles.heroBanner)}>
<div className="container">
<h1 className="hero__title">
{/* Image Logo */}
<img
src={'/img/hertzbeat-brand.svg'}
alt={'HertzBeat Logo'}
/>
</h1>
{/* Slogan Sub-Title */}
<p className="hero__subtitle">
<Translate>slogan</Translate>
</p>
{/* QuickStart Button */}
<div className={styles.buttons}>
<Link
to="/docs/"
className={clsx(
'button button--primary button--lg'
)}
>
<Translate>quickstart</Translate>
</Link>
</div>
</div>
</header>
{/* --------------------------------------------------------- */}
<main>
{/* Features Section */}
{features && features.length > 0 && (
<section className={styles.featuresSection}>
{/* Feature Cards */}
<div className="container">
<div className={styles.featuresRow}>
{features.map((props, idx) => (
<Feature key={idx} {...props} index={idx} />
))}
</div>
</div>
</section>
)}
{/* Swiper Carousel Section - Helps Create Image Slideshows for HertzBeat*/}
<div className={styles.swiperContainer}>
<div className={styles.swiperInner}>
{/* Swiper - Autoplays Image Slideshow */}
<Swiper
modules={[Autoplay]}
grabCursor
loop={true}
speed={600}
autoplay={{
delay: 6000,
disableOnInteraction: false,
}}
>
{/* Each Image Presented in the Swiper */}
<SwiperSlide>
<img
src={useBaseUrl('/img/docs/hertzbeat-arch.png')}
alt="HertzBeat Architecture"
/>
</SwiperSlide>
<SwiperSlide>
<img
src={useBaseUrl('/img/home/status.png')}
alt="Monitoring Status"
/>
</SwiperSlide>
<SwiperSlide>
<img
src={useBaseUrl('/img/home/0.png')}
alt="Dashboard Overview"
/>
</SwiperSlide>
<SwiperSlide>
<img
src={useBaseUrl('/img/home/1.png')}
alt="Feature Demo"
/>
</SwiperSlide>
<SwiperSlide>
<img
src={useBaseUrl('/img/home/9.png')}
alt="Advanced Features"
/>
</SwiperSlide>
</Swiper>
</div>
</div>
</main>
</Layout>
</>
)
// ________________________________________________________________________________________________
}
export default Home
// AutoRedirect() - Detects the user's browser language on page load
function autoRedirect() {
// User Language
let lang = global.navigator?.language || navigator?.userLanguage
// If language is chinese, redirect to "/zh-cn" version of the site
if (lang != null && (lang.toLowerCase() === 'zh-cn' || lang.toLowerCase().indexOf('zh') > 0)) {
console.log(window.location.pathname);
if (sessionStorage.getItem('auto_detect_redirect') !== 'true' && !window.location.pathname.startsWith('/zh-cn', false)) {
sessionStorage.setItem('auto_detect_redirect', 'true')
window.location.href = '/zh-cn'
}
}
}