@vercel/geistdocs 1.3.0-canary.88e35b7 → 1.3.1
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/assets/icons/icon-arrow-up-right-small.d.ts +8 -0
- package/dist/assets/icons/icon-arrow-up-right-small.d.ts.map +1 -0
- package/dist/assets/icons/icon-arrow-up-right-small.js +4 -0
- package/dist/assets/icons/icon-arrow-up-right.d.ts +5 -0
- package/dist/assets/icons/icon-arrow-up-right.d.ts.map +1 -0
- package/dist/assets/icons/icon-arrow-up-right.js +4 -0
- package/dist/assets/icons/icon-check.d.ts +5 -0
- package/dist/assets/icons/icon-check.d.ts.map +1 -0
- package/dist/assets/icons/icon-check.js +4 -0
- package/dist/assets/icons/icon-chevron-down-small.d.ts +8 -0
- package/dist/assets/icons/icon-chevron-down-small.d.ts.map +1 -0
- package/dist/assets/icons/icon-chevron-down-small.js +7 -0
- package/dist/assets/icons/icon-chevron-right.d.ts +5 -0
- package/dist/assets/icons/icon-chevron-right.d.ts.map +1 -0
- package/dist/assets/icons/icon-chevron-right.js +4 -0
- package/dist/assets/icons/icon-copy.d.ts +5 -0
- package/dist/assets/icons/icon-copy.d.ts.map +1 -0
- package/dist/assets/icons/icon-copy.js +4 -0
- package/dist/assets/icons/icon-file-text.d.ts +5 -0
- package/dist/assets/icons/icon-file-text.d.ts.map +1 -0
- package/dist/assets/icons/icon-file-text.js +4 -0
- package/dist/assets/icons/icon-menu-alt.d.ts +5 -0
- package/dist/assets/icons/icon-menu-alt.d.ts.map +1 -0
- package/dist/assets/icons/icon-menu-alt.js +4 -0
- package/dist/assets/icons/icon-slash-forward.d.ts +8 -0
- package/dist/assets/icons/icon-slash-forward.d.ts.map +1 -0
- package/dist/assets/icons/icon-slash-forward.js +4 -0
- package/dist/assets/icons/index.d.ts +10 -0
- package/dist/assets/icons/index.d.ts.map +1 -0
- package/{template/components/geistcn-fallbacks/geistcn-assets/icons/index.tsx → dist/assets/icons/index.js} +0 -1
- package/dist/assets/logos/index.d.ts +15 -0
- package/dist/assets/logos/index.d.ts.map +1 -0
- package/{template/components/geistcn-fallbacks/geistcn-assets/logos/index.tsx → dist/assets/logos/index.js} +2 -1
- package/dist/assets/logos/logo-ai-elements.d.ts +8 -0
- package/dist/assets/logos/logo-ai-elements.d.ts.map +1 -0
- package/dist/assets/logos/logo-ai-elements.js +8 -0
- package/dist/assets/logos/logo-ai-sdk.d.ts +8 -0
- package/dist/assets/logos/logo-ai-sdk.d.ts.map +1 -0
- package/dist/assets/logos/logo-ai-sdk.js +8 -0
- package/dist/assets/logos/logo-chat-sdk.d.ts +8 -0
- package/dist/assets/logos/logo-chat-sdk.d.ts.map +1 -0
- package/dist/assets/logos/logo-chat-sdk.js +8 -0
- package/dist/assets/logos/logo-flags-sdk.d.ts +8 -0
- package/dist/assets/logos/logo-flags-sdk.d.ts.map +1 -0
- package/dist/assets/logos/logo-flags-sdk.js +8 -0
- package/dist/assets/logos/logo-icon-vercel.d.ts +9 -0
- package/dist/assets/logos/logo-icon-vercel.d.ts.map +1 -0
- package/dist/assets/logos/logo-icon-vercel.js +8 -0
- package/dist/assets/logos/logo-nextjs.d.ts +8 -0
- package/dist/assets/logos/logo-nextjs.d.ts.map +1 -0
- package/dist/assets/logos/logo-nextjs.js +7 -0
- package/dist/assets/logos/logo-streamdown.d.ts +8 -0
- package/dist/assets/logos/logo-streamdown.d.ts.map +1 -0
- package/dist/assets/logos/logo-streamdown.js +8 -0
- package/dist/assets/logos/logo-svelte-kit.d.ts +5 -0
- package/dist/assets/logos/logo-svelte-kit.d.ts.map +1 -0
- package/dist/assets/logos/logo-svelte-kit.js +4 -0
- package/dist/assets/logos/logo-vercel-oss.d.ts +8 -0
- package/dist/assets/logos/logo-vercel-oss.d.ts.map +1 -0
- package/dist/assets/logos/logo-vercel-oss.js +7 -0
- package/dist/assets/logos/logo-workflow-sdk.d.ts +8 -0
- package/dist/assets/logos/logo-workflow-sdk.d.ts.map +1 -0
- package/dist/assets/logos/logo-workflow-sdk.js +8 -0
- package/dist/cli/index.js +2 -5
- package/dist/components/button-group.d.ts +2 -0
- package/dist/components/button-group.d.ts.map +1 -0
- package/dist/components/button-group.js +2 -0
- package/dist/components/button.d.ts +2 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +2 -0
- package/dist/components/card.d.ts +2 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +2 -0
- package/dist/components/code-block-tabs.js +3 -3
- package/dist/components/code-block.d.ts.map +1 -1
- package/dist/components/code-block.js +7 -3
- package/dist/components/collapsible.d.ts +2 -0
- package/dist/components/collapsible.d.ts.map +1 -0
- package/dist/components/collapsible.js +3 -0
- package/dist/components/copy-prompt.d.ts +11 -0
- package/dist/components/copy-prompt.d.ts.map +1 -0
- package/dist/components/copy-prompt.js +58 -0
- package/dist/components/dialog.d.ts +13 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +35 -0
- package/dist/components/drawer.d.ts +2 -0
- package/dist/components/drawer.d.ts.map +1 -0
- package/dist/components/drawer.js +3 -0
- package/dist/components/dropdown-menu.d.ts +2 -0
- package/dist/components/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu.js +3 -0
- package/dist/components/input-group.d.ts +2 -0
- package/dist/components/input-group.d.ts.map +1 -0
- package/dist/components/input-group.js +3 -0
- package/dist/components/input.d.ts +2 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +2 -0
- package/dist/components/kbd.d.ts +2 -0
- package/dist/components/kbd.d.ts.map +1 -0
- package/dist/components/kbd.js +2 -0
- package/dist/components/navigation-menu.d.ts +2 -0
- package/dist/components/navigation-menu.d.ts.map +1 -0
- package/dist/components/navigation-menu.js +3 -0
- package/dist/components/popover.d.ts +2 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +3 -0
- package/dist/components/scroll-area.d.ts +2 -0
- package/dist/components/scroll-area.d.ts.map +1 -0
- package/dist/components/scroll-area.js +3 -0
- package/dist/components/separator.d.ts +2 -0
- package/dist/components/separator.d.ts.map +1 -0
- package/dist/components/separator.js +3 -0
- package/dist/components/sheet.d.ts +2 -0
- package/dist/components/sheet.d.ts.map +1 -0
- package/dist/components/sheet.js +3 -0
- package/dist/components/sonner.d.ts +2 -0
- package/dist/components/sonner.d.ts.map +1 -0
- package/dist/components/sonner.js +3 -0
- package/dist/components/spinner.d.ts +2 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/spinner.js +2 -0
- package/dist/components/textarea.d.ts +2 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +2 -0
- package/dist/components/tooltip.d.ts +2 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +3 -0
- package/dist/config.d.ts +66 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/controls.js +4 -4
- package/dist/footer.d.ts +8 -0
- package/dist/footer.d.ts.map +1 -0
- package/dist/footer.js +6 -0
- package/dist/home-layout.d.ts +11 -0
- package/dist/home-layout.d.ts.map +1 -0
- package/dist/home-layout.js +31 -0
- package/dist/internal/chat/conversation.js +1 -1
- package/dist/internal/chat/message.js +1 -1
- package/dist/internal/chat/prompt-input.js +1 -1
- package/dist/internal/chat/shell.d.ts.map +1 -1
- package/dist/internal/chat/shell.js +6 -5
- package/dist/internal/chat/sources.js +1 -1
- package/dist/internal/config-context.d.ts +10 -0
- package/dist/internal/config-context.d.ts.map +1 -0
- package/dist/internal/config-context.js +15 -0
- package/dist/internal/footer/github-button.d.ts +7 -0
- package/dist/internal/footer/github-button.d.ts.map +1 -0
- package/dist/internal/footer/github-button.js +10 -0
- package/dist/internal/footer/rss-button.d.ts +2 -0
- package/dist/internal/footer/rss-button.d.ts.map +1 -0
- package/dist/internal/footer/rss-button.js +4 -0
- package/dist/internal/localized-link.d.ts +8 -0
- package/dist/internal/localized-link.d.ts.map +1 -0
- package/dist/internal/localized-link.js +13 -0
- package/dist/internal/navbar/desktop-menu.d.ts +10 -0
- package/dist/internal/navbar/desktop-menu.d.ts.map +1 -0
- package/dist/internal/navbar/desktop-menu.js +11 -0
- package/dist/internal/navbar/mobile-menu.d.ts +7 -0
- package/dist/internal/navbar/mobile-menu.d.ts.map +1 -0
- package/dist/internal/navbar/mobile-menu.js +44 -0
- package/dist/internal/navbar/navbar-logo.d.ts +16 -0
- package/dist/internal/navbar/navbar-logo.d.ts.map +1 -0
- package/dist/internal/navbar/navbar-logo.js +30 -0
- package/dist/internal/page-actions-client.d.ts +1 -2
- package/dist/internal/page-actions-client.d.ts.map +1 -1
- package/dist/internal/page-actions-client.js +28 -11
- package/dist/internal/page-visibility.d.ts +18 -0
- package/dist/internal/page-visibility.d.ts.map +1 -0
- package/dist/internal/page-visibility.js +24 -0
- package/dist/internal/provider-client.d.ts +9 -0
- package/dist/internal/provider-client.d.ts.map +1 -0
- package/dist/internal/provider-client.js +24 -0
- package/dist/internal/sidebar.d.ts +4 -1
- package/dist/internal/sidebar.d.ts.map +1 -1
- package/dist/internal/sidebar.js +8 -7
- package/dist/internal/table-of-contents.d.ts +9 -0
- package/dist/internal/table-of-contents.d.ts.map +1 -0
- package/dist/internal/table-of-contents.js +5 -0
- package/dist/internal/ui/button-group.js +2 -2
- package/dist/internal/ui/button.d.ts +1 -1
- package/dist/internal/ui/button.d.ts.map +1 -1
- package/dist/internal/ui/button.js +7 -7
- package/dist/internal/ui/card.js +1 -1
- package/dist/internal/ui/drawer.js +1 -1
- package/dist/internal/ui/dropdown-menu.js +7 -7
- package/dist/internal/ui/input-group.js +2 -2
- package/dist/internal/ui/input.js +1 -1
- package/dist/internal/ui/kbd.js +1 -1
- package/dist/internal/ui/navigation-menu.d.ts +17 -0
- package/dist/internal/ui/navigation-menu.d.ts.map +1 -0
- package/dist/internal/ui/navigation-menu.js +38 -0
- package/dist/internal/ui/popover.js +1 -1
- package/dist/internal/ui/scroll-area.js +2 -2
- package/dist/internal/ui/separator.js +1 -1
- package/dist/internal/ui/sheet.js +4 -4
- package/dist/internal/ui/sonner.js +3 -3
- package/dist/internal/ui/textarea.js +1 -1
- package/dist/internal/ui/tooltip.js +1 -1
- package/dist/layout.d.ts +4 -8
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +26 -44
- package/dist/mdx.d.ts +55 -24
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +9 -46
- package/dist/mobile-docs-bar.d.ts +7 -0
- package/dist/mobile-docs-bar.d.ts.map +1 -0
- package/dist/mobile-docs-bar.js +13 -0
- package/dist/navbar.d.ts +7 -0
- package/dist/navbar.d.ts.map +1 -0
- package/dist/navbar.js +10 -0
- package/dist/pages/docs.d.ts +33 -5
- package/dist/pages/docs.d.ts.map +1 -1
- package/dist/pages/docs.js +57 -22
- package/dist/proxy.d.ts +24 -8
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +116 -36
- package/dist/routes/agents.d.ts +21 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +201 -0
- package/dist/routes/chat.d.ts +11 -5
- package/dist/routes/chat.d.ts.map +1 -1
- package/dist/routes/chat.js +386 -65
- package/dist/routes/llms.d.ts +29 -10
- package/dist/routes/llms.d.ts.map +1 -1
- package/dist/routes/llms.js +80 -9
- package/dist/routes/search.d.ts +8 -5
- package/dist/routes/search.d.ts.map +1 -1
- package/dist/routes/search.js +52 -4
- package/dist/routes/sitemap.d.ts +15 -3
- package/dist/routes/sitemap.d.ts.map +1 -1
- package/dist/routes/sitemap.js +32 -6
- package/dist/shiki-theme.d.ts +20 -0
- package/dist/shiki-theme.d.ts.map +1 -0
- package/dist/shiki-theme.js +110 -0
- package/dist/sidebar.d.ts +11 -0
- package/dist/sidebar.d.ts.map +1 -0
- package/dist/sidebar.js +16 -0
- package/dist/source-config.d.ts +68 -0
- package/dist/source-config.d.ts.map +1 -0
- package/dist/source-config.js +161 -0
- package/dist/source.d.ts +155 -4
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +73 -3
- package/dist/versions.d.ts +45 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +79 -0
- package/package.json +142 -9
- package/source-config.js +174 -0
- package/styles.css +465 -102
- package/template/AGENTS.md +95 -0
- package/template/app/[lang]/(home)/components/centered-section.tsx +1 -3
- package/template/app/[lang]/(home)/components/hero.tsx +2 -2
- package/template/app/[lang]/(home)/components/one-two-section.tsx +1 -3
- package/template/app/[lang]/(home)/components/templates.tsx +3 -5
- package/template/app/[lang]/(home)/components/text-grid-section.tsx +1 -1
- package/template/app/[lang]/(home)/layout.tsx +4 -3
- package/template/app/[lang]/(home)/page.tsx +2 -2
- package/template/app/[lang]/agents.md/route.ts +6 -0
- package/template/app/[lang]/docs/[[...slug]]/page.tsx +4 -1
- package/template/app/[lang]/layout.tsx +6 -6
- package/template/app/[lang]/llms.mdx/[[...slug]]/route.ts +1 -1
- package/template/app/[lang]/llms.txt/route.ts +1 -1
- package/template/app/[lang]/sitemap.md/route.ts +2 -2
- package/template/app/api/chat/route.ts +12 -1
- package/template/app/api/search/route.ts +2 -2
- package/template/app/styles/geistdocs.css +151 -109
- package/template/components/ui/badge.tsx +5 -5
- package/template/components/ui/button.tsx +7 -7
- package/template/components/ui/command-prompt.tsx +2 -2
- package/template/content/docs/agent-readiness.mdx +103 -0
- package/template/content/docs/ask-ai.mdx +61 -5
- package/template/content/docs/configuration.cn.mdx +47 -7
- package/template/content/docs/configuration.mdx +226 -66
- package/template/content/docs/deployment.mdx +17 -0
- package/template/content/docs/edit-on-github.mdx +6 -2
- package/template/content/docs/env.mdx +38 -3
- package/template/content/docs/feedback.mdx +6 -2
- package/template/content/docs/getting-started.cn.mdx +2 -2
- package/template/content/docs/getting-started.mdx +71 -43
- package/template/content/docs/index.cn.mdx +36 -33
- package/template/content/docs/index.mdx +69 -59
- package/template/content/docs/internationalization.cn.mdx +7 -9
- package/template/content/docs/internationalization.mdx +10 -5
- package/template/content/docs/llms-txt.cn.mdx +24 -2
- package/template/content/docs/llms-txt.mdx +48 -12
- package/template/content/docs/md.cn.mdx +12 -15
- package/template/content/docs/md.mdx +30 -16
- package/template/content/docs/meta.json +6 -2
- package/template/content/docs/migration.mdx +364 -0
- package/template/content/docs/open-in-chat.mdx +12 -10
- package/template/content/docs/provider.cn.mdx +6 -5
- package/template/content/docs/provider.mdx +13 -8
- package/template/content/docs/proxy.cn.mdx +96 -0
- package/template/content/docs/proxy.mdx +178 -0
- package/template/content/docs/rss.mdx +6 -2
- package/template/content/docs/syntax.cn.mdx +2 -2
- package/template/content/docs/syntax.mdx +6 -2
- package/template/content/docs/theme-aware-image.mdx +5 -1
- package/template/content/docs/versioned-docs.cn.mdx +117 -0
- package/template/content/docs/versioned-docs.mdx +228 -0
- package/template/geistdocs.tsx +26 -0
- package/template/lib/geistdocs/config.tsx +3 -0
- package/template/package.json +5 -5
- package/template/proxy.ts +2 -1
- package/template/source.config.ts +8 -47
- package/template/app/actions/feedback/emotions.ts +0 -18
- package/template/app/actions/feedback/index.ts +0 -45
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right-small.tsx +0 -35
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right.tsx +0 -27
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-check.tsx +0 -27
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-down-small.tsx +0 -30
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-right.tsx +0 -27
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-copy.tsx +0 -27
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-file-text.tsx +0 -25
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-menu-alt.tsx +0 -27
- package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-slash-forward.tsx +0 -36
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-elements.tsx +0 -29
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-sdk.tsx +0 -38
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-chat-sdk.tsx +0 -42
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-flags-sdk.tsx +0 -42
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-icon-vercel.tsx +0 -31
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-streamdown.tsx +0 -29
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-vercel-oss.tsx +0 -24
- package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-workflow-sdk.tsx +0 -73
- package/template/components/geistdocs/callout.tsx +0 -40
- package/template/components/geistdocs/chat.tsx +0 -24
- package/template/components/geistdocs/code-block-tabs.tsx +0 -61
- package/template/components/geistdocs/code-block.tsx +0 -134
- package/template/components/geistdocs/copy-page.tsx +0 -27
- package/template/components/geistdocs/desktop-menu.tsx +0 -52
- package/template/components/geistdocs/docs-page.tsx +0 -35
- package/template/components/geistdocs/edit-source.tsx +0 -30
- package/template/components/geistdocs/feedback.tsx +0 -139
- package/template/components/geistdocs/footer.tsx +0 -30
- package/template/components/geistdocs/github-button.tsx +0 -19
- package/template/components/geistdocs/home-layout.tsx +0 -46
- package/template/components/geistdocs/icons.tsx +0 -13
- package/template/components/geistdocs/installer.tsx +0 -58
- package/template/components/geistdocs/language-selector.tsx +0 -3
- package/template/components/geistdocs/mermaid.tsx +0 -68
- package/template/components/geistdocs/mobile-docs-bar.tsx +0 -81
- package/template/components/geistdocs/mobile-menu.tsx +0 -150
- package/template/components/geistdocs/navbar-logo.tsx +0 -124
- package/template/components/geistdocs/navbar.tsx +0 -22
- package/template/components/geistdocs/rss-button.tsx +0 -10
- package/template/components/geistdocs/scroll-top.tsx +0 -21
- package/template/components/geistdocs/search.tsx +0 -17
- package/template/components/geistdocs/sidebar.tsx +0 -128
- package/template/components/geistdocs/theme-aware-image.tsx +0 -22
- package/template/components/geistdocs/theme-toggle.tsx +0 -3
- package/template/components/geistdocs/video.tsx +0 -16
- package/template/components/ui/button-group.tsx +0 -83
- package/template/components/ui/card.tsx +0 -92
- package/template/components/ui/collapsible.tsx +0 -33
- package/template/components/ui/command.tsx +0 -184
- package/template/components/ui/dialog.tsx +0 -143
- package/template/components/ui/drawer.tsx +0 -135
- package/template/components/ui/dropdown-menu.tsx +0 -257
- package/template/components/ui/hover-card.tsx +0 -44
- package/template/components/ui/input-group.tsx +0 -170
- package/template/components/ui/input.tsx +0 -21
- package/template/components/ui/kbd.tsx +0 -28
- package/template/components/ui/navigation-menu.tsx +0 -192
- package/template/components/ui/popover.tsx +0 -48
- package/template/components/ui/scroll-area.tsx +0 -58
- package/template/components/ui/select.tsx +0 -187
- package/template/components/ui/separator.tsx +0 -28
- package/template/components/ui/sheet.tsx +0 -139
- package/template/components/ui/sonner.tsx +0 -40
- package/template/components/ui/spinner.tsx +0 -16
- package/template/components/ui/textarea.tsx +0 -18
- package/template/components/ui/tooltip.tsx +0 -61
- package/template/hooks/geistdocs/use-sidebar.ts +0 -13
- package/template/hooks/use-mobile.ts +0 -19
package/dist/proxy.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { generateNotFoundMarkdown, isAIAgent } from "@vercel/agent-readability";
|
|
2
2
|
import { defineI18n } from "fumadocs-core/i18n";
|
|
3
3
|
import { createI18nMiddleware } from "fumadocs-core/i18n/middleware";
|
|
4
|
-
import { isMarkdownPreferred
|
|
4
|
+
import { isMarkdownPreferred } from "fumadocs-core/negotiation";
|
|
5
5
|
import { NextResponse, } from "next/server";
|
|
6
6
|
const MDX_EXTENSION_PATTERN = /\.mdx?$/;
|
|
7
|
+
const PATH_TOKEN_PATTERN = /\*path|:path\*/g;
|
|
8
|
+
const PATH_WILDCARD_PATTERN = /\/\*path$/;
|
|
9
|
+
const DEFAULT_MARKDOWN_ROUTE = {
|
|
10
|
+
from: "/docs/*path",
|
|
11
|
+
to: "/[lang]/llms.mdx/*path",
|
|
12
|
+
};
|
|
13
|
+
const TRAILING_SLASH_PATTERN = /\/$/;
|
|
7
14
|
const getLanguages = (config) => {
|
|
8
15
|
const defaultLanguage = config.defaultLanguage ?? "en";
|
|
9
16
|
const languages = Object.keys(config.translations ?? {});
|
|
@@ -12,7 +19,48 @@ const getLanguages = (config) => {
|
|
|
12
19
|
languages: Array.from(new Set([defaultLanguage, ...languages])),
|
|
13
20
|
};
|
|
14
21
|
};
|
|
15
|
-
|
|
22
|
+
const normalizeHooks = (hooks) => {
|
|
23
|
+
if (!hooks) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return Array.isArray(hooks) ? hooks : [hooks];
|
|
27
|
+
};
|
|
28
|
+
const normalizeBaseUrl = (baseUrl) => {
|
|
29
|
+
if (baseUrl === "/") {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
return baseUrl.replace(TRAILING_SLASH_PATTERN, "");
|
|
33
|
+
};
|
|
34
|
+
const inferMarkdownRoutes = (config) => {
|
|
35
|
+
if (!config.content || config.content.length === 0) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
const sections = config.content.filter((section) => normalizeBaseUrl(section.route) !== "");
|
|
39
|
+
const includeBaseUrlInDestination = config.content.length > 1;
|
|
40
|
+
return sections.map((section) => {
|
|
41
|
+
const baseUrl = normalizeBaseUrl(section.route) || "/";
|
|
42
|
+
const from = `${baseUrl === "/" ? "" : baseUrl}/*path`;
|
|
43
|
+
const toBase = includeBaseUrlInDestination
|
|
44
|
+
? `${normalizeBaseUrl(section.route)}/*path`
|
|
45
|
+
: "/*path";
|
|
46
|
+
return {
|
|
47
|
+
from: from,
|
|
48
|
+
to: `/[lang]/llms.mdx${toBase}`,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const runHooks = async (hooks, proxyContext) => {
|
|
53
|
+
for (const hook of hooks) {
|
|
54
|
+
const response = await hook(proxyContext);
|
|
55
|
+
if (response) {
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
};
|
|
61
|
+
export const createProxy = ({ after, before, config, markdownRoutes, trackMarkdownRequest, }) => {
|
|
62
|
+
const routeMappings = markdownRoutes ??
|
|
63
|
+
inferMarkdownRoutes(config) ?? [DEFAULT_MARKDOWN_ROUTE];
|
|
16
64
|
const { defaultLanguage, languages } = getLanguages(config);
|
|
17
65
|
const i18n = defineI18n({
|
|
18
66
|
defaultLanguage,
|
|
@@ -20,23 +68,47 @@ export const createProxy = ({ config, trackMarkdownRequest, }) => {
|
|
|
20
68
|
hideLocale: "default-locale",
|
|
21
69
|
});
|
|
22
70
|
const internationalizer = createI18nMiddleware(i18n);
|
|
23
|
-
const
|
|
71
|
+
const beforeHooks = normalizeHooks(before);
|
|
72
|
+
const afterHooks = normalizeHooks(after);
|
|
24
73
|
const trackRequest = (context, event) => {
|
|
25
74
|
if (!trackMarkdownRequest) {
|
|
26
75
|
return;
|
|
27
76
|
}
|
|
28
77
|
context.waitUntil(Promise.resolve(trackMarkdownRequest(event)));
|
|
29
78
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
79
|
+
const resolveMarkdownRewrite = (pathname) => {
|
|
80
|
+
for (const route of routeMappings) {
|
|
81
|
+
const hasWildcard = PATH_WILDCARD_PATTERN.test(route.from);
|
|
82
|
+
const basePath = route.from.replace(PATH_WILDCARD_PATTERN, "");
|
|
83
|
+
const matches = hasWildcard
|
|
84
|
+
? pathname === basePath || pathname.startsWith(`${basePath}/`)
|
|
85
|
+
: pathname === route.from;
|
|
86
|
+
if (!matches) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const path = hasWildcard && pathname !== basePath
|
|
90
|
+
? pathname
|
|
91
|
+
.slice(basePath.length + 1)
|
|
92
|
+
.split("/")
|
|
93
|
+
.filter(Boolean)
|
|
94
|
+
: [];
|
|
95
|
+
if (typeof route.to === "function") {
|
|
96
|
+
return route.to({ defaultLanguage, path, pathname });
|
|
97
|
+
}
|
|
98
|
+
const destination = route.to.replace("[lang]", defaultLanguage);
|
|
99
|
+
const pathValue = path.join("/");
|
|
100
|
+
const rewritten = destination.replace(PATH_TOKEN_PATTERN, pathValue);
|
|
101
|
+
return rewritten.endsWith("/") ? rewritten.slice(0, -1) : rewritten;
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
33
105
|
const tryMarkdownRewrite = (request, context, pathname, options) => {
|
|
34
|
-
const result =
|
|
106
|
+
const result = resolveMarkdownRewrite(pathname);
|
|
35
107
|
if (!result) {
|
|
36
108
|
return null;
|
|
37
109
|
}
|
|
38
110
|
trackRequest(context, {
|
|
39
|
-
path: pathname,
|
|
111
|
+
path: options?.trackPath ?? pathname,
|
|
40
112
|
userAgent: request.headers.get("user-agent"),
|
|
41
113
|
referer: request.headers.get("referer"),
|
|
42
114
|
acceptHeader: request.headers.get("accept"),
|
|
@@ -45,10 +117,17 @@ export const createProxy = ({ config, trackMarkdownRequest, }) => {
|
|
|
45
117
|
});
|
|
46
118
|
return NextResponse.rewrite(new URL(result, request.nextUrl));
|
|
47
119
|
};
|
|
48
|
-
const isMdExtensionRequest = (pathname) => (pathname
|
|
49
|
-
pathname
|
|
50
|
-
|
|
51
|
-
(
|
|
120
|
+
const isMdExtensionRequest = (pathname) => (pathname.endsWith(".md") || pathname.endsWith(".mdx")) &&
|
|
121
|
+
Boolean(resolveMarkdownRewrite(pathname.replace(MDX_EXTENSION_PATTERN, "")));
|
|
122
|
+
const handleMarkdownExtensionRequest = (request, context, pathname) => {
|
|
123
|
+
if (!isMdExtensionRequest(pathname)) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
return tryMarkdownRewrite(request, context, pathname.replace(MDX_EXTENSION_PATTERN, ""), {
|
|
127
|
+
requestType: "md-url",
|
|
128
|
+
trackPath: pathname,
|
|
129
|
+
});
|
|
130
|
+
};
|
|
52
131
|
const handleAgentRewrite = (request, context, pathname) => {
|
|
53
132
|
const agentResult = isAIAgent(request);
|
|
54
133
|
if (!agentResult.detected || isMarkdownPreferred(request)) {
|
|
@@ -65,8 +144,23 @@ export const createProxy = ({ config, trackMarkdownRequest, }) => {
|
|
|
65
144
|
headers: { "Content-Type": "text/markdown; charset=utf-8" },
|
|
66
145
|
});
|
|
67
146
|
};
|
|
68
|
-
|
|
147
|
+
const handlePreferredMarkdownRequest = (request, context) => isMarkdownPreferred(request)
|
|
148
|
+
? tryMarkdownRewrite(request, context, request.nextUrl.pathname, {
|
|
149
|
+
requestType: "header-negotiated",
|
|
150
|
+
})
|
|
151
|
+
: null;
|
|
152
|
+
return async (request, context) => {
|
|
69
153
|
const pathname = request.nextUrl.pathname;
|
|
154
|
+
const proxyContext = {
|
|
155
|
+
context,
|
|
156
|
+
defaultLanguage,
|
|
157
|
+
languages,
|
|
158
|
+
request,
|
|
159
|
+
};
|
|
160
|
+
const beforeResponse = await runHooks(beforeHooks, proxyContext);
|
|
161
|
+
if (beforeResponse) {
|
|
162
|
+
return beforeResponse;
|
|
163
|
+
}
|
|
70
164
|
if (pathname === "/llms.txt") {
|
|
71
165
|
trackRequest(context, {
|
|
72
166
|
path: "/llms.txt",
|
|
@@ -75,35 +169,21 @@ export const createProxy = ({ config, trackMarkdownRequest, }) => {
|
|
|
75
169
|
acceptHeader: request.headers.get("accept"),
|
|
76
170
|
});
|
|
77
171
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
requestType: "md-url",
|
|
82
|
-
});
|
|
83
|
-
if (response) {
|
|
84
|
-
return response;
|
|
85
|
-
}
|
|
172
|
+
const extensionResponse = handleMarkdownExtensionRequest(request, context, pathname);
|
|
173
|
+
if (extensionResponse) {
|
|
174
|
+
return extensionResponse;
|
|
86
175
|
}
|
|
87
|
-
if ((pathname
|
|
88
|
-
!pathname.includes("/llms.mdx/")) {
|
|
176
|
+
if (resolveMarkdownRewrite(pathname) && !pathname.includes("/llms.mdx/")) {
|
|
89
177
|
const response = handleAgentRewrite(request, context, pathname);
|
|
90
178
|
if (response) {
|
|
91
179
|
return response;
|
|
92
180
|
}
|
|
93
181
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
if (response) {
|
|
99
|
-
return response;
|
|
100
|
-
}
|
|
182
|
+
const preferredMarkdownResponse = handlePreferredMarkdownRequest(request, context);
|
|
183
|
+
if (preferredMarkdownResponse) {
|
|
184
|
+
return preferredMarkdownResponse;
|
|
101
185
|
}
|
|
102
|
-
|
|
186
|
+
const afterResponse = await runHooks(afterHooks, proxyContext);
|
|
187
|
+
return afterResponse ?? internationalizer(request, context);
|
|
103
188
|
};
|
|
104
189
|
};
|
|
105
|
-
export const createProxyConfig = () => ({
|
|
106
|
-
matcher: [
|
|
107
|
-
"/((?!api|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
|
|
108
|
-
],
|
|
109
|
-
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { NextRequest } from "next/server";
|
|
2
|
+
import type { GeistdocsConfig } from "../config";
|
|
3
|
+
export interface CreateAgentsRouteOptions {
|
|
4
|
+
config: Pick<GeistdocsConfig, "agent" | "basePath" | "content" | "defaultLanguage" | "github" | "nav" | "title" | "translations" | "versions">;
|
|
5
|
+
transform?: (markdown: string, context: {
|
|
6
|
+
lang?: string;
|
|
7
|
+
request: NextRequest;
|
|
8
|
+
}) => Promise<string> | string;
|
|
9
|
+
}
|
|
10
|
+
export declare const createAgentsRoute: ({ config, transform, }: CreateAgentsRouteOptions) => {
|
|
11
|
+
GET: (request: NextRequest, { params }?: {
|
|
12
|
+
params?: Promise<{
|
|
13
|
+
lang?: string;
|
|
14
|
+
}>;
|
|
15
|
+
}) => Promise<Response>;
|
|
16
|
+
generateStaticParams: () => {
|
|
17
|
+
lang: string;
|
|
18
|
+
}[];
|
|
19
|
+
revalidate: false;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,WAAW,CAAC;AAEnE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,IAAI,CACV,eAAe,EACb,OAAO,GACP,UAAU,GACV,SAAS,GACT,iBAAiB,GACjB,QAAQ,GACR,KAAK,GACL,OAAO,GACP,cAAc,GACd,UAAU,CACb,CAAC;IACF,SAAS,CAAC,EAAE,CACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,WAAW,CAAA;KAAE,KAC7C,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;CAC/B;AAgTD,eAAO,MAAM,iBAAiB,GAAI,wBAG/B,wBAAwB;mBAEd,WAAW,eACR;QAAE,MAAM,CAAC,EAAE,OAAO,CAAC;YAAE,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE;;;;;CA2BtD,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
const ABSOLUTE_URL_PATTERN = /^[a-z][a-z\d+.-]*:/i;
|
|
2
|
+
const TRAILING_SLASH_PATTERN = /\/$/;
|
|
3
|
+
const DEFAULT_AGENT_INSTRUCTIONS = [
|
|
4
|
+
"Use /sitemap.md to identify the most relevant documentation pages before answering broad questions.",
|
|
5
|
+
"Use /llms.txt when you need the complete documentation corpus as Markdown context.",
|
|
6
|
+
"Fetch individual documentation pages with a .md or .mdx extension for focused page-level context.",
|
|
7
|
+
"Do not assume API, authentication, OpenAPI, or MCP support unless it is listed in this file.",
|
|
8
|
+
];
|
|
9
|
+
const getLanguages = (config) => {
|
|
10
|
+
const defaultLanguage = config.defaultLanguage ?? "en";
|
|
11
|
+
const languages = Object.keys(config.translations ?? {});
|
|
12
|
+
return Array.from(new Set([defaultLanguage, ...languages]));
|
|
13
|
+
};
|
|
14
|
+
const normalizeBasePath = (basePath) => basePath?.replace(TRAILING_SLASH_PATTERN, "") ?? "";
|
|
15
|
+
const withBasePath = (href, basePath) => {
|
|
16
|
+
if (!(href.startsWith("/") && basePath)) {
|
|
17
|
+
return href;
|
|
18
|
+
}
|
|
19
|
+
const normalizedBasePath = normalizeBasePath(basePath);
|
|
20
|
+
if (href === normalizedBasePath ||
|
|
21
|
+
href.startsWith(`${normalizedBasePath}/`)) {
|
|
22
|
+
return href;
|
|
23
|
+
}
|
|
24
|
+
return `${normalizedBasePath}${href}`;
|
|
25
|
+
};
|
|
26
|
+
const toAbsoluteUrl = ({ basePath, href, origin, }) => {
|
|
27
|
+
if (ABSOLUTE_URL_PATTERN.test(href) || href.startsWith("#")) {
|
|
28
|
+
return href;
|
|
29
|
+
}
|
|
30
|
+
return new URL(withBasePath(href, basePath), origin).toString();
|
|
31
|
+
};
|
|
32
|
+
const toSiteUrl = (config, origin, href) => toAbsoluteUrl({ basePath: config.basePath, href, origin });
|
|
33
|
+
const escapeMarkdown = (value) => value.replace(/([\\[\]])/g, "\\$1");
|
|
34
|
+
const renderLink = (label, href, description) => {
|
|
35
|
+
const link = `- [${escapeMarkdown(label)}](${href})`;
|
|
36
|
+
return description ? `${link}: ${description}` : link;
|
|
37
|
+
};
|
|
38
|
+
const renderList = (items) => items.map((item) => `- ${item}`).join("\n");
|
|
39
|
+
const getDocsLinks = (config, origin) => {
|
|
40
|
+
const contentLinks = (config.content ?? []).map((section) => ({
|
|
41
|
+
label: section.label,
|
|
42
|
+
href: toAbsoluteUrl({
|
|
43
|
+
basePath: config.basePath,
|
|
44
|
+
href: section.route,
|
|
45
|
+
origin,
|
|
46
|
+
}),
|
|
47
|
+
description: `Documentation section: ${section.id}`,
|
|
48
|
+
}));
|
|
49
|
+
if (contentLinks.length > 0) {
|
|
50
|
+
return contentLinks;
|
|
51
|
+
}
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
label: "Documentation",
|
|
55
|
+
href: toAbsoluteUrl({ basePath: config.basePath, href: "/docs", origin }),
|
|
56
|
+
description: "Primary human-readable documentation",
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
};
|
|
60
|
+
const getNavigationLinks = (nav, config, origin) => (nav ?? []).map((item) => ({
|
|
61
|
+
label: item.label,
|
|
62
|
+
href: toAbsoluteUrl({ basePath: config.basePath, href: item.href, origin }),
|
|
63
|
+
description: item.external ? "External navigation link" : undefined,
|
|
64
|
+
}));
|
|
65
|
+
const renderDocumentationSection = (config, origin) => [
|
|
66
|
+
"## Documentation Surfaces",
|
|
67
|
+
"",
|
|
68
|
+
...getDocsLinks(config, origin).map((link) => renderLink(link.label, link.href, link.description)),
|
|
69
|
+
renderLink("Full documentation context", toSiteUrl(config, origin, "/llms.txt"), "All configured documentation as Markdown"),
|
|
70
|
+
renderLink("Semantic documentation sitemap", toSiteUrl(config, origin, "/sitemap.md"), "High-level documentation map for agent navigation"),
|
|
71
|
+
"- Page-level Markdown: append .md or .mdx to a documentation URL",
|
|
72
|
+
"",
|
|
73
|
+
];
|
|
74
|
+
const renderProductSection = (product = {}) => {
|
|
75
|
+
if (!(product.category || product.audience?.length || product.useCases?.length)) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
const lines = ["## Product Context", ""];
|
|
79
|
+
if (product.category) {
|
|
80
|
+
lines.push(`- Category: ${product.category}`);
|
|
81
|
+
}
|
|
82
|
+
if (product.audience?.length) {
|
|
83
|
+
lines.push(`- Audience: ${product.audience.join(", ")}`);
|
|
84
|
+
}
|
|
85
|
+
if (product.useCases?.length) {
|
|
86
|
+
lines.push("Common use cases:", "", renderList(product.useCases));
|
|
87
|
+
}
|
|
88
|
+
lines.push("");
|
|
89
|
+
return lines;
|
|
90
|
+
};
|
|
91
|
+
const getApiLinks = (api, config, origin) => [
|
|
92
|
+
api?.openApiUrl &&
|
|
93
|
+
renderLink("OpenAPI specification", toSiteUrl(config, origin, api.openApiUrl)),
|
|
94
|
+
api?.authDocsUrl &&
|
|
95
|
+
renderLink("Authentication documentation", toSiteUrl(config, origin, api.authDocsUrl)),
|
|
96
|
+
api?.scopesDocsUrl &&
|
|
97
|
+
renderLink("Permission scopes", toSiteUrl(config, origin, api.scopesDocsUrl)),
|
|
98
|
+
api?.rateLimitsUrl &&
|
|
99
|
+
renderLink("Rate limits", toSiteUrl(config, origin, api.rateLimitsUrl)),
|
|
100
|
+
api?.errorsUrl &&
|
|
101
|
+
renderLink("Error handling", toSiteUrl(config, origin, api.errorsUrl)),
|
|
102
|
+
].filter((link) => Boolean(link));
|
|
103
|
+
const renderApiSection = (api, config, origin) => {
|
|
104
|
+
const links = getApiLinks(api, config, origin);
|
|
105
|
+
return links.length > 0 ? ["## API and Auth", "", ...links, ""] : [];
|
|
106
|
+
};
|
|
107
|
+
const renderMcpSection = (mcp, config, origin) => {
|
|
108
|
+
const links = [
|
|
109
|
+
mcp?.manifestUrl &&
|
|
110
|
+
renderLink("MCP manifest", toSiteUrl(config, origin, mcp.manifestUrl)),
|
|
111
|
+
...(mcp?.servers ?? []).map((server) => renderLink(server.name, toSiteUrl(config, origin, server.url), server.description)),
|
|
112
|
+
].filter((link) => Boolean(link));
|
|
113
|
+
return links.length > 0 ? ["## MCP", "", ...links, ""] : [];
|
|
114
|
+
};
|
|
115
|
+
const renderImportantLinksSection = (agent, config, origin) => {
|
|
116
|
+
const links = [
|
|
117
|
+
...getNavigationLinks(config.nav, config, origin),
|
|
118
|
+
...(agent.links ?? []).map((link) => ({
|
|
119
|
+
...link,
|
|
120
|
+
href: toSiteUrl(config, origin, link.href),
|
|
121
|
+
})),
|
|
122
|
+
];
|
|
123
|
+
if (config.github) {
|
|
124
|
+
links.push({
|
|
125
|
+
label: "GitHub repository",
|
|
126
|
+
href: `https://github.com/${config.github.owner}/${config.github.repo}`,
|
|
127
|
+
description: "Source repository",
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return links.length > 0
|
|
131
|
+
? [
|
|
132
|
+
"## Important Links",
|
|
133
|
+
"",
|
|
134
|
+
...links.map((link) => renderLink(link.label, link.href, link.description)),
|
|
135
|
+
"",
|
|
136
|
+
]
|
|
137
|
+
: [];
|
|
138
|
+
};
|
|
139
|
+
const renderVersionsSection = (config, origin) => {
|
|
140
|
+
if (!config.versions?.items.length) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
return [
|
|
144
|
+
"## Versions",
|
|
145
|
+
"",
|
|
146
|
+
...config.versions.items.map((version) => {
|
|
147
|
+
const marker = version.id === config.versions?.current ? " current" : "";
|
|
148
|
+
const href = version.href ?? version.routePrefix;
|
|
149
|
+
return href
|
|
150
|
+
? renderLink(`${version.label}${marker}`, toSiteUrl(config, origin, href), version.description)
|
|
151
|
+
: `- ${version.label}${marker}${version.description ? `: ${version.description}` : ""}`;
|
|
152
|
+
}),
|
|
153
|
+
"",
|
|
154
|
+
];
|
|
155
|
+
};
|
|
156
|
+
const renderInstructionsSection = (agent) => [
|
|
157
|
+
"## Agent Instructions",
|
|
158
|
+
"",
|
|
159
|
+
renderList(agent.instructions?.length ? agent.instructions : DEFAULT_AGENT_INSTRUCTIONS),
|
|
160
|
+
"",
|
|
161
|
+
];
|
|
162
|
+
const renderAgentsMarkdown = (config, request) => {
|
|
163
|
+
const agent = config.agent ?? {};
|
|
164
|
+
const product = agent.product ?? {};
|
|
165
|
+
const origin = request.nextUrl.origin;
|
|
166
|
+
const name = product.name ?? config.title;
|
|
167
|
+
return [
|
|
168
|
+
`# ${name}`,
|
|
169
|
+
"",
|
|
170
|
+
...(product.description ? [product.description, ""] : []),
|
|
171
|
+
"This file helps AI agents understand and use this documentation site.",
|
|
172
|
+
"",
|
|
173
|
+
...renderDocumentationSection(config, origin),
|
|
174
|
+
...renderProductSection(product),
|
|
175
|
+
...renderApiSection(agent.api, config, origin),
|
|
176
|
+
...renderMcpSection(agent.mcp, config, origin),
|
|
177
|
+
...renderImportantLinksSection(agent, config, origin),
|
|
178
|
+
...renderVersionsSection(config, origin),
|
|
179
|
+
...renderInstructionsSection(agent),
|
|
180
|
+
].join("\n");
|
|
181
|
+
};
|
|
182
|
+
export const createAgentsRoute = ({ config, transform, }) => {
|
|
183
|
+
const GET = async (request, { params } = {}) => {
|
|
184
|
+
if (config.agent?.enabled === false) {
|
|
185
|
+
return new Response("Not found", { status: 404 });
|
|
186
|
+
}
|
|
187
|
+
const { lang } = (await params) ?? {};
|
|
188
|
+
const markdown = renderAgentsMarkdown(config, request);
|
|
189
|
+
return new Response(transform ? await transform(markdown, { lang, request }) : markdown, {
|
|
190
|
+
headers: {
|
|
191
|
+
"Content-Type": "text/markdown; charset=utf-8",
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
const generateStaticParams = () => getLanguages(config).map((lang) => ({ lang }));
|
|
196
|
+
return {
|
|
197
|
+
GET,
|
|
198
|
+
generateStaticParams,
|
|
199
|
+
revalidate: false,
|
|
200
|
+
};
|
|
201
|
+
};
|
package/dist/routes/chat.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { GeistdocsConfig } from "../config";
|
|
2
|
-
import type {
|
|
3
|
-
type SourceBundle =
|
|
2
|
+
import type { GeistdocsSourceBundle } from "../source";
|
|
3
|
+
type SourceBundle = GeistdocsSourceBundle;
|
|
4
|
+
interface ChatProxyConfig {
|
|
5
|
+
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
6
|
+
url: string;
|
|
7
|
+
}
|
|
4
8
|
interface CreateChatRouteOptions {
|
|
5
|
-
config: Pick<GeistdocsConfig, "ai" | "defaultLanguage">;
|
|
6
|
-
|
|
9
|
+
config: Pick<GeistdocsConfig, "ai" | "basePath" | "defaultLanguage" | "translations">;
|
|
10
|
+
proxy?: ChatProxyConfig;
|
|
11
|
+
source?: SourceBundle;
|
|
12
|
+
sources?: SourceBundle[];
|
|
7
13
|
}
|
|
8
|
-
export declare const createChatRoute: ({ config, source }: CreateChatRouteOptions) => {
|
|
14
|
+
export declare const createChatRoute: ({ config, proxy, source, sources, }: CreateChatRouteOptions) => {
|
|
9
15
|
POST: (req: Request) => Promise<Response>;
|
|
10
16
|
maxDuration: 800;
|
|
11
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/routes/chat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/routes/chat.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAEvD,KAAK,YAAY,GAAG,qBAAqB,CAAC;AAyB1C,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IACnE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,UAAU,sBAAsB;IAC9B,MAAM,EAAE,IAAI,CACV,eAAe,EACf,IAAI,GAAG,UAAU,GAAG,iBAAiB,GAAG,cAAc,CACvD,CAAC;IACF,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;CAC1B;AAsqBD,eAAO,MAAM,eAAe,GAAI,qCAK7B,sBAAsB;gBAIE,OAAO;;CAqIjC,CAAC"}
|