Skip to content

Commit 57a4c3c

Browse files
committed
Run Geistdocs updater
1 parent ee12ec8 commit 57a4c3c

File tree

12 files changed

+53
-30
lines changed

12 files changed

+53
-30
lines changed

apps/website/app/[lang]/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "katex/dist/katex.css";
33
import { Footer } from "@/components/geistdocs/footer";
44
import { Navbar } from "@/components/geistdocs/navbar";
55
import { GeistdocsProvider } from "@/components/geistdocs/provider";
6+
import { basePath } from "@/geistdocs";
67
import { mono, sans } from "@/lib/geistdocs/fonts";
78
import { cn } from "@/lib/utils";
89

@@ -16,7 +17,7 @@ const Layout = async ({ children, params }: LayoutProps<"/[lang]">) => {
1617
suppressHydrationWarning
1718
>
1819
<body>
19-
<GeistdocsProvider lang={lang}>
20+
<GeistdocsProvider basePath={basePath} lang={lang}>
2021
<Navbar />
2122
{children}
2223
<Footer />

apps/website/app/api/chat/route.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,6 @@ User question: ${userQuestion}`,
8484
execute: ({ writer }) => {
8585
const result = streamText({
8686
model: "openai/gpt-4.1-mini",
87-
providerOptions: {
88-
openai: {
89-
reasoningEffort: "minimal",
90-
reasoningSummary: "auto",
91-
textVerbosity: "medium",
92-
serviceTier: "priority",
93-
},
94-
},
9587
messages: convertToModelMessages(processedMessages),
9688
stopWhen: stepCountIs(10),
9789
tools: createTools(writer),

apps/website/app/api/chat/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { prompt } from "@/geistdocs";
22

33
export const createSystemPrompt = (currentRoute: string) => {
4-
// Given we are using gpt-5, this prompt has been optimised to work well using openai's prompt optimiser
54
const newPrompt = `# Role and Objective
65
You are a helpful assistant specializing in answering questions strictly. If information is unavailable, politely decline to answer. Your primary objective is to guide users through the happy path using the most relevant documentation or guides.
76

apps/website/components/geistdocs/chat.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import type { UIMessage } from "@ai-sdk/react";
44
import { useChat } from "@ai-sdk/react";
5+
import { DefaultChatTransport } from "ai";
56
import { useLiveQuery } from "dexie-react-hooks";
67
import { ChevronRightIcon, MessagesSquareIcon, Trash } from "lucide-react";
78
import { Portal } from "radix-ui";
@@ -34,7 +35,6 @@ import {
3435
import { Suggestion, Suggestions } from "@/components/ai-elements/suggestion";
3536
import { Button } from "@/components/ui/button";
3637
import { Drawer, DrawerContent, DrawerTrigger } from "@/components/ui/drawer";
37-
import { suggestions } from "@/geistdocs";
3838
import { useChatContext } from "@/hooks/geistdocs/use-chat";
3939
import { useIsMobile } from "@/hooks/use-mobile";
4040
import { db } from "@/lib/geistdocs/db";
@@ -113,7 +113,12 @@ export const useChatPersistence = () => {
113113
};
114114
};
115115

116-
const ChatInner = () => {
116+
type ChatProps = {
117+
basePath: string | undefined;
118+
suggestions: string[];
119+
};
120+
121+
const ChatInner = ({ basePath, suggestions }: ChatProps) => {
117122
const [isInitialized, setIsInitialized] = useState(false);
118123
const [localPrompt, setLocalPrompt] = useState("");
119124
const [providerKey, setProviderKey] = useState(0);
@@ -122,6 +127,9 @@ const ChatInner = () => {
122127
useChatPersistence();
123128

124129
const { messages, sendMessage, status, setMessages } = useChat({
130+
transport: new DefaultChatTransport({
131+
api: basePath ? `${basePath}/api/chat` : "/api/chat",
132+
}),
125133
onError: (error) => {
126134
toast.error(error.message, {
127135
description: error.message,
@@ -328,7 +336,7 @@ const ChatInner = () => {
328336
);
329337
};
330338

331-
export const Chat = () => {
339+
export const Chat = ({ basePath, suggestions }: ChatProps) => {
332340
const { isOpen, setIsOpen } = useChatContext();
333341
const isMobile = useIsMobile();
334342

@@ -375,7 +383,7 @@ export const Chat = () => {
375383
)}
376384
data-state={isOpen ? "open" : "closed"}
377385
>
378-
<ChatInner />
386+
<ChatInner basePath={basePath} suggestions={suggestions} />
379387
</div>
380388
</Portal.Root>
381389
<div className="md:hidden">
@@ -390,7 +398,7 @@ export const Chat = () => {
390398
</Button>
391399
</DrawerTrigger>
392400
<DrawerContent className="h-[80dvh]">
393-
<ChatInner />
401+
<ChatInner basePath={basePath} suggestions={suggestions} />
394402
</DrawerContent>
395403
</Drawer>
396404
</div>

apps/website/components/geistdocs/docs-layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ type DocsLayoutProps = {
1515

1616
export const DocsLayout = ({ tree, children }: DocsLayoutProps) => (
1717
<FumadocsDocsLayout
18-
i18n={i18n}
1918
containerProps={{
2019
style: {
21-
'--fd-docs-row-1': '4rem',
22-
} as CSSProperties
20+
"--fd-docs-row-1": "4rem",
21+
} as CSSProperties,
2322
}}
23+
i18n={i18n}
2424
nav={{
2525
enabled: false,
2626
}}

apps/website/components/geistdocs/home-layout.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DocsLayout as FumadocsDocsLayout } from "fumadocs-ui/layouts/docs";
22
import type { ComponentProps, CSSProperties, ReactNode } from "react";
33
import { i18n } from "@/lib/geistdocs/i18n";
4+
import { Folder, Item, Separator, Sidebar } from "./sidebar";
45

56
type HomeLayoutProps = {
67
tree: ComponentProps<typeof FumadocsDocsLayout>["tree"];
@@ -14,7 +15,7 @@ export const HomeLayout = ({ tree, children }: HomeLayoutProps) => (
1415
style: {
1516
display: "flex",
1617
flexDirection: "column",
17-
'--fd-docs-row-1': '4rem',
18+
"--fd-docs-row-1": "4rem",
1819
} as CSSProperties,
1920
}}
2021
i18n={i18n}
@@ -26,6 +27,13 @@ export const HomeLayout = ({ tree, children }: HomeLayoutProps) => (
2627
}}
2728
sidebar={{
2829
className: "md:hidden",
30+
collapsible: false,
31+
component: <Sidebar />,
32+
components: {
33+
Folder,
34+
Item,
35+
Separator,
36+
},
2937
}}
3038
tabMode="auto"
3139
themeSwitch={{

apps/website/components/geistdocs/navbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SiVercel } from "@icons-pack/react-simple-icons";
22
import { DynamicLink } from "fumadocs-core/dynamic-link";
3-
import { Logo, nav } from "@/geistdocs";
3+
import { basePath, Logo, nav, suggestions } from "@/geistdocs";
44
import { Chat } from "./chat";
55
import { DesktopMenu } from "./desktop-menu";
66
import { SlashIcon } from "./icons";
@@ -22,7 +22,7 @@ export const Navbar = () => (
2222
<DesktopMenu className="hidden xl:flex" items={nav} />
2323
<div className="ml-auto flex flex-1 items-center justify-end gap-2">
2424
<SearchButton className="hidden xl:flex" />
25-
<Chat />
25+
<Chat basePath={basePath} suggestions={suggestions} />
2626
<MobileMenu />
2727
</div>
2828
</div>

apps/website/components/geistdocs/provider.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import { Analytics } from "@vercel/analytics/next";
44
import { SpeedInsights } from "@vercel/speed-insights/next";
5+
import type { SharedProps } from "fumadocs-ui/contexts/search";
56
import { RootProvider } from "fumadocs-ui/provider/next";
6-
import type { ComponentProps } from "react";
7+
import { type ComponentProps, useCallback } from "react";
78
import { Toaster } from "@/components/ui/sonner";
89
import { useChatContext } from "@/hooks/geistdocs/use-chat";
910
import { useIsMobile } from "@/hooks/use-mobile";
@@ -13,32 +14,40 @@ import { TooltipProvider } from "../ui/tooltip";
1314
import { SearchDialog } from "./search";
1415

1516
type GeistdocsProviderProps = ComponentProps<typeof RootProvider> & {
17+
basePath: string | undefined;
1618
className?: string;
1719
lang?: string;
1820
};
1921

2022
export const GeistdocsProvider = ({
23+
basePath,
2124
search,
2225
className,
2326
lang = i18n.defaultLanguage,
2427
...props
2528
}: GeistdocsProviderProps) => {
2629
const { isOpen } = useChatContext();
2730
const isMobile = useIsMobile();
31+
const isSidebarVisible = isOpen && !isMobile;
32+
33+
const SearchDialogComponent = useCallback(
34+
(sdProps: SharedProps) => <SearchDialog basePath={basePath} {...sdProps} />,
35+
[basePath]
36+
);
2837

2938
return (
3039
<div
3140
className={cn(
3241
"transition-all",
33-
isOpen && !isMobile && "pr-96!",
42+
isSidebarVisible ? "pr-96!" : null,
3443
className
3544
)}
3645
>
3746
<TooltipProvider>
3847
<RootProvider
3948
i18n={i18nProvider(lang)}
4049
search={{
41-
SearchDialog,
50+
SearchDialog: SearchDialogComponent,
4251
...search,
4352
}}
4453
{...props}

apps/website/components/geistdocs/search.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ type SearchButtonProps = {
2323
onClick?: () => void;
2424
};
2525

26-
export const SearchDialog = (props: SharedProps) => {
26+
export const SearchDialog = ({
27+
basePath,
28+
...props
29+
}: SharedProps & { basePath: string | undefined }) => {
2730
const { locale } = useI18n();
2831
const { search, setSearch, query } = useDocsSearch({
2932
type: "fetch",
3033
locale,
31-
api: `${process.env.NEXT_PUBLIC_GEISTDOCS_BASE_PATH}/api/search`,
34+
api: basePath ? `${basePath}/api/search` : "/api/search",
3235
});
3336

3437
return (

apps/website/components/geistdocs/sidebar.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ export const Folder: SidebarPageTreeComponents["Folder"] = ({
7676
const defaultOpen = item.defaultOpen ?? path.includes(item);
7777

7878
return (
79-
<SidebarFolder
80-
defaultOpen={defaultOpen}
81-
>
79+
<SidebarFolder defaultOpen={defaultOpen}>
8280
{item.index ? (
8381
<SidebarFolderLink
8482
className="flex items-center gap-2 text-pretty py-1.5 text-muted-foreground text-sm transition-colors hover:text-foreground data-[active=true]:text-foreground [&_svg]:size-3.5"

0 commit comments

Comments
 (0)