Skip to content

Commit dbfa94a

Browse files
committed
fix(website): missing suspense
1 parent 86aaa97 commit dbfa94a

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

apps/website/src/components/Header.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import menuIcon from "../assets/boxicons/bx-menu.svg?raw";
1111
import { LocaleContext } from "..";
1212
import { useTranslation } from "react-i18next";
1313
import { swapLocaleInUrl } from "../i18n";
14+
import { Suspense } from "preact/compat";
1415

1516
interface HeaderLink {
1617
url: string;
@@ -78,7 +79,9 @@ export function Header(props: {repoStargazersCount: number}) {
7879
/>
7980
</div>
8081

81-
<DownloadButton />
82+
<Suspense fallback={<div class="loading-screen">Loading...</div>}>
83+
<DownloadButton />
84+
</Suspense>
8285

8386
</div>
8487
</header>

apps/website/src/index.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,33 @@ import { default as i18next, changeLanguage } from 'i18next';
1313
import { extractLocaleFromUrl, LOCALES, mapLocale } from './i18n';
1414
import HttpApi from 'i18next-http-backend';
1515
import { initReactI18next } from "react-i18next";
16+
import { Suspense } from 'preact/compat';
1617

1718
export const LocaleContext = createContext('en');
1819

1920
export function App(props: {repoStargazersCount: number}) {
2021
return (
21-
<LocationProvider>
22-
<LocaleProvider>
23-
<Header repoStargazersCount={props.repoStargazersCount} />
24-
<main>
25-
<Router>
26-
<Route path="/" component={Home} />
27-
<Route path="/get-started" component={GetStarted} />
28-
<Route path="/support-us" component={SupportUs} />
22+
<LocationProvider>
23+
<LocaleProvider>
24+
<Suspense fallback={<div class="loading-screen">Loading...</div>}>
25+
<Header repoStargazersCount={props.repoStargazersCount} />
26+
<main>
27+
<Router>
28+
<Route path="/" component={Home} />
29+
<Route path="/get-started" component={GetStarted} />
30+
<Route path="/support-us" component={SupportUs} />
2931

30-
<Route path="/:locale:/" component={Home} />
31-
<Route path="/:locale:/get-started" component={GetStarted} />
32-
<Route path="/:locale:/support-us" component={SupportUs} />
32+
<Route path="/:locale:/" component={Home} />
33+
<Route path="/:locale:/get-started" component={GetStarted} />
34+
<Route path="/:locale:/support-us" component={SupportUs} />
3335

34-
<Route default component={NotFound} />
35-
</Router>
36-
</main>
37-
<Footer />
38-
</LocaleProvider>
39-
</LocationProvider>
36+
<Route default component={NotFound} />
37+
</Router>
38+
</main>
39+
<Footer />
40+
</Suspense>
41+
</LocaleProvider>
42+
</LocationProvider>
4043
);
4144
}
4245

apps/website/src/pages/Home/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import presentationIcon from "../../assets/boxicons/bx-slideshow.svg?raw";
3333
import { getPlatform } from '../../download-helper.js';
3434
import { useEffect, useState } from 'preact/hooks';
3535
import { Trans, useTranslation } from 'react-i18next';
36+
import { Suspense } from 'preact/compat';
3637

3738
export function Home() {
3839
usePageTitle("");
@@ -79,7 +80,9 @@ function HeroSection() {
7980
<p>{t("hero_section.subtitle")}</p>
8081

8182
<div className="download-wrapper">
82-
<DownloadButton big />
83+
<Suspense fallback={<div class="loading-screen">Loading...</div>}>
84+
<DownloadButton big />
85+
</Suspense>
8386
<Button href="./get-started/" className="mobile-only" text={t("hero_section.get_started")} />
8487
<div className="additional-options">
8588
<Button iconSvg={gitHubIcon} outline text={t("hero_section.github")} href="https://github.com/TriliumNext/Trilium/" openExternally />

0 commit comments

Comments
 (0)