+
);
-}
+}
\ No newline at end of file
diff --git a/apps/website/src/github-utils.ts b/apps/website/src/github-utils.ts
new file mode 100644
index 000000000..b34925ce8
--- /dev/null
+++ b/apps/website/src/github-utils.ts
@@ -0,0 +1,15 @@
+const API_URL = "https://api.github.com/repos/TriliumNext/Trilium";
+
+/** Returns the number of stargazers of the Trilium's GitHub repository. */
+export async function getRepoStargazersCount() {
+ const response = await fetch(API_URL);
+
+ if (response.ok) {
+ const details = await response.json();
+ if ("stargazers_count" in details) {
+ return details["stargazers_count"];
+ }
+ }
+
+ return 31862; // The count as of 2025-10-03
+}
\ No newline at end of file
diff --git a/apps/website/src/index.tsx b/apps/website/src/index.tsx
index 9dc5edfb1..ae1d46a87 100644
--- a/apps/website/src/index.tsx
+++ b/apps/website/src/index.tsx
@@ -1,17 +1,17 @@
-import { LocationProvider, Router, Route, hydrate, prerender as ssr } from 'preact-iso';
-
+import './style.css';
+import { getRepoStargazersCount } from './github-utils.js';
import { Header } from './components/Header.jsx';
import { Home } from './pages/Home/index.jsx';
+import { LocationProvider, Router, Route, hydrate, prerender as ssr } from 'preact-iso';
import { NotFound } from './pages/_404.jsx';
-import './style.css';
import Footer from './components/Footer.js';
import GetStarted from './pages/GetStarted/get-started.js';
import SupportUs from './pages/SupportUs/SupportUs.js';
-export function App() {
+export function App(props: {repoStargazersCount: number}) {
return (
-
+
@@ -26,9 +26,15 @@ export function App() {
}
if (typeof window !== 'undefined') {
- hydrate(, document.getElementById('app')!);
+ hydrate(, document.getElementById('app')!);
}
export async function prerender(data) {
- return await ssr();
+ // Fetch the stargazer count of the Trilium's GitHub repo on prerender to pass
+ // it to the App component for SSR.
+ // This ensures the GitHub API is not called on every page load in the client.
+ const stargazersCount = await getRepoStargazersCount();
+
+ return await ssr();
}
+