@vercel/geistdocs 2.14.6 → 2.14.7-canary.6ce58a6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +5 -5
- package/dist/config.d.ts +23 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/controls.d.ts +3 -40
- package/dist/controls.d.ts.map +1 -1
- package/dist/controls.js +5 -96
- package/dist/internal/chat-retrieval.d.ts +10 -9
- package/dist/internal/chat-retrieval.d.ts.map +1 -1
- package/dist/internal/chat-retrieval.js +32 -68
- package/dist/internal/controls-client.d.ts +40 -0
- package/dist/internal/controls-client.d.ts.map +1 -0
- package/dist/internal/controls-client.js +87 -0
- package/dist/internal/language-selector.d.ts +2 -0
- package/dist/internal/language-selector.d.ts.map +1 -0
- package/dist/internal/language-selector.js +12 -0
- package/dist/internal/mixedbread-store.d.ts +53 -0
- package/dist/internal/mixedbread-store.d.ts.map +1 -0
- package/dist/internal/mixedbread-store.js +129 -0
- package/dist/internal/navbar/mobile-menu.js +1 -1
- package/dist/internal/page-action-options.d.ts +37 -0
- package/dist/internal/page-action-options.d.ts.map +1 -0
- package/dist/internal/page-action-options.js +39 -0
- package/dist/internal/page-actions-client.d.ts +1 -31
- package/dist/internal/page-actions-client.d.ts.map +1 -1
- package/dist/internal/page-actions-client.js +5 -103
- package/dist/internal/page-actions-gate.d.ts +3 -0
- package/dist/internal/page-actions-gate.d.ts.map +1 -0
- package/dist/internal/page-actions-gate.js +15 -0
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +26 -1
- package/dist/internal/relative-docs-link.d.ts +7 -0
- package/dist/internal/relative-docs-link.d.ts.map +1 -0
- package/dist/internal/relative-docs-link.js +22 -0
- package/dist/internal/sidebar.d.ts.map +1 -1
- package/dist/internal/sidebar.js +1 -1
- package/dist/internal/toc-actions-client.d.ts +9 -0
- package/dist/internal/toc-actions-client.d.ts.map +1 -0
- package/dist/internal/toc-actions-client.js +78 -0
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +5 -2
- package/dist/navbar.js +1 -1
- package/dist/pages/changelog.js +1 -1
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +4 -3
- package/dist/routes/chat.d.ts +4 -4
- package/dist/routes/chat.d.ts.map +1 -1
- package/dist/routes/chat.js +19 -34
- package/dist/routes/openapi.d.ts.map +1 -1
- package/dist/routes/openapi.js +13 -5
- package/dist/routes/search-export.d.ts +1 -1
- package/dist/routes/search-export.d.ts.map +1 -1
- package/dist/routes/search-export.js +5 -2
- package/dist/routes/search.d.ts +10 -2
- package/dist/routes/search.d.ts.map +1 -1
- package/dist/routes/search.js +215 -55
- package/docs/agents.md +3 -3
- package/docs/llms.txt +214 -32
- package/docs/manifest.json +5 -5
- package/docs/pages/ask-ai.md +1 -1
- package/docs/pages/configuration.md +26 -3
- package/docs/pages/env.md +5 -5
- package/docs/pages/index.md +1 -1
- package/docs/pages/llms-txt.md +1 -1
- package/docs/pages/mixedbread-retrieval.md +174 -18
- package/docs/pages/provider.md +3 -0
- package/docs/sitemap.md +2 -2
- package/package.json +6 -6
- package/template/.env.example +1 -0
- package/template/AGENTS.md +11 -7
- package/template/content/docs/ask-ai.mdx +1 -1
- package/template/content/docs/configuration.mdx +26 -3
- package/template/content/docs/env.mdx +5 -5
- package/template/content/docs/index.mdx +1 -1
- package/template/content/docs/llms-txt.mdx +1 -1
- package/template/content/docs/mixedbread-retrieval.mdx +174 -18
- package/template/content/docs/provider.mdx +3 -0
- package/template/geistdocs.tsx +6 -1
- package/template/lib/geistdocs/config.tsx +2 -0
- package/template/package.json +1 -1
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useSearchContext } from "fumadocs-ui/contexts/search";
|
|
4
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { IconMoon, IconSun } from "#geistdocs-assets/icons";
|
|
6
|
+
import { Button } from "#geistdocs-ui/components/button";
|
|
7
|
+
import { Kbd } from "#geistdocs-ui/components/kbd";
|
|
8
|
+
import { useTheme } from "#geistdocs-ui/core";
|
|
9
|
+
import { cn } from "#geistdocs-ui/utils";
|
|
10
|
+
import { useGeistdocsChatContext, } from "./chat/context";
|
|
11
|
+
/**
|
|
12
|
+
* Control the Ask AI chat from custom components rendered inside
|
|
13
|
+
* `GeistdocsProvider`.
|
|
14
|
+
*/
|
|
15
|
+
export const useGeistdocsChat = () => {
|
|
16
|
+
const { ask, enabled, isOpen, openWithPage, setIsOpen } = useGeistdocsChatContext();
|
|
17
|
+
return useMemo(() => ({
|
|
18
|
+
ask,
|
|
19
|
+
close: () => setIsOpen(false),
|
|
20
|
+
enabled,
|
|
21
|
+
isOpen,
|
|
22
|
+
open: () => {
|
|
23
|
+
if (enabled) {
|
|
24
|
+
setIsOpen(true);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
openWithPage,
|
|
28
|
+
toggle: () => {
|
|
29
|
+
if (enabled) {
|
|
30
|
+
setIsOpen((open) => !open);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
}), [ask, enabled, isOpen, openWithPage, setIsOpen]);
|
|
34
|
+
};
|
|
35
|
+
export const SearchButton = ({ className, onClick }) => {
|
|
36
|
+
const { setOpenSearch } = useSearchContext();
|
|
37
|
+
return (_jsxs("button", { className: cn("flex h-8 cursor-pointer items-center justify-between rounded-md border-0 bg-background-100 py-0 pr-1.5 pl-3.5 font-normal font-sans text-gray-1000 text-sm shadow-[0_0_0_1px_var(--ds-gray-400)] outline-none hover:bg-gray-100 focus-visible:shadow-[var(--ds-focus-ring)]", className), onClick: () => {
|
|
38
|
+
setOpenSearch(true);
|
|
39
|
+
onClick?.();
|
|
40
|
+
}, type: "button", children: [_jsx("span", { className: "pr-6", children: "Search\u2026" }), _jsx(Kbd, { className: "inline-flex items-center justify-center rounded", small: true, children: "\u2318K" })] }));
|
|
41
|
+
};
|
|
42
|
+
export const ThemeToggle = () => {
|
|
43
|
+
const { resolvedTheme, setTheme } = useTheme();
|
|
44
|
+
const [mounted, setMounted] = useState(false);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
setMounted(true);
|
|
47
|
+
}, []);
|
|
48
|
+
if (!mounted) {
|
|
49
|
+
return (_jsx(Button, { "aria-label": "Toggle Theme", shape: "square", size: "small", svgOnly: true, type: "unstyled", typeName: "button", children: _jsx("div", { className: "size-4" }) }));
|
|
50
|
+
}
|
|
51
|
+
const Icon = resolvedTheme === "dark" ? IconMoon : IconSun;
|
|
52
|
+
return (_jsx(Button, { "aria-label": resolvedTheme === "dark"
|
|
53
|
+
? "Switch to Light Theme"
|
|
54
|
+
: "Switch to Dark Theme", onClick: () => setTheme(resolvedTheme === "dark" ? "light" : "dark"), shape: "square", size: "small", svgOnly: true, type: "unstyled", typeName: "button", children: _jsx(Icon, { className: "size-4" }) }));
|
|
55
|
+
};
|
|
56
|
+
export const AskAIButton = ({ children, className, prompt, size = "small", variant = "secondary", ...props }) => {
|
|
57
|
+
const { enabled, isOpen, preloadChat, setIsOpen, setPrompt } = useGeistdocsChatContext();
|
|
58
|
+
if (!enabled) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
return (_jsx(Button, { className: cn("shrink-0", className), "data-geistdocs-ask-ai": "", onClick: () => {
|
|
62
|
+
preloadChat();
|
|
63
|
+
if (prompt) {
|
|
64
|
+
setPrompt(prompt);
|
|
65
|
+
setIsOpen(true);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setIsOpen(!isOpen);
|
|
69
|
+
}, onFocus: preloadChat, onMouseEnter: preloadChat, size: size, typeName: "button", variant: variant, ...props, children: children ?? _jsx("span", { children: "Ask AI" }) }));
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Identify the signed-in reader to Ask AI. Renders nothing; while mounted
|
|
73
|
+
* with an `avatarUrl`, the reader's avatar appears beside their chat
|
|
74
|
+
* messages. Unmount it, or pass no `avatarUrl`, to clear the reader.
|
|
75
|
+
*/
|
|
76
|
+
export const AskAIUser = ({ avatarUrl, name }) => {
|
|
77
|
+
const { setUser } = useGeistdocsChatContext();
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!avatarUrl) {
|
|
80
|
+
setUser(null);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setUser({ avatarUrl, name: name ?? undefined });
|
|
84
|
+
return () => setUser(null);
|
|
85
|
+
}, [avatarUrl, name, setUser]);
|
|
86
|
+
return null;
|
|
87
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-selector.d.ts","sourceRoot":"","sources":["../../src/internal/language-selector.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB,sDA+B5B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useI18n } from "fumadocs-ui/contexts/i18n";
|
|
4
|
+
import { IconCheck, IconLanguages } from "#geistdocs-assets/icons";
|
|
5
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "./ui/dropdown-menu";
|
|
6
|
+
export const LanguageSelector = () => {
|
|
7
|
+
const { locale, locales, onChange } = useI18n();
|
|
8
|
+
if (!locales) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { "aria-label": "Select Language", className: "flex items-center justify-center rounded-md p-2 hover:bg-gray-alpha-100 focus-visible:shadow-[var(--ds-focus-ring)] focus-visible:outline-none active:bg-gray-alpha-300", children: [_jsx(IconLanguages, { className: "size-4.5" }), _jsx("span", { className: "sr-only", children: "Select Language" })] }), _jsx(DropdownMenuContent, { align: "end", children: locales.map((lang) => (_jsxs(DropdownMenuItem, { className: "flex cursor-pointer items-center justify-between", disabled: locale === lang.locale, onClick: () => onChange?.(lang.locale), children: [lang.name, locale === lang.locale && _jsx(IconCheck, { className: "size-4" })] }, lang.locale))) })] }));
|
|
12
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { GeistdocsConfig, GeistdocsPageSurface, GeistdocsRetrievalProvider } from "../config.js";
|
|
2
|
+
import { type GeistdocsPageFilter } from "../page-visibility.js";
|
|
3
|
+
import { type GeistdocsSourceBundle, type GeistdocsSourcePage } from "../source.js";
|
|
4
|
+
import { type CreateMixedbreadClientOptions, type MixedbreadClient } from "./mixedbread.js";
|
|
5
|
+
export type MixedbreadReaderSurface = Extract<GeistdocsPageSurface, "chat" | "search">;
|
|
6
|
+
type ReaderConfig = Pick<GeistdocsConfig, "ai" | "search">;
|
|
7
|
+
export declare const getReaderProvider: (config: ReaderConfig, surface: MixedbreadReaderSurface) => GeistdocsRetrievalProvider;
|
|
8
|
+
export declare const getMixedbreadReaders: (config: ReaderConfig) => MixedbreadReaderSurface[];
|
|
9
|
+
/**
|
|
10
|
+
* Server-only Mixedbread overrides, one shape for chat and search.
|
|
11
|
+
* `MXBAI_API_KEY` and `MXBAI_STORE_ID` fill omitted credentials.
|
|
12
|
+
* `apiBaseUrl` comes only from this option.
|
|
13
|
+
*/
|
|
14
|
+
export type GeistdocsMixedbreadOptions = Partial<Pick<CreateMixedbreadClientOptions, "apiBaseUrl" | "apiKey" | "fetchImpl" | "requestTimeoutMs" | "storeId">>;
|
|
15
|
+
export type MixedbreadConnection = {
|
|
16
|
+
client: MixedbreadClient;
|
|
17
|
+
siteId: string;
|
|
18
|
+
status: "ready";
|
|
19
|
+
} | {
|
|
20
|
+
missing: string[];
|
|
21
|
+
status: "unconfigured";
|
|
22
|
+
};
|
|
23
|
+
export declare const resolveMixedbreadConnection: ({ defaultTimeoutMs, options, siteId, }: {
|
|
24
|
+
defaultTimeoutMs: number;
|
|
25
|
+
options?: GeistdocsMixedbreadOptions;
|
|
26
|
+
siteId: string | undefined;
|
|
27
|
+
}) => MixedbreadConnection;
|
|
28
|
+
export interface StoreChunk {
|
|
29
|
+
headings: string[];
|
|
30
|
+
text: string;
|
|
31
|
+
}
|
|
32
|
+
export interface StorePageHit<Source> {
|
|
33
|
+
chunks: [StoreChunk, ...StoreChunk[]];
|
|
34
|
+
page: GeistdocsSourcePage;
|
|
35
|
+
source: Source;
|
|
36
|
+
}
|
|
37
|
+
export type StoreReader<Source> = (input: {
|
|
38
|
+
locale: string;
|
|
39
|
+
query: string;
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
topK: number;
|
|
42
|
+
}) => Promise<StorePageHit<Source>[]>;
|
|
43
|
+
type StoreSource = GeistdocsSourceBundle | GeistdocsSourceBundle["source"];
|
|
44
|
+
export declare const createStoreReader: <Source extends StoreSource>({ connection, filterPage, sources, surface, }: {
|
|
45
|
+
connection: Extract<MixedbreadConnection, {
|
|
46
|
+
status: "ready";
|
|
47
|
+
}>;
|
|
48
|
+
filterPage?: GeistdocsPageFilter<GeistdocsSourcePage, Source>;
|
|
49
|
+
sources: Source[];
|
|
50
|
+
surface: MixedbreadReaderSurface;
|
|
51
|
+
}) => StoreReader<Source>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=mixedbread-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixedbread-store.d.ts","sourceRoot":"","sources":["../../src/internal/mixedbread-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAEzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,6BAA6B,EAElC,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAC3C,oBAAoB,EACpB,MAAM,GAAG,QAAQ,CAClB,CAAC;AAEF,KAAK,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,QAAQ,CAAC,CAAC;AAU3D,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,YAAY,EACpB,SAAS,uBAAuB,KAC/B,0BAAyE,CAAC;AAE7E,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,KACnB,uBAAuB,EAGvB,CAAC;AAEJ;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAC9C,IAAI,CACF,6BAA6B,EAC7B,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,kBAAkB,GAAG,SAAS,CACvE,CACF,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC7D;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAAC;AAElD,eAAO,MAAM,2BAA2B,GAAI,wCAIzC;IACD,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,0BAA0B,CAAC;IACrC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,KAAG,oBA4BH,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY,CAAC,MAAM;IAClC,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;IACtC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,WAAW,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,KAAK,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEtC,KAAK,WAAW,GAAG,qBAAqB,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;AAoD3E,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,WAAW,EAAE,+CAK3D;IACD,UAAU,EAAE,OAAO,CAAC,oBAAoB,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC/D,UAAU,CAAC,EAAE,mBAAmB,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;IAC9D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,uBAAuB,CAAC;CAClC,KAAG,WAAW,CAAC,MAAM,CAmErB,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { isPageVisibleForSurface, } from "../page-visibility.js";
|
|
2
|
+
import { isGeistdocsSourceBundle, } from "../source.js";
|
|
3
|
+
import { createMixedbreadClient, readGeistdocsMixedbreadMetadata, } from "./mixedbread.js";
|
|
4
|
+
const readerProviders = {
|
|
5
|
+
chat: (config) => config.ai?.retrieval,
|
|
6
|
+
search: (config) => config.search?.provider,
|
|
7
|
+
};
|
|
8
|
+
export const getReaderProvider = (config, surface) => readerProviders[surface](config) ?? "local";
|
|
9
|
+
export const getMixedbreadReaders = (config) => Object.keys(readerProviders).filter((surface) => getReaderProvider(config, surface) === "mixedbread");
|
|
10
|
+
export const resolveMixedbreadConnection = ({ defaultTimeoutMs, options, siteId, }) => {
|
|
11
|
+
const apiKey = (options?.apiKey ?? process.env.MXBAI_API_KEY)?.trim();
|
|
12
|
+
const storeId = (options?.storeId ?? process.env.MXBAI_STORE_ID)?.trim();
|
|
13
|
+
const storeSiteId = siteId?.trim();
|
|
14
|
+
if (!(apiKey && storeId && storeSiteId)) {
|
|
15
|
+
return {
|
|
16
|
+
missing: [
|
|
17
|
+
!apiKey && "MXBAI_API_KEY",
|
|
18
|
+
!storeId && "MXBAI_STORE_ID",
|
|
19
|
+
!storeSiteId && "config.siteId",
|
|
20
|
+
].filter((name) => Boolean(name)),
|
|
21
|
+
status: "unconfigured",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
client: createMixedbreadClient({
|
|
26
|
+
apiBaseUrl: options?.apiBaseUrl,
|
|
27
|
+
apiKey,
|
|
28
|
+
fetchImpl: options?.fetchImpl,
|
|
29
|
+
maxRetries: 0,
|
|
30
|
+
requestTimeoutMs: options?.requestTimeoutMs ?? defaultTimeoutMs,
|
|
31
|
+
storeId,
|
|
32
|
+
}),
|
|
33
|
+
siteId: storeSiteId,
|
|
34
|
+
status: "ready",
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const readFirstLineHeading = (text) => {
|
|
38
|
+
const newline = text.indexOf("\n");
|
|
39
|
+
const line = newline === -1 ? text : text.slice(0, newline);
|
|
40
|
+
let hashes = 0;
|
|
41
|
+
while (hashes < line.length && line[hashes] === "#") {
|
|
42
|
+
hashes += 1;
|
|
43
|
+
}
|
|
44
|
+
const separator = line[hashes];
|
|
45
|
+
if (hashes < 1 || hashes > 6 || (separator !== " " && separator !== "\t")) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const heading = line.slice(hashes + 1).trim();
|
|
49
|
+
return heading ? [heading] : [];
|
|
50
|
+
};
|
|
51
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
52
|
+
const getChunkText = (chunk) => {
|
|
53
|
+
for (const value of [chunk.text, chunk.summary, chunk.context]) {
|
|
54
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
55
|
+
if (text) {
|
|
56
|
+
return text;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const readHeadingTexts = (value) => Array.isArray(value)
|
|
61
|
+
? value.flatMap((entry) => isRecord(entry) && typeof entry.text === "string" && entry.text.trim()
|
|
62
|
+
? [entry.text.trim()]
|
|
63
|
+
: [])
|
|
64
|
+
: [];
|
|
65
|
+
const getHeadingCandidates = (generatedMetadata, text) => {
|
|
66
|
+
const metadata = isRecord(generatedMetadata) ? generatedMetadata : {};
|
|
67
|
+
const fromMetadata = [
|
|
68
|
+
...readHeadingTexts(metadata.chunk_headings),
|
|
69
|
+
...readHeadingTexts(metadata.heading_context).reverse(),
|
|
70
|
+
];
|
|
71
|
+
if (fromMetadata.length > 0) {
|
|
72
|
+
return fromMetadata;
|
|
73
|
+
}
|
|
74
|
+
return readFirstLineHeading(text);
|
|
75
|
+
};
|
|
76
|
+
export const createStoreReader = ({ connection, filterPage, sources, surface, }) => {
|
|
77
|
+
const resolveLivePage = (sourceUrl, locale) => {
|
|
78
|
+
for (const [index, source] of sources.entries()) {
|
|
79
|
+
const input = source;
|
|
80
|
+
const loader = isGeistdocsSourceBundle(input) ? input.source : input;
|
|
81
|
+
const page = loader.getPageByHref(sourceUrl, { language: locale })?.page;
|
|
82
|
+
if (page) {
|
|
83
|
+
return { key: `${index}:${page.url}`, page, source };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return async ({ locale, query, signal, topK }) => {
|
|
88
|
+
const chunks = await connection.client.search({
|
|
89
|
+
locale,
|
|
90
|
+
query,
|
|
91
|
+
signal,
|
|
92
|
+
siteId: connection.siteId,
|
|
93
|
+
topK,
|
|
94
|
+
});
|
|
95
|
+
const hits = new Map();
|
|
96
|
+
for (const chunk of chunks) {
|
|
97
|
+
const metadata = readGeistdocsMixedbreadMetadata(chunk.metadata);
|
|
98
|
+
const text = getChunkText(chunk);
|
|
99
|
+
if (!(metadata && text) ||
|
|
100
|
+
metadata.siteId !== connection.siteId ||
|
|
101
|
+
metadata.locale !== locale) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const live = resolveLivePage(metadata.sourceUrl, locale);
|
|
105
|
+
if (!(live &&
|
|
106
|
+
isPageVisibleForSurface(live.page, surface) &&
|
|
107
|
+
(filterPage?.(live.page, { lang: locale, source: live.source }) ??
|
|
108
|
+
true))) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const storeChunk = {
|
|
112
|
+
headings: getHeadingCandidates(chunk.generated_metadata, text),
|
|
113
|
+
text,
|
|
114
|
+
};
|
|
115
|
+
const hit = hits.get(live.key);
|
|
116
|
+
if (!hit) {
|
|
117
|
+
hits.set(live.key, {
|
|
118
|
+
chunks: [storeChunk],
|
|
119
|
+
page: live.page,
|
|
120
|
+
source: live.source,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
else if (!hit.chunks.some((existing) => existing.text === text)) {
|
|
124
|
+
hit.chunks.push(storeChunk);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return Array.from(hits.values());
|
|
128
|
+
};
|
|
129
|
+
};
|
|
@@ -6,7 +6,7 @@ import { useEffect, useId, useRef, useState } from "react";
|
|
|
6
6
|
import { IconChevronDownSmall } from "#geistdocs-assets/icons";
|
|
7
7
|
import { ThemeSwitcher } from "#geistdocs-ui/components/theme-switcher";
|
|
8
8
|
import { cn } from "#geistdocs-ui/utils";
|
|
9
|
-
import { SearchButton } from "
|
|
9
|
+
import { SearchButton } from "../controls-client";
|
|
10
10
|
import { ExternalArrow } from "../external-arrow";
|
|
11
11
|
import { LocalizedLink } from "../localized-link";
|
|
12
12
|
import { groupDropdownItems } from "./desktop-menu";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { GeistdocsConfig } from "../config";
|
|
2
|
+
export interface PageActionsProps {
|
|
3
|
+
config: Pick<GeistdocsConfig, "ai" | "feedback" | "github" | "pageActions" | "siteId">;
|
|
4
|
+
/**
|
|
5
|
+
* Which variant to render. Defaults to both. Use "desktop" to render only
|
|
6
|
+
* the dropdown (beside the title) and "mobile" to render only the inline
|
|
7
|
+
* action row (below the title).
|
|
8
|
+
*/
|
|
9
|
+
only?: "desktop" | "mobile";
|
|
10
|
+
page: {
|
|
11
|
+
markdownUrl: string;
|
|
12
|
+
path?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether "Ask AI about this page" attaches the page to the next Ask AI
|
|
15
|
+
* message. Pages the chat route cannot resolve, such as changelog
|
|
16
|
+
* entries, set `false` to pre-fill a prompt with the page URL instead.
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
attachToChat?: boolean;
|
|
20
|
+
/** Page title, shown when the page is attached to an Ask AI message. */
|
|
21
|
+
title?: string;
|
|
22
|
+
url: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare const getEditSourceUrl: ({ github, path, }: {
|
|
26
|
+
github?: GeistdocsConfig["github"];
|
|
27
|
+
path?: string;
|
|
28
|
+
}) => string | undefined;
|
|
29
|
+
export declare const getPageActionOptions: (config: PageActionsProps["config"], page: PageActionsProps["page"], chatEnabled: boolean) => {
|
|
30
|
+
askAIEnabled: boolean;
|
|
31
|
+
copyEnabled: boolean;
|
|
32
|
+
editSourceEnabled: boolean;
|
|
33
|
+
editSourceUrl: string | undefined;
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
openInChatEnabled: boolean;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=page-action-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-action-options.d.ts","sourceRoot":"","sources":["../../src/internal/page-action-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,CACxD,CAAC;IACF;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE;QACJ,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd;;;;;WAKG;QACH,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,wEAAwE;QACxE,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH;AAsBD,eAAO,MAAM,gBAAgB,GAAI,mBAG9B;IACD,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,uBAQA,CAAC;AAIF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,gBAAgB,CAAC,QAAQ,CAAC,EAClC,MAAM,gBAAgB,CAAC,MAAM,CAAC,EAC9B,aAAa,OAAO;;;;;;;CAwBrB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const DEFAULT_EDIT_PATH = "content/docs/{path}";
|
|
2
|
+
const trimSlashes = (value) => value.replace(/^\/+|\/+$/g, "");
|
|
3
|
+
const resolveEditPath = ({ editPath = DEFAULT_EDIT_PATH, path, }) => {
|
|
4
|
+
const pagePath = trimSlashes(path);
|
|
5
|
+
if (editPath.includes("{path}")) {
|
|
6
|
+
return trimSlashes(editPath.replaceAll("{path}", pagePath));
|
|
7
|
+
}
|
|
8
|
+
return `${trimSlashes(editPath)}/${pagePath}`;
|
|
9
|
+
};
|
|
10
|
+
export const getEditSourceUrl = ({ github, path, }) => {
|
|
11
|
+
if (github?.owner && github?.repo && path) {
|
|
12
|
+
const branch = github.branch ?? "main";
|
|
13
|
+
const editPath = resolveEditPath({ editPath: github.editPath, path });
|
|
14
|
+
return `https://github.com/${github.owner}/${github.repo}/edit/${branch}/${editPath}`;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
};
|
|
18
|
+
// Keep the lightweight loading boundary and the menu's visibility rules in
|
|
19
|
+
// sync, including sites that disable chat through their provider.
|
|
20
|
+
export const getPageActionOptions = (config, page, chatEnabled) => {
|
|
21
|
+
const copyEnabled = config.pageActions?.copyPage !== false;
|
|
22
|
+
const openInChatEnabled = config.pageActions?.openInChat !== false;
|
|
23
|
+
const askAIEnabled = chatEnabled &&
|
|
24
|
+
config.ai?.enabled !== false &&
|
|
25
|
+
config.pageActions?.askAI !== false;
|
|
26
|
+
const editSourceUrl = getEditSourceUrl({
|
|
27
|
+
github: config.github,
|
|
28
|
+
path: page.path,
|
|
29
|
+
});
|
|
30
|
+
const editSourceEnabled = config.pageActions?.editSource !== false && Boolean(editSourceUrl);
|
|
31
|
+
return {
|
|
32
|
+
askAIEnabled,
|
|
33
|
+
copyEnabled,
|
|
34
|
+
editSourceEnabled,
|
|
35
|
+
editSourceUrl,
|
|
36
|
+
enabled: copyEnabled || openInChatEnabled || askAIEnabled || editSourceEnabled,
|
|
37
|
+
openInChatEnabled,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { GeistdocsConfig } from "../config";
|
|
3
|
-
interface PageActionsProps {
|
|
4
|
-
config: Pick<GeistdocsConfig, "ai" | "feedback" | "github" | "pageActions" | "siteId">;
|
|
5
|
-
/**
|
|
6
|
-
* Which variant to render. Defaults to both. Use "desktop" to render only
|
|
7
|
-
* the dropdown (beside the title) and "mobile" to render only the inline
|
|
8
|
-
* action row (below the title).
|
|
9
|
-
*/
|
|
10
|
-
only?: "desktop" | "mobile";
|
|
11
|
-
page: {
|
|
12
|
-
markdownUrl: string;
|
|
13
|
-
path?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Whether "Ask AI about this page" attaches the page to the next Ask AI
|
|
16
|
-
* message. Pages the chat route cannot resolve, such as changelog
|
|
17
|
-
* entries, set `false` to pre-fill a prompt with the page URL instead.
|
|
18
|
-
* @default true
|
|
19
|
-
*/
|
|
20
|
-
attachToChat?: boolean;
|
|
21
|
-
/** Page title, shown when the page is attached to an Ask AI message. */
|
|
22
|
-
title?: string;
|
|
23
|
-
url: string;
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
interface GeistdocsTableOfContentsActionsProps {
|
|
27
|
-
config: Pick<GeistdocsConfig, "feedback" | "pageActions" | "siteId">;
|
|
28
|
-
extraActions: ReactNode[];
|
|
29
|
-
}
|
|
1
|
+
import { type PageActionsProps } from "./page-action-options";
|
|
30
2
|
export declare const GeistdocsPageActions: ({ config, page, only, }: PageActionsProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
31
|
-
export declare const GeistdocsTableOfContentsActions: ({ config, extraActions, }: GeistdocsTableOfContentsActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
32
|
-
export {};
|
|
33
3
|
//# sourceMappingURL=page-actions-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"page-actions-client.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-client.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAsf/B,eAAO,MAAM,oBAAoB,GAAI,yBAIlC,gBAAgB,mDA0GlB,CAAC"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useCopyButton } from "fumadocs-ui/utils/use-copy-button";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { IconAcronymMarkdown, IconArrowCircleUp, IconCheck, IconChevronDown, IconChevronLeft, IconChevronRight, IconCopy, IconExternal, IconMessage, IconThumbUp, } from "#geistdocs-assets/icons";
|
|
4
|
+
import { useRef, useState, } from "react";
|
|
5
|
+
import { IconAcronymMarkdown, IconCheck, IconChevronDown, IconChevronLeft, IconChevronRight, IconCopy, IconExternal, IconMessage, } from "#geistdocs-assets/icons";
|
|
7
6
|
import { LogoIconGithub, LogoIconV0 } from "#geistdocs-assets/logos";
|
|
8
|
-
import { Button } from "#geistdocs-ui/components/button";
|
|
9
|
-
import { Textarea } from "#geistdocs-ui/components/textarea";
|
|
10
7
|
import { cn } from "#geistdocs-ui/utils";
|
|
11
8
|
import { useGeistdocsChatContext } from "./chat/context";
|
|
12
|
-
import {
|
|
9
|
+
import { getPageActionOptions, } from "./page-action-options";
|
|
13
10
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "./ui/dropdown-menu";
|
|
14
|
-
import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
|
|
15
11
|
import { useIsMobile } from "./use-mobile";
|
|
16
|
-
const actionClassName = "group flex min-h-8 w-full min-w-0 touch-manipulation items-center gap-2 rounded-md text-left text-gray-900 text-label-14 transition-colors hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2 focus-visible:ring-offset-background-100 motion-reduce:transition-none [&_svg]:size-4 [&_svg]:shrink-0 [&_span]:min-w-0 [&_span]:truncate";
|
|
17
12
|
// Inline page-action link (icon + label) used in the mobile action row.
|
|
18
13
|
const inlineActionClassName = "group flex touch-manipulation items-center gap-1.5 whitespace-nowrap text-gray-900 text-label-12 font-medium transition-colors hover:text-gray-1000 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2 focus-visible:ring-offset-background-100 motion-reduce:transition-none [&_svg]:size-3.5 [&_svg]:shrink-0";
|
|
19
|
-
const DEFAULT_EDIT_PATH = "content/docs/{path}";
|
|
20
14
|
const markdownRequests = new Map();
|
|
21
15
|
const getMarkdown = (url) => {
|
|
22
16
|
const cached = markdownRequests.get(url);
|
|
@@ -37,20 +31,6 @@ const getMarkdown = (url) => {
|
|
|
37
31
|
markdownRequests.set(url, request);
|
|
38
32
|
return request;
|
|
39
33
|
};
|
|
40
|
-
const trimSlashes = (value) => value.replace(/^\/+|\/+$/g, "");
|
|
41
|
-
const resolveEditPath = ({ editPath = DEFAULT_EDIT_PATH, path, }) => {
|
|
42
|
-
const pagePath = trimSlashes(path);
|
|
43
|
-
if (editPath.includes("{path}")) {
|
|
44
|
-
return trimSlashes(editPath.replaceAll("{path}", pagePath));
|
|
45
|
-
}
|
|
46
|
-
return `${trimSlashes(editPath)}/${pagePath}`;
|
|
47
|
-
};
|
|
48
|
-
const feedbackEmotions = [
|
|
49
|
-
{ name: "cry", emoji: "😭" },
|
|
50
|
-
{ name: "sad", emoji: "😕" },
|
|
51
|
-
{ name: "happy", emoji: "🙂" },
|
|
52
|
-
{ name: "amazed", emoji: "🤩" },
|
|
53
|
-
];
|
|
54
34
|
const openInProviders = [
|
|
55
35
|
{
|
|
56
36
|
id: "v0",
|
|
@@ -77,14 +57,6 @@ const openInProviders = [
|
|
|
77
57
|
},
|
|
78
58
|
},
|
|
79
59
|
];
|
|
80
|
-
const getEditSourceUrl = ({ github, path, }) => {
|
|
81
|
-
if (github?.owner && github?.repo && path) {
|
|
82
|
-
const branch = github.branch ?? "main";
|
|
83
|
-
const editPath = resolveEditPath({ editPath: github.editPath, path });
|
|
84
|
-
return `https://github.com/${github.owner}/${github.repo}/edit/${branch}/${editPath}`;
|
|
85
|
-
}
|
|
86
|
-
return undefined;
|
|
87
|
-
};
|
|
88
60
|
const getPageQuery = (href, origin) => {
|
|
89
61
|
const protocol = process.env.NODE_ENV === "production" ? "https" : "http";
|
|
90
62
|
const productionHost = process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL;
|
|
@@ -108,10 +80,6 @@ const getPageQuery = (href, origin) => {
|
|
|
108
80
|
}
|
|
109
81
|
return `Read this page, I want to ask questions about it. ${url}`;
|
|
110
82
|
};
|
|
111
|
-
const ScrollTopAction = () => (_jsxs("button", { className: actionClassName, onClick: () => {
|
|
112
|
-
const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
113
|
-
window.scrollTo({ top: 0, behavior: reduceMotion ? "auto" : "smooth" });
|
|
114
|
-
}, type: "button", children: [_jsx(IconArrowCircleUp, { className: "size-3.5" }), _jsx("span", { children: "Scroll to top" })] }));
|
|
115
83
|
const PageActionMenuItemContent = ({ description, icon, title, }) => (_jsxs("span", { className: "grid w-full grid-cols-[20px_minmax(0,1fr)] items-center gap-3 text-left", children: [_jsx("span", { className: "flex size-5 items-center justify-center text-gray-900", children: icon }), _jsxs("span", { className: "flex min-w-0 flex-col items-start gap-0.5", children: [_jsx("span", { className: "text-gray-1000 text-label-14", children: title }), _jsx("span", { className: "text-copy-13 text-gray-900", children: description })] })] }));
|
|
116
84
|
const OpenInProviderItems = ({ providers, query, }) => providers.map((provider) => (_jsx(DropdownMenuItem, { asChild: true, children: _jsxs("a", { className: "flex items-center gap-2 text-label-14", href: provider.getHref(query), rel: "noopener noreferrer", target: "_blank", children: [_jsx("span", { className: "flex-1", translate: "no", children: provider.label }), _jsx(IconExternal, { className: "size-4 shrink-0" })] }) }, provider.id)));
|
|
117
85
|
const ProviderMenuView = ({ backRef, onBack, providers, query, }) => (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "text-label-14", onSelect: (event) => {
|
|
@@ -124,53 +92,6 @@ const PageActionsMainMenu = ({ askAIEnabled, copyEnabled, editSourceEnabled, edi
|
|
|
124
92
|
onShowProviders();
|
|
125
93
|
}, ref: openInChatRef, children: [_jsx(PageActionMenuItemContent, { description: "Use this page in another AI chat", icon: _jsx(IconExternal, { className: "size-4" }), title: "Open in another chat" }), _jsx(IconChevronRight, { className: "size-4" })] })) : (_jsxs(DropdownMenuSub, { children: [_jsx(DropdownMenuSubTrigger, { className: "h-auto p-2", children: _jsx(PageActionMenuItemContent, { description: "Use this page in another AI chat", icon: _jsx(IconExternal, { className: "size-4" }), title: "Open in another chat" }) }), _jsx(DropdownMenuSubContent, { className: "w-52", sideOffset: 12, children: _jsx(OpenInProviderItems, { providers: otherProviders, query: query }) })] }))] })) : null, askAIEnabled ? (_jsx(DropdownMenuItem, { className: "h-auto p-2", onSelect: onAskAI, children: _jsx(PageActionMenuItemContent, { description: "Chat with this page as context", icon: _jsx(IconMessage, { className: "size-4" }), title: "Ask AI about this page" }) })) : null, editSourceEnabled ? (_jsx(DropdownMenuItem, { asChild: true, className: "h-auto p-2", children: _jsx("a", { href: editSourceUrl, rel: "noopener noreferrer", target: "_blank", children: _jsx(PageActionMenuItemContent, { description: "Suggest changes to this page", icon: _jsx(LogoIconGithub, { "aria-hidden": "true", size: 16 }), title: "Edit this page on GitHub" }) }) })) : null] }));
|
|
126
94
|
};
|
|
127
|
-
const FeedbackAction = ({ siteId }) => {
|
|
128
|
-
const isMobile = useIsMobile();
|
|
129
|
-
const url = usePathname();
|
|
130
|
-
const [submitted, setSubmitted] = useState(false);
|
|
131
|
-
const [emotion, setEmotion] = useState(null);
|
|
132
|
-
const [message, setMessage] = useState("");
|
|
133
|
-
const [failed, setFailed] = useState(false);
|
|
134
|
-
const [isPending, startTransition] = useTransition();
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
const item = localStorage.getItem(`docs-feedback-${url}`);
|
|
137
|
-
if (!item) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
setSubmitted(true);
|
|
141
|
-
}, [url]);
|
|
142
|
-
const submit = (event) => {
|
|
143
|
-
event.preventDefault();
|
|
144
|
-
if (!emotion) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
startTransition(async () => {
|
|
148
|
-
const feedback = {
|
|
149
|
-
emotion,
|
|
150
|
-
message,
|
|
151
|
-
};
|
|
152
|
-
const result = await sendFeedback({ url, feedback, siteId });
|
|
153
|
-
// Keep the form (and the visitor's text) so a failed submission can
|
|
154
|
-
// be retried.
|
|
155
|
-
if (!result.success) {
|
|
156
|
-
setFailed(true);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
setFailed(false);
|
|
160
|
-
setSubmitted(true);
|
|
161
|
-
localStorage.setItem(`docs-feedback-${url}`, "1");
|
|
162
|
-
setMessage("");
|
|
163
|
-
setEmotion(null);
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { className: actionClassName, type: "button", children: [_jsx(IconThumbUp, { className: "size-3.5" }), _jsx("span", { children: "Give feedback" })] }) }), _jsx(PopoverContent, { className: "overflow-hidden p-0", children: _jsx("div", { className: "overflow-visible", children: submitted ? (_jsx("div", { className: "flex flex-col items-center gap-3 rounded-xl bg-background-200 px-3 py-6 text-center text-copy-14", role: "status", children: _jsx("p", { children: "Thank you for your feedback!" }) })) : (_jsxs("form", { className: "flex flex-col", onSubmit: submit, children: [_jsx("div", { className: "p-2", children: _jsx(Textarea, { "aria-label": "Feedback", autoComplete: "off", autoFocus: !isMobile, className: "max-h-48 min-h-24 shadow-none", name: "feedback", onChange: (event) => setMessage(event.target.value), onKeyDown: (event) => {
|
|
167
|
-
if (!event.shiftKey && event.key === "Enter") {
|
|
168
|
-
event.currentTarget.form?.requestSubmit();
|
|
169
|
-
}
|
|
170
|
-
}, placeholder: "Leave your feedback\u2026", required: true, value: message }) }), _jsxs("div", { className: "flex items-center justify-end gap-1 px-2 text-gray-900", children: [_jsx(IconAcronymMarkdown, { "aria-hidden": "true", className: "inline size-3" }), _jsx("p", { className: "text-label-12", children: " supported" })] }), failed ? (_jsx("p", { className: "px-2 pb-1 text-label-12 text-red-900", role: "alert", children: "Sending feedback failed. Please try again." })) : null, _jsxs("div", { className: "mt-2 flex items-center justify-between border-t bg-background-200 p-2", children: [_jsx("div", { className: "flex items-center gap-px", children: feedbackEmotions.map((entry) => (_jsxs(Button, { className: emotion === entry.name
|
|
171
|
-
? "bg-gray-100 text-gray-1000"
|
|
172
|
-
: "text-gray-900 hover:text-gray-1000", onClick: () => setEmotion(entry.name), size: "small", type: "unstyled", typeName: "button", children: [entry.emoji, _jsx("span", { className: "sr-only", children: entry.name })] }, entry.name))) }), _jsx(Button, { disabled: isPending || !emotion || !message, size: "small", typeName: "submit", children: "Send" })] })] })) }) })] }));
|
|
173
|
-
};
|
|
174
95
|
// The mobile action row: three primary actions rendered inline below the
|
|
175
96
|
// page title.
|
|
176
97
|
const InlinePageActions = ({ askAIEnabled, checked, copyEnabled, onAskAI, onCopy, onPrefetchMarkdown, onViewMarkdown, }) => {
|
|
@@ -213,18 +134,9 @@ export const GeistdocsPageActions = ({ config, page, only, }) => {
|
|
|
213
134
|
const handleViewMarkdown = () => {
|
|
214
135
|
window.open(markdownUrl, "_blank", "noopener");
|
|
215
136
|
};
|
|
216
|
-
const editSourceUrl =
|
|
217
|
-
github: config.github,
|
|
218
|
-
path: page.path,
|
|
219
|
-
});
|
|
137
|
+
const { askAIEnabled, copyEnabled, editSourceEnabled, editSourceUrl, enabled, openInChatEnabled, } = getPageActionOptions(config, page, chatEnabled);
|
|
220
138
|
const query = getPageQuery(page.url);
|
|
221
|
-
|
|
222
|
-
const openInChatEnabled = config.pageActions?.openInChat !== false;
|
|
223
|
-
const askAIEnabled = chatEnabled &&
|
|
224
|
-
config.ai?.enabled !== false &&
|
|
225
|
-
config.pageActions?.askAI !== false;
|
|
226
|
-
const editSourceEnabled = config.pageActions?.editSource !== false && Boolean(editSourceUrl);
|
|
227
|
-
if (!(copyEnabled || openInChatEnabled || askAIEnabled || editSourceEnabled)) {
|
|
139
|
+
if (!enabled) {
|
|
228
140
|
return null;
|
|
229
141
|
}
|
|
230
142
|
const v0Provider = openInProviders[0];
|
|
@@ -247,13 +159,3 @@ export const GeistdocsPageActions = ({ config, page, only, }) => {
|
|
|
247
159
|
: "mb-2 self-end @max-[960px]:hidden";
|
|
248
160
|
return (_jsxs("div", { className: rootClassName, onFocusCapture: preloadChat, onPointerEnter: preloadChat, children: [showDesktop ? (_jsx(DesktopPageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, editSourceEnabled: editSourceEnabled, editSourceUrl: editSourceUrl, isMobile: isMobile, menuView: menuView, onAskAI: onAskAI, onCopy: handleCopy, onPrefetchMarkdown: prefetchMarkdown, onViewMarkdown: handleViewMarkdown, openInChatEnabled: openInChatEnabled, openInChatRef: openInChatRef, otherProviders: otherProviders, providersBackRef: providersBackRef, query: query, setMenuView: setMenuView, v0Provider: v0Provider })) : null, showMobile && (copyEnabled || askAIEnabled) ? (_jsx(InlinePageActions, { askAIEnabled: askAIEnabled, checked: checked, copyEnabled: copyEnabled, onAskAI: onAskAI, onCopy: handleCopy, onPrefetchMarkdown: prefetchMarkdown, onViewMarkdown: handleViewMarkdown })) : null, _jsx("span", { "aria-live": "polite", className: "sr-only", children: checked ? "Page copied" : "" })] }));
|
|
249
161
|
};
|
|
250
|
-
export const GeistdocsTableOfContentsActions = ({ config, extraActions, }) => {
|
|
251
|
-
const actions = [];
|
|
252
|
-
if (config.pageActions?.scrollTop !== false) {
|
|
253
|
-
actions.push(_jsx(ScrollTopAction, {}, "scroll-top"));
|
|
254
|
-
}
|
|
255
|
-
if (config.feedback?.enabled !== false) {
|
|
256
|
-
actions.push(_jsx(FeedbackAction, { siteId: config.siteId }, "feedback"));
|
|
257
|
-
}
|
|
258
|
-
return (_jsxs(_Fragment, { children: [actions, extraActions] }));
|
|
259
|
-
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-actions-gate.d.ts","sourceRoot":"","sources":["../../src/internal/page-actions-gate.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,uBAAuB,CAAC;AAQ/B,eAAO,MAAM,oBAAoB,GAAI,OAAO,gBAAgB,mDAW3D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { lazy, Suspense } from "react";
|
|
4
|
+
import { useGeistdocsChatContext } from "./chat/context";
|
|
5
|
+
import { getPageActionOptions, } from "./page-action-options";
|
|
6
|
+
const PageActions = lazy(() => import("./page-actions-client").then((module) => ({
|
|
7
|
+
default: module.GeistdocsPageActions,
|
|
8
|
+
})));
|
|
9
|
+
export const GeistdocsPageActions = (props) => {
|
|
10
|
+
const { enabled: chatEnabled } = useGeistdocsChatContext();
|
|
11
|
+
if (!getPageActionOptions(props.config, props.page, chatEnabled).enabled) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return (_jsx(Suspense, { fallback: null, children: _jsx(PageActions, { ...props }) }));
|
|
15
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAMjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAUtD,KAAK,kBAAkB,GAAG,WAAW,CACnC,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC,QAAQ,CAAC,CAC9C,CAAC;AAEF,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,EAAE,QAAQ,CAAC;IAC3D,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,GAAG;QAC7C,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;KACjE,CAAC;CACH;
|
|
1
|
+
{"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAMjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAUtD,KAAK,kBAAkB,GAAG,WAAW,CACnC,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC,QAAQ,CAAC,CAC9C,CAAC;AAEF,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,YAAY,CAAC,EAAE,QAAQ,CAAC;IAC3D,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS,CAAC,GAAG;QAC7C,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC;KACjE,CAAC;CACH;AAqJD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAQ9D,CAAC"}
|