Skip to content

Commit 1889578

Browse files
authored
Merge pull request #412 from CREDO23/feature/github-stars-hook
[Feature] Fetch github repo starts dynamically
2 parents f9d5a9f + 9af7ea5 commit 1889578

File tree

7 files changed

+89
-20
lines changed

7 files changed

+89
-20
lines changed

surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ export default function BaiduSearchApiPage() {
153153
<CardHeader>
154154
<CardTitle className="text-2xl font-bold">Connect Baidu Search</CardTitle>
155155
<CardDescription>
156-
Integrate with Baidu AI Search to enhance your search capabilities with
157-
intelligent Chinese web search results.
156+
Integrate with Baidu AI Search to enhance your search capabilities with intelligent
157+
Chinese web search results.
158158
</CardDescription>
159159
</CardHeader>
160160
<CardContent>
@@ -224,13 +224,9 @@ export default function BaiduSearchApiPage() {
224224
<SelectContent>
225225
<SelectItem value="ernie-3.5-8k">ERNIE 3.5 8K</SelectItem>
226226
<SelectItem value="ernie-4.5-turbo-32k">ERNIE 4.5 Turbo 32K</SelectItem>
227-
<SelectItem value="ernie-4.5-turbo-128k">
228-
ERNIE 4.5 Turbo 128K
229-
</SelectItem>
227+
<SelectItem value="ernie-4.5-turbo-128k">ERNIE 4.5 Turbo 128K</SelectItem>
230228
<SelectItem value="deepseek-v3">DeepSeek V3</SelectItem>
231-
<SelectItem value="qwen3-235b-a22b-instruct-2507">
232-
Qwen3 235B
233-
</SelectItem>
229+
<SelectItem value="qwen3-235b-a22b-instruct-2507">Qwen3 235B</SelectItem>
234230
</SelectContent>
235231
</Select>
236232
<FormDescription>
@@ -255,7 +251,9 @@ export default function BaiduSearchApiPage() {
255251
</FormControl>
256252
<SelectContent>
257253
<SelectItem value="baidu_search_v1">Baidu Search V1</SelectItem>
258-
<SelectItem value="baidu_search_v2">Baidu Search V2 (Recommended)</SelectItem>
254+
<SelectItem value="baidu_search_v2">
255+
Baidu Search V2 (Recommended)
256+
</SelectItem>
259257
</SelectContent>
260258
</Select>
261259
<FormDescription>

surfsense_web/app/dashboard/[search_space_id]/connectors/add/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const connectorCategories: ConnectorCategory[] = [
6565
description: "Connect to Elasticsearch to index and search documents, logs and metrics.",
6666
icon: getConnectorIcon(EnumConnectorName.ELASTICSEARCH_CONNECTOR, "h-6 w-6"),
6767
status: "available",
68-
},
68+
},
6969
{
7070
id: "baidu-search-api",
7171
title: "Baidu Search",

surfsense_web/components/chat/SourceDetailSheet.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export function SourceDetailSheet({
5353

5454
// Check if this is a source type that should render directly from node
5555
const isDirectRenderSource =
56-
sourceType === "TAVILY_API" ||
57-
sourceType === "LINKUP_API" ||
58-
sourceType === "SEARXNG_API" ||
56+
sourceType === "TAVILY_API" ||
57+
sourceType === "LINKUP_API" ||
58+
sourceType === "SEARXNG_API" ||
5959
sourceType === "BAIDU_SEARCH_API";
6060

6161
useEffect(() => {

surfsense_web/components/contact/contact-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ export function GridPattern({ width, height, x, y, squares, ...props }: any) {
339339
</defs>
340340
<rect width="100%" height="100%" strokeWidth={0} fill={`url(#${patternId})`} />
341341
{squares && (
342-
<svg x={x} y={y} className="overflow-visible">
342+
<svg aria-hidden="true" x={x} y={y} className="overflow-visible">
343343
{squares.map(([x, y]: any, idx: number) => (
344344
<rect
345345
strokeWidth="0"

surfsense_web/components/homepage/navbar.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Link from "next/link";
55
import React, { useEffect, useState } from "react";
66
import { Logo } from "@/components/Logo";
77
import { ThemeTogglerComponent } from "@/components/theme/theme-toggle";
8+
import { useGithubStars } from "@/hooks/use-github-stars";
89
import { cn } from "@/lib/utils";
910

1011
export const Navbar = () => {
@@ -36,6 +37,7 @@ export const Navbar = () => {
3637

3738
const DesktopNav = ({ navItems, isScrolled }: any) => {
3839
const [hovered, setHovered] = useState<number | null>(null);
40+
const { compactFormat: githubStars, loading: loadingGithubStars } = useGithubStars();
3941
return (
4042
<motion.div
4143
onMouseLeave={() => {
@@ -86,7 +88,13 @@ const DesktopNav = ({ navItems, isScrolled }: any) => {
8688
className="hidden rounded-full px-3 py-2 hover:bg-gray-100 dark:hover:bg-neutral-800 transition-colors md:flex items-center gap-1.5"
8789
>
8890
<IconBrandGithub className="h-5 w-5 text-neutral-600 dark:text-neutral-300" />
89-
<span className="text-sm font-medium text-neutral-600 dark:text-neutral-300">9.5k</span>
91+
{loadingGithubStars ? (
92+
<div className="w-6 h-5 dark:bg-neutral-800 animate-pulse"></div>
93+
) : (
94+
<span className="text-sm font-medium text-neutral-600 dark:text-neutral-300">
95+
{githubStars}
96+
</span>
97+
)}
9098
</Link>
9199
<ThemeTogglerComponent />
92100
<Link
@@ -102,6 +110,7 @@ const DesktopNav = ({ navItems, isScrolled }: any) => {
102110

103111
const MobileNav = ({ navItems, isScrolled }: any) => {
104112
const [open, setOpen] = useState(false);
113+
const { compactFormat: githubStars, loading: loadingGithubStars } = useGithubStars();
105114

106115
return (
107116
<>
@@ -160,12 +169,19 @@ const MobileNav = ({ navItems, isScrolled }: any) => {
160169
className="flex items-center gap-1.5 rounded-lg px-3 py-2 hover:bg-gray-100 dark:hover:bg-neutral-800 transition-colors"
161170
>
162171
<IconBrandGithub className="h-5 w-5 text-neutral-600 dark:text-neutral-300" />
163-
<span className="text-sm font-medium text-neutral-600 dark:text-neutral-300">
164-
9.5k
165-
</span>
172+
{loadingGithubStars ? (
173+
<div className="w-6 h-5 dark:bg-neutral-800 animate-pulse"></div>
174+
) : (
175+
<span className="text-sm font-medium text-neutral-600 dark:text-neutral-300">
176+
{githubStars}
177+
</span>
178+
)}
166179
</Link>
167180
</div>
168-
<button className="w-full rounded-lg bg-black px-8 py-2 font-medium text-white shadow-[0px_-2px_0px_0px_rgba(255,255,255,0.4)_inset] dark:bg-white dark:text-black">
181+
<button
182+
type="button"
183+
className="w-full rounded-lg bg-black px-8 py-2 font-medium text-white shadow-[0px_-2px_0px_0px_rgba(255,255,255,0.4)_inset] dark:bg-white dark:text-black"
184+
>
169185
Book a call
170186
</button>
171187
</motion.div>

surfsense_web/components/pricing.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ export function Pricing({
7676
</div>
7777

7878
<div className="flex justify-center mb-10">
79-
<label className="relative inline-flex items-center cursor-pointer">
79+
<label
80+
htmlFor="billing-toggle"
81+
className="relative inline-flex items-center cursor-pointer"
82+
>
8083
<Label>
8184
<Switch
8285
ref={switchRef as any}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"use client";
2+
3+
import { useEffect, useState } from "react";
4+
5+
export const useGithubStars = () => {
6+
const [stars, setStars] = useState<number | null>(null);
7+
const [loading, setLoading] = useState(true);
8+
const [error, setError] = useState<string | null>(null);
9+
10+
useEffect(() => {
11+
const abortController = new AbortController();
12+
const getStars = async () => {
13+
try {
14+
setError(null);
15+
16+
const response = await fetch(`https://api.github.com/repos/MODSetter/SurfSense`, {
17+
signal: abortController.signal,
18+
});
19+
20+
if (!response.ok) {
21+
throw new Error(`Failed to fetch stars: ${response.statusText}`);
22+
}
23+
24+
const data = await response.json();
25+
26+
setStars(data?.stargazers_count);
27+
} catch (err) {
28+
if (err instanceof Error) {
29+
console.error("Error fetching stars:", err);
30+
setError(err.message);
31+
}
32+
} finally {
33+
setLoading(false);
34+
}
35+
};
36+
37+
getStars();
38+
39+
return () => {
40+
abortController.abort();
41+
};
42+
}, []);
43+
44+
return {
45+
stars,
46+
loading,
47+
error,
48+
compactFormat: Intl.NumberFormat("en-US", {
49+
notation: "compact",
50+
}).format(stars || 0),
51+
};
52+
};

0 commit comments

Comments
 (0)