@vercel/geistdocs 1.3.0-canary.5af98bc → 1.3.0
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 +8 -0
- package/dist/assets/logos/logo-svelte-kit.d.ts.map +1 -0
- package/dist/assets/logos/logo-svelte-kit.js +7 -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 +1 -1
- 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.js +3 -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.js +3 -3
- 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.map +1 -1
- package/dist/internal/page-actions-client.js +17 -6
- 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 +1 -1
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +2 -1
- package/dist/internal/sidebar.d.ts +4 -1
- package/dist/internal/sidebar.d.ts.map +1 -1
- package/dist/internal/sidebar.js +4 -4
- 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 +2 -1
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +2 -2
- package/dist/mdx.d.ts +55 -24
- package/dist/mdx.d.ts.map +1 -1
- package/dist/mdx.js +7 -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 +46 -17
- 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/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 +134 -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 +150 -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 +57 -5
- package/template/content/docs/configuration.cn.mdx +47 -7
- package/template/content/docs/configuration.mdx +158 -1
- package/template/content/docs/deployment.mdx +11 -0
- package/template/content/docs/edit-on-github.mdx +2 -2
- package/template/content/docs/env.mdx +36 -5
- package/template/content/docs/feedback.mdx +2 -2
- package/template/content/docs/getting-started.cn.mdx +2 -2
- package/template/content/docs/getting-started.mdx +8 -1
- package/template/content/docs/index.cn.mdx +36 -33
- package/template/content/docs/index.mdx +12 -0
- package/template/content/docs/internationalization.mdx +1 -1
- package/template/content/docs/llms-txt.cn.mdx +24 -2
- package/template/content/docs/llms-txt.mdx +44 -12
- package/template/content/docs/md.cn.mdx +12 -15
- package/template/content/docs/md.mdx +26 -16
- package/template/content/docs/meta.json +4 -0
- package/template/content/docs/migration.mdx +364 -0
- package/template/content/docs/open-in-chat.mdx +8 -10
- package/template/content/docs/provider.cn.mdx +6 -5
- package/template/content/docs/provider.mdx +9 -8
- package/template/content/docs/proxy.cn.mdx +96 -0
- package/template/content/docs/proxy.mdx +178 -0
- package/template/content/docs/rss.mdx +2 -2
- package/template/content/docs/syntax.mdx +1 -1
- package/template/content/docs/theme-aware-image.mdx +1 -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 -77
- 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/pages/docs.d.ts
CHANGED
|
@@ -3,15 +3,26 @@ import type { MDXComponents } from "mdx/types";
|
|
|
3
3
|
import type { Metadata } from "next";
|
|
4
4
|
import type { ComponentProps, ComponentType, ReactNode } from "react";
|
|
5
5
|
import type { GeistdocsConfig } from "../config";
|
|
6
|
-
import type
|
|
7
|
-
type
|
|
6
|
+
import { type GeistdocsPageVisibilityData } from "../internal/page-visibility";
|
|
7
|
+
import type { GeistdocsSourceBundle } from "../source";
|
|
8
|
+
type SourceBundle = GeistdocsSourceBundle;
|
|
8
9
|
type GeistdocsPage = NonNullable<ReturnType<SourceBundle["source"]["getPage"]>>;
|
|
9
10
|
type PageActionsBundle = ReturnType<typeof createPageActions>;
|
|
10
11
|
type DocsPageLink = MDXComponents["a"];
|
|
12
|
+
interface DocsPageParams {
|
|
13
|
+
lang: string;
|
|
14
|
+
slug?: string[];
|
|
15
|
+
}
|
|
11
16
|
type DocsPageMdx = MDXComponents | ((context: {
|
|
12
17
|
link: DocsPageLink;
|
|
18
|
+
page: GeistdocsPage;
|
|
19
|
+
source: SourceBundle;
|
|
13
20
|
}) => MDXComponents);
|
|
14
|
-
|
|
21
|
+
type OpenGraphImages = NonNullable<Metadata["openGraph"]>["images"];
|
|
22
|
+
interface DocsPageOpenGraphOptions {
|
|
23
|
+
images?: boolean | OpenGraphImages;
|
|
24
|
+
}
|
|
25
|
+
interface DocsPageData extends GeistdocsPageVisibilityData {
|
|
15
26
|
body: ComponentType<{
|
|
16
27
|
components?: MDXComponents;
|
|
17
28
|
}>;
|
|
@@ -22,24 +33,41 @@ interface DocsPageData {
|
|
|
22
33
|
}
|
|
23
34
|
interface CreateDocsPageOptions {
|
|
24
35
|
config: Pick<GeistdocsConfig, "ai" | "feedback" | "github" | "pageActions" | "siteId">;
|
|
36
|
+
filterStaticParams?: (params: DocsPageParams) => boolean;
|
|
37
|
+
getPageUrl?: (context: {
|
|
38
|
+
page: GeistdocsPage;
|
|
39
|
+
params: DocsPageParams;
|
|
40
|
+
}) => string;
|
|
25
41
|
mdx?: DocsPageMdx;
|
|
42
|
+
metadata?: (context: {
|
|
43
|
+
metadata: Metadata;
|
|
44
|
+
page: GeistdocsPage;
|
|
45
|
+
params: DocsPageParams;
|
|
46
|
+
}) => Metadata | Promise<Metadata>;
|
|
47
|
+
openGraph?: DocsPageOpenGraphOptions;
|
|
26
48
|
pageActions?: PageActionsBundle;
|
|
27
49
|
renderTop?: (context: {
|
|
28
50
|
data: DocsPageData;
|
|
29
51
|
markdown: string;
|
|
30
52
|
page: GeistdocsPage;
|
|
53
|
+
pageUrl: string;
|
|
31
54
|
}) => ReactNode;
|
|
55
|
+
resolveLink?: (context: {
|
|
56
|
+
link: DocsPageLink;
|
|
57
|
+
page: GeistdocsPage;
|
|
58
|
+
source: SourceBundle;
|
|
59
|
+
}) => DocsPageLink;
|
|
32
60
|
source: SourceBundle;
|
|
33
61
|
tableOfContentPopover?: ComponentProps<typeof FumadocsDocsPage>["tableOfContentPopover"];
|
|
34
62
|
}
|
|
35
|
-
export declare const createDocsPage: ({ config, source, mdx, pageActions, renderTop, tableOfContentPopover, }: CreateDocsPageOptions) => {
|
|
63
|
+
export declare const createDocsPage: ({ config, source, mdx, pageActions, filterStaticParams, getPageUrl, metadata, openGraph, renderTop, resolveLink, tableOfContentPopover, }: CreateDocsPageOptions) => {
|
|
36
64
|
Page: ({ params, }: {
|
|
37
65
|
params: Promise<{
|
|
38
66
|
lang: string;
|
|
39
67
|
slug?: string[];
|
|
40
68
|
}>;
|
|
41
69
|
}) => Promise<import("react/jsx-runtime").JSX.Element>;
|
|
42
|
-
generateStaticParams: () =>
|
|
70
|
+
generateStaticParams: () => DocsPageParams[];
|
|
43
71
|
generateMetadata: ({ params, }: {
|
|
44
72
|
params: Promise<{
|
|
45
73
|
lang: string;
|
package/dist/pages/docs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/pages/docs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,QAAQ,IAAI,gBAAgB,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/pages/docs.tsx"],"names":[],"mappings":"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"}
|
package/dist/pages/docs.js
CHANGED
|
@@ -5,60 +5,89 @@ import { notFound } from "next/navigation";
|
|
|
5
5
|
import { cn } from "../internal/cn";
|
|
6
6
|
import { createPageActions as createInternalPageActions } from "../internal/page-actions";
|
|
7
7
|
import { GeistdocsPageActions } from "../internal/page-actions-client";
|
|
8
|
+
import { getPageRobots, } from "../internal/page-visibility";
|
|
8
9
|
import { GeistdocsTableOfContents } from "../internal/table-of-contents";
|
|
9
10
|
import { createMdxComponents } from "../mdx";
|
|
10
11
|
const DocsTitle = ({ className, ...props }) => (_jsx(FumadocsDocsTitle, { className: cn("mb-4 text-4xl tracking-tight", className), ...props }));
|
|
11
12
|
const DocsDescription = (props) => _jsx(FumadocsDocsDescription, { ...props });
|
|
12
13
|
const DocsBody = ({ className, ...props }) => (_jsx(FumadocsDocsBody, { className: cn("mx-auto w-full", className), ...props }));
|
|
13
|
-
export const createDocsPage = ({ config, source, mdx, pageActions = createInternalPageActions({ config }), renderTop, tableOfContentPopover, }) => {
|
|
14
|
+
export const createDocsPage = ({ config, source, mdx, pageActions = createInternalPageActions({ config }), filterStaticParams, getPageUrl, metadata, openGraph, renderTop, resolveLink, tableOfContentPopover, }) => {
|
|
14
15
|
const Page = async ({ params, }) => {
|
|
15
|
-
const
|
|
16
|
+
const resolvedParams = await params;
|
|
17
|
+
const { slug, lang } = resolvedParams;
|
|
16
18
|
const page = source.source.getPage(slug, lang);
|
|
17
19
|
if (!page) {
|
|
18
20
|
notFound();
|
|
19
21
|
}
|
|
20
22
|
const data = page.data;
|
|
21
23
|
const MDX = data.body;
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
+
const defaultLink = createRelativeLink(source.source, page);
|
|
25
|
+
const link = resolveLink
|
|
26
|
+
? resolveLink({ link: defaultLink, page, source })
|
|
27
|
+
: defaultLink;
|
|
28
|
+
const resolvedMdx = typeof mdx === "function" ? mdx({ link, page, source }) : mdx;
|
|
29
|
+
const pageUrl = getPageUrl?.({ page, params: resolvedParams }) ?? page.url;
|
|
24
30
|
const markdown = pageActions.getExtraActions || renderTop
|
|
25
31
|
? await source.getPageMarkdown(page)
|
|
26
32
|
: undefined;
|
|
27
33
|
const footerActions = markdown
|
|
28
|
-
? (pageActions.getExtraActions?.({
|
|
34
|
+
? (pageActions.getExtraActions?.({
|
|
35
|
+
markdown,
|
|
36
|
+
page: {
|
|
37
|
+
path: page.path,
|
|
38
|
+
url: pageUrl,
|
|
39
|
+
},
|
|
40
|
+
}) ?? [])
|
|
29
41
|
: [];
|
|
30
|
-
const tocFooter = (_jsx("div", { className: "mt-3 border-
|
|
42
|
+
const tocFooter = (_jsx("div", { className: "mt-3 border-gray-alpha-400 border-t pt-3", children: _jsx("nav", { "aria-label": "Page actions", className: "flex min-w-0 flex-col gap-1", children: _jsx(GeistdocsPageActions, { config: pageActions.config, extraActions: footerActions, page: {
|
|
31
43
|
path: page.path,
|
|
32
|
-
url:
|
|
44
|
+
url: pageUrl,
|
|
33
45
|
} }) }) }));
|
|
34
46
|
return (_jsxs(FumadocsDocsPage, { full: data.full, tableOfContent: {
|
|
35
47
|
enabled: true,
|
|
36
48
|
single: true,
|
|
37
49
|
component: (_jsx(GeistdocsTableOfContents, { footer: tocFooter, toc: data.toc ?? [] })),
|
|
38
|
-
}, tableOfContentPopover: tableOfContentPopover, toc: data.toc, children: [renderTop?.({ data, markdown: markdown ?? "", page }), _jsx(DocsTitle, { children: data.title }), _jsx(DocsDescription, { children: data.description }), _jsx(DocsBody, { children: _jsx(MDX, { components: {
|
|
50
|
+
}, tableOfContentPopover: tableOfContentPopover, toc: data.toc, children: [renderTop?.({ data, markdown: markdown ?? "", page, pageUrl }), _jsx(DocsTitle, { children: data.title }), _jsx(DocsDescription, { children: data.description }), _jsx(DocsBody, { children: _jsx(MDX, { components: {
|
|
39
51
|
...createMdxComponents({ a: link }),
|
|
40
52
|
...resolvedMdx,
|
|
41
53
|
} }) })] }));
|
|
42
54
|
};
|
|
43
|
-
const generateStaticParams = () =>
|
|
55
|
+
const generateStaticParams = () => {
|
|
56
|
+
const params = source.source.generateParams();
|
|
57
|
+
return filterStaticParams ? params.filter(filterStaticParams) : params;
|
|
58
|
+
};
|
|
44
59
|
const generateMetadata = async ({ params, }) => {
|
|
45
|
-
const
|
|
60
|
+
const resolvedParams = await params;
|
|
61
|
+
const { slug, lang } = resolvedParams;
|
|
46
62
|
const page = source.source.getPage(slug, lang);
|
|
47
63
|
if (!page) {
|
|
48
64
|
notFound();
|
|
49
65
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
const data = page.data;
|
|
67
|
+
const pageUrl = getPageUrl?.({ page, params: resolvedParams }) ?? page.url;
|
|
68
|
+
const openGraphImages = openGraph?.images === true
|
|
69
|
+
? source.getPageImage(page).url
|
|
70
|
+
: openGraph?.images;
|
|
71
|
+
const defaultMetadata = {
|
|
72
|
+
title: data.title,
|
|
73
|
+
description: data.description,
|
|
74
|
+
keywords: data.keywords,
|
|
75
|
+
robots: getPageRobots(page),
|
|
76
|
+
...(openGraphImages ? { openGraph: { images: openGraphImages } } : {}),
|
|
56
77
|
alternates: {
|
|
78
|
+
canonical: data.canonical,
|
|
57
79
|
types: {
|
|
58
|
-
"text/markdown":
|
|
80
|
+
"text/markdown": pageUrl === "/docs" ? "/docs.md" : `${pageUrl}.md`,
|
|
59
81
|
},
|
|
60
82
|
},
|
|
61
83
|
};
|
|
84
|
+
return metadata
|
|
85
|
+
? await metadata({
|
|
86
|
+
metadata: defaultMetadata,
|
|
87
|
+
page,
|
|
88
|
+
params: resolvedParams,
|
|
89
|
+
})
|
|
90
|
+
: defaultMetadata;
|
|
62
91
|
};
|
|
63
92
|
return {
|
|
64
93
|
Page,
|
package/dist/proxy.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type NextFetchEvent, type NextRequest } from "next/server";
|
|
2
2
|
import type { GeistdocsConfig } from "./config";
|
|
3
|
-
type DetectionMethod = "ua-match" | "signature-agent" | "heuristic" | null;
|
|
4
|
-
interface TrackMarkdownRequestEvent {
|
|
3
|
+
export type DetectionMethod = "ua-match" | "signature-agent" | "heuristic" | null;
|
|
4
|
+
export interface TrackMarkdownRequestEvent {
|
|
5
5
|
acceptHeader: string | null;
|
|
6
6
|
detectionMethod?: DetectionMethod;
|
|
7
7
|
path: string;
|
|
@@ -9,13 +9,29 @@ interface TrackMarkdownRequestEvent {
|
|
|
9
9
|
requestType?: "md-url" | "header-negotiated" | "agent-rewrite";
|
|
10
10
|
userAgent: string | null;
|
|
11
11
|
}
|
|
12
|
-
interface
|
|
13
|
-
|
|
12
|
+
export interface GeistdocsProxyContext {
|
|
13
|
+
context: NextFetchEvent;
|
|
14
|
+
defaultLanguage: string;
|
|
15
|
+
languages: string[];
|
|
16
|
+
request: NextRequest;
|
|
17
|
+
}
|
|
18
|
+
type ProxyHookResult = Response | undefined | null;
|
|
19
|
+
export type GeistdocsProxyHook = (context: GeistdocsProxyContext) => Promise<ProxyHookResult> | ProxyHookResult;
|
|
20
|
+
export interface GeistdocsMarkdownRoute {
|
|
21
|
+
from: `/${string}`;
|
|
22
|
+
to: `/${string}` | ((context: {
|
|
23
|
+
defaultLanguage: string;
|
|
24
|
+
path: string[];
|
|
25
|
+
pathname: string;
|
|
26
|
+
}) => `/${string}`);
|
|
27
|
+
}
|
|
28
|
+
export interface CreateProxyOptions {
|
|
29
|
+
after?: GeistdocsProxyHook | GeistdocsProxyHook[];
|
|
30
|
+
before?: GeistdocsProxyHook | GeistdocsProxyHook[];
|
|
31
|
+
config: Pick<GeistdocsConfig, "content" | "defaultLanguage" | "translations">;
|
|
32
|
+
markdownRoutes?: GeistdocsMarkdownRoute[];
|
|
14
33
|
trackMarkdownRequest?: (event: TrackMarkdownRequestEvent) => Promise<void> | void;
|
|
15
34
|
}
|
|
16
|
-
export declare const createProxy: ({ config, trackMarkdownRequest, }: CreateProxyOptions) => (request: NextRequest, context: NextFetchEvent) =>
|
|
17
|
-
export declare const createProxyConfig: () => {
|
|
18
|
-
matcher: string[];
|
|
19
|
-
};
|
|
35
|
+
export declare const createProxy: ({ after, before, config, markdownRoutes, trackMarkdownRequest, }: CreateProxyOptions) => (request: NextRequest, context: NextFetchEvent) => Promise<import("next/dist/server/web/types").NextMiddlewareResult>;
|
|
20
36
|
export {};
|
|
21
37
|
//# sourceMappingURL=proxy.d.ts.map
|
package/dist/proxy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,iBAAiB,GACjB,WAAW,GACX,IAAI,CAAC;AAET,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,QAAQ,GAAG,mBAAmB,GAAG,eAAe,CAAC;IAC/D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,cAAc,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,KAAK,eAAe,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,IAAI,MAAM,EAAE,CAAC;IACnB,EAAE,EACE,IAAI,MAAM,EAAE,GACZ,CAAC,CAAC,OAAO,EAAE;QACT,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,KAAK,IAAI,MAAM,EAAE,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,CAAC;IAClD,MAAM,CAAC,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,CAAC;IACnD,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,iBAAiB,GAAG,cAAc,CAAC,CAAC;IAC9E,cAAc,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAC1C,oBAAoB,CAAC,EAAE,CACrB,KAAK,EAAE,yBAAyB,KAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3B;AAiFD,eAAO,MAAM,WAAW,GAAI,kEAMzB,kBAAkB,MAkJL,SAAS,WAAW,EAAE,SAAS,cAAc,uEAmD5D,CAAC"}
|
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"}
|