corso/website/src/pages/index.js
Georgi Matev a7a0ebf017
Force home page to dark mode while allowing choice for other pages (#1810)
## Description

Force home page to dark mode while allowing choice for other pages

## Does this PR need a docs update or release note?

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No 

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [ ] 🐹 Trivial/Minor

## Issue(s)

## Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
2022-12-14 17:23:22 +00:00

34 lines
994 B
JavaScript

import React, { useEffect } from "react";
import Layout from "@theme/Layout";
import { MainComp } from "@site/src/components/parts/MainComp";
import { useColorMode } from '@docusaurus/theme-common';
const ThemeColor = () => {
const { colorMode, setColorMode } = useColorMode();
useEffect(function () {
if (window.location.pathname === '/') {
if (colorMode !== 'dark') {
//force dark theme to home page without overriding user settings
setColorMode('dark', { persist: false })
}
} else {
setColorMode(localStorage.getItem('theme'))
}
});
return null
};
export default function Home() {
return (
<Layout
title="Free, Secure, and Open-Source Backup for Microsoft 365"
description="Intro, docs, and blog for Corso, an open-source tool, that protects Microsoft 365 data by securely and efficiently backing up all business-critical data to object storage."
>
<ThemeColor />
<MainComp />
</Layout>
);
}