doccupine 0.0.139 → 0.0.141
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/README.md +14 -7
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +191 -0
- package/dist/index.d.ts +3 -7
- package/dist/index.js +5 -1895
- package/dist/lib/config-manager.d.ts +1 -0
- package/dist/lib/config-manager.js +63 -3
- package/dist/lib/generated-artifacts.d.ts +26 -0
- package/dist/lib/generated-artifacts.js +147 -0
- package/dist/lib/layout.js +30 -30
- package/dist/lib/metadata.js +58 -30
- package/dist/lib/openapi-types.d.ts +2 -2
- package/dist/lib/openapi.d.ts +6 -3
- package/dist/lib/openapi.js +330 -50
- package/dist/lib/output-safety.d.ts +15 -0
- package/dist/lib/output-safety.js +428 -0
- package/dist/lib/structures.js +11 -0
- package/dist/lib/utils.d.ts +18 -0
- package/dist/lib/utils.js +125 -0
- package/dist/mdx-to-nextjs-generator.d.ts +166 -0
- package/dist/mdx-to-nextjs-generator.js +2229 -0
- package/dist/templates/app/api/gate/route.d.ts +1 -1
- package/dist/templates/app/api/gate/route.js +18 -6
- package/dist/templates/app/api/mcp/route.d.ts +1 -1
- package/dist/templates/app/api/mcp/route.js +181 -111
- package/dist/templates/app/api/playground/route.d.ts +1 -1
- package/dist/templates/app/api/playground/route.js +45 -13
- package/dist/templates/app/api/rag/route.d.ts +1 -1
- package/dist/templates/app/api/rag/route.js +102 -25
- package/dist/templates/app/api/search/route.d.ts +1 -1
- package/dist/templates/app/api/search/route.js +5 -0
- package/dist/templates/app/robots.d.ts +1 -1
- package/dist/templates/app/robots.js +1 -26
- package/dist/templates/app/theme.d.ts +1 -1
- package/dist/templates/app/theme.js +31 -19
- package/dist/templates/components/Chat.d.ts +1 -1
- package/dist/templates/components/Chat.js +411 -104
- package/dist/templates/components/Docs.d.ts +1 -1
- package/dist/templates/components/Docs.js +56 -13
- package/dist/templates/components/SearchDocs.d.ts +1 -1
- package/dist/templates/components/SearchDocs.js +63 -11
- package/dist/templates/components/SearchModalContent.d.ts +1 -1
- package/dist/templates/components/SearchModalContent.js +191 -49
- package/dist/templates/components/SideBar.d.ts +1 -1
- package/dist/templates/components/SideBar.js +8 -2
- package/dist/templates/components/layout/Accordion.d.ts +1 -1
- package/dist/templates/components/layout/Accordion.js +26 -3
- package/dist/templates/components/layout/ApiPlayground.d.ts +1 -1
- package/dist/templates/components/layout/ApiPlayground.js +4 -7
- package/dist/templates/components/layout/Badge.d.ts +1 -1
- package/dist/templates/components/layout/Badge.js +1 -1
- package/dist/templates/components/layout/Button.d.ts +1 -1
- package/dist/templates/components/layout/Button.js +4 -4
- package/dist/templates/components/layout/Callout.d.ts +1 -1
- package/dist/templates/components/layout/Callout.js +6 -6
- package/dist/templates/components/layout/Card.d.ts +1 -1
- package/dist/templates/components/layout/Card.js +9 -4
- package/dist/templates/components/layout/CherryThemeProvider.d.ts +1 -1
- package/dist/templates/components/layout/CherryThemeProvider.js +63 -12
- package/dist/templates/components/layout/Code.d.ts +1 -1
- package/dist/templates/components/layout/Code.js +5 -5
- package/dist/templates/components/layout/CopyButton.d.ts +1 -1
- package/dist/templates/components/layout/CopyButton.js +1 -1
- package/dist/templates/components/layout/DemoTheme.d.ts +1 -1
- package/dist/templates/components/layout/DemoTheme.js +8 -28
- package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
- package/dist/templates/components/layout/DocsComponents.js +57 -18
- package/dist/templates/components/layout/GlobalStyles.d.ts +1 -1
- package/dist/templates/components/layout/GlobalStyles.js +15 -9
- package/dist/templates/components/layout/Prompt.d.ts +1 -1
- package/dist/templates/components/layout/Prompt.js +4 -7
- package/dist/templates/components/layout/Steps.d.ts +1 -1
- package/dist/templates/components/layout/Steps.js +7 -1
- package/dist/templates/components/layout/Tabs.d.ts +1 -1
- package/dist/templates/components/layout/Tabs.js +108 -19
- package/dist/templates/env.example.d.ts +1 -1
- package/dist/templates/env.example.js +11 -0
- package/dist/templates/eslint.config.d.ts +1 -1
- package/dist/templates/eslint.config.js +20 -0
- package/dist/templates/gitignore.d.ts +1 -1
- package/dist/templates/gitignore.js +4 -3
- package/dist/templates/lib/access.d.ts +1 -0
- package/dist/templates/lib/access.js +41 -0
- package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/ai-assistant.mdx.js +17 -1
- package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
- package/dist/templates/mdx/api-playground.mdx.js +5 -3
- package/dist/templates/mdx/authentication.mdx.d.ts +1 -1
- package/dist/templates/mdx/authentication.mdx.js +5 -3
- package/dist/templates/mdx/commands.mdx.d.ts +1 -1
- package/dist/templates/mdx/commands.mdx.js +20 -6
- package/dist/templates/mdx/components.mdx.d.ts +1 -1
- package/dist/templates/mdx/components.mdx.js +3 -0
- package/dist/templates/mdx/deployment-and-hosting.mdx.d.ts +1 -1
- package/dist/templates/mdx/deployment-and-hosting.mdx.js +2 -2
- package/dist/templates/mdx/globals.mdx.d.ts +1 -1
- package/dist/templates/mdx/globals.mdx.js +14 -11
- package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
- package/dist/templates/mdx/model-context-protocol.mdx.js +22 -35
- package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/ai-assistant.mdx.js +23 -0
- package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/api-playground.mdx.js +7 -0
- package/dist/templates/mdx/platform/authentication.mdx.d.ts +1 -0
- package/dist/templates/mdx/platform/authentication.mdx.js +63 -0
- package/dist/templates/mdx/platform/build-and-deploy.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/build-and-deploy.mdx.js +1 -1
- package/dist/templates/mdx/platform/import-from-github.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/import-from-github.mdx.js +2 -2
- package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/index.mdx.js +1 -0
- package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/mcp.mdx.js +2 -1
- package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/navigation-settings.mdx.js +12 -1
- package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/publishing.mdx.js +43 -10
- package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
- package/dist/templates/mdx/platform/self-updating-docs.mdx.js +48 -9
- package/dist/templates/mdx/sections.mdx.d.ts +1 -1
- package/dist/templates/mdx/sections.mdx.js +4 -0
- package/dist/templates/mdx/space.mdx.d.ts +1 -0
- package/dist/templates/mdx/space.mdx.js +125 -0
- package/dist/templates/mdx/tabs.mdx.d.ts +1 -1
- package/dist/templates/mdx/tabs.mdx.js +4 -0
- package/dist/templates/next.config.js +20 -8
- package/dist/templates/package.js +3 -3
- package/dist/templates/prettierignore.d.ts +1 -1
- package/dist/templates/prettierignore.js +1 -0
- package/dist/templates/proxy.js +47 -19
- package/dist/templates/scripts/build-docs-index.d.ts +1 -1
- package/dist/templates/scripts/build-docs-index.js +1 -0
- package/dist/templates/services/mcp/docsContentStub.d.ts +1 -0
- package/dist/templates/services/mcp/docsContentStub.js +1 -0
- package/dist/templates/services/mcp/server.d.ts +1 -1
- package/dist/templates/services/mcp/server.js +140 -83
- package/dist/templates/services/mcp/tools.d.ts +1 -1
- package/dist/templates/services/mcp/tools.js +65 -137
- package/dist/templates/utils/playgroundAllowlist.d.ts +1 -1
- package/dist/templates/utils/playgroundAllowlist.js +13 -4
- package/dist/templates/utils/rateLimit.d.ts +1 -1
- package/dist/templates/utils/rateLimit.js +40 -3
- package/dist/templates/utils/requestBody.d.ts +1 -0
- package/dist/templates/utils/requestBody.js +56 -0
- package/dist/templates/utils/ssrfGuard.d.ts +1 -1
- package/dist/templates/utils/ssrfGuard.js +138 -33
- package/package.json +14 -9
- package/dist/lib/mdxToMarkdown.d.ts +0 -1
- package/dist/lib/mdxToMarkdown.js +0 -134
- package/dist/templates/mdx/image-and-embeds.mdx.d.ts +0 -1
- package/dist/templates/mdx/image-and-embeds.mdx.js +0 -118
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const stepsTemplate = "\"use client\";\nimport React from \"react\";\nimport styled, { useTheme } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\n\nconst StyledStepsContainer = styled.div<{ theme: Theme }>`\n position: relative;\n width: 100%;\n`;\n\nconst StyledStep = styled.div<{ theme: Theme }>`\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 0 0 20px 52px;\n margin: 0;\n position: relative;\n ${({ theme }) => styledText(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n\n &::after {\n content: \"\";\n position: absolute;\n left: 16px;\n top: 0;\n width: 1px;\n height: 100%;\n background: ${({ theme }) => theme.colors.primary};\n background: linear-gradient(\n 180deg,\n ${({ theme }) => theme.colors.primary},\n transparent\n );\n border-radius: 4px;\n }\n`;\n\nconst StepNumber = styled.div<{ theme: Theme }>`\n width: 32px;\n height: 32px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n color: ${({ theme }) => theme.colors.light};\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 700;\n margin-bottom: 12px;\n ${({ theme }) => styledText(theme)};\n position: absolute;\n left: 0;\n top: 0;\n z-index: 1;\n`;\n\nconst StyledStepTitle = styled.div<{ theme: Theme }>`\n margin: 0 0 10px 0;\n padding: 2px 0 0 0;\n color: ${({ theme }) => theme.colors.dark};\n ${({ theme }) => styledText(theme)};\n font-weight: 700;\n display: flex;\n align-items: center;\n gap: 10px;\n`;\n\nconst StepContent = styled.div<{ theme: Theme }>`\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledText(theme)};\n\n & > .code-wrapper {\n margin: 10px 0;\n }\n`;\n\ninterface StepProps extends React.HTMLAttributes<HTMLDivElement> {\n title?: string;\n children: React.ReactNode;\n icon?: IconProps;\n}\n\nfunction Step(_props: StepProps) {\n return null;\n}\n\ninterface StepsProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\nfunction Steps({ children }: StepsProps) {\n const theme = useTheme() as Theme;\n\n const steps = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<StepProps> =>\n React.isValidElement(child),\n );\n\n return (\n <StyledStepsContainer theme={theme}>\n {steps.map((step, index) => {\n const { title, children: stepContent, icon } = step.props;\n\n return (\n <StyledStep key={index} theme={theme}>\n <StepNumber theme={theme}>{index + 1}</StepNumber>\n {(title || icon) && (\n <StyledStepTitle theme={theme}>\n {icon && <Icon name={icon}
|
|
1
|
+
export declare const stepsTemplate = "\"use client\";\nimport React from \"react\";\nimport styled, { useTheme } from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon, IconProps } from \"@/components/layout/Icon\";\n\nconst StyledStepsContainer = styled.div<{ theme: Theme }>`\n position: relative;\n width: 100%;\n`;\n\nconst StyledStep = styled.div<{ theme: Theme }>`\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 0 0 20px 52px;\n margin: 0;\n position: relative;\n ${({ theme }) => styledText(theme)}\n color: ${({ theme }) => theme.colors.grayDark};\n\n &::after {\n content: \"\";\n position: absolute;\n left: 16px;\n top: 0;\n width: 1px;\n height: 100%;\n background: ${({ theme }) => theme.colors.primary};\n background: linear-gradient(\n 180deg,\n ${({ theme }) => theme.colors.primary},\n transparent\n );\n border-radius: 4px;\n }\n`;\n\nconst StepNumber = styled.div<{ theme: Theme }>`\n width: 32px;\n height: 32px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.primary};\n color: ${({ theme }) => theme.colors.light};\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 700;\n margin-bottom: 12px;\n ${({ theme }) => styledText(theme)};\n position: absolute;\n left: 0;\n top: 0;\n z-index: 1;\n`;\n\nconst StyledStepTitle = styled.div<{ theme: Theme }>`\n margin: 0 0 10px 0;\n padding: 2px 0 0 0;\n color: ${({ theme }) => theme.colors.dark};\n ${({ theme }) => styledText(theme)};\n font-weight: 700;\n display: flex;\n align-items: center;\n gap: 10px;\n\n /* See Card: lucide's color prop lands on an SVG presentation attribute,\n where a CSS custom property would not resolve. */\n & > svg.lucide {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\nconst StepContent = styled.div<{ theme: Theme }>`\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledText(theme)};\n\n & > .code-wrapper {\n margin: 10px 0;\n }\n`;\n\ninterface StepProps extends React.HTMLAttributes<HTMLDivElement> {\n title?: string;\n children: React.ReactNode;\n icon?: IconProps;\n}\n\nfunction Step(_props: StepProps) {\n return null;\n}\n\ninterface StepsProps extends React.HTMLAttributes<HTMLDivElement> {\n children: React.ReactNode;\n}\n\nfunction Steps({ children }: StepsProps) {\n const theme = useTheme() as Theme;\n\n const steps = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<StepProps> =>\n React.isValidElement(child),\n );\n\n return (\n <StyledStepsContainer theme={theme}>\n {steps.map((step, index) => {\n const { title, children: stepContent, icon } = step.props;\n\n return (\n <StyledStep key={index} theme={theme}>\n <StepNumber theme={theme}>{index + 1}</StepNumber>\n {(title || icon) && (\n <StyledStepTitle theme={theme}>\n {icon && <Icon name={icon} />}\n {title}\n </StyledStepTitle>\n )}\n <StepContent theme={theme}>{stepContent}</StepContent>\n </StyledStep>\n );\n })}\n </StyledStepsContainer>\n );\n}\n\nexport { Steps, Step };\n";
|
|
@@ -62,6 +62,12 @@ const StyledStepTitle = styled.div<{ theme: Theme }>\`
|
|
|
62
62
|
display: flex;
|
|
63
63
|
align-items: center;
|
|
64
64
|
gap: 10px;
|
|
65
|
+
|
|
66
|
+
/* See Card: lucide's color prop lands on an SVG presentation attribute,
|
|
67
|
+
where a CSS custom property would not resolve. */
|
|
68
|
+
& > svg.lucide {
|
|
69
|
+
color: \${({ theme }) => theme.colors.primary};
|
|
70
|
+
}
|
|
65
71
|
\`;
|
|
66
72
|
|
|
67
73
|
const StepContent = styled.div<{ theme: Theme }>\`
|
|
@@ -105,7 +111,7 @@ function Steps({ children }: StepsProps) {
|
|
|
105
111
|
<StepNumber theme={theme}>{index + 1}</StepNumber>
|
|
106
112
|
{(title || icon) && (
|
|
107
113
|
<StyledStepTitle theme={theme}>
|
|
108
|
-
{icon && <Icon name={icon}
|
|
114
|
+
{icon && <Icon name={icon} />}
|
|
109
115
|
{title}
|
|
110
116
|
</StyledStepTitle>
|
|
111
117
|
)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const tabsTemplate = "\"use client\";\nimport { Theme } from \"@/app/theme\";\nimport { styledText } from \"cherry-styled-components\";\nimport React, {
|
|
1
|
+
export declare const tabsTemplate = "\"use client\";\nimport { Theme } from \"@/app/theme\";\nimport { Button, resetButton, styledText } from \"cherry-styled-components\";\nimport React, { ReactNode, useId, useRef, useState } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport { thinScrollbar } from \"@/components/layout/SharedStyled\";\nimport { Icon } from \"@/components/layout/Icon\";\n\ninterface TabContentProps {\n title: string;\n icon?: string;\n children: ReactNode;\n}\n\ninterface TabsProps {\n children: React.ReactElement<TabContentProps>[];\n}\n\nconst TabsContainer = styled.div`\n width: 100%;\n margin: 0 auto;\n`;\n\nconst TabsList = styled.div<{ theme: Theme }>`\n display: flex;\n overflow: hidden;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n background-color: ${({ theme }) => theme.colors.light};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n overflow-x: auto;\n ${thinScrollbar};\n`;\n\nconst TabButton = styled(Button)<{ theme: Theme; $isActive?: boolean }>`\n ${resetButton};\n appearance: none;\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 12px 20px;\n border: none;\n border-radius: 0;\n background: ${({ theme }) => theme.colors.light};\n cursor: pointer;\n transition: all 0.2s ease;\n border-bottom: 3px solid transparent;\n min-width: fit-content;\n height: auto;\n min-height: 0;\n ${({ theme }) => styledText(theme)};\n color: ${({ theme }) => theme.colors.dark};\n font-weight: 600;\n position: relative;\n\n & svg {\n flex-shrink: 0;\n }\n\n ${({ theme, $isActive }) =>\n $isActive &&\n css`\n color: ${theme.colors.primary};\n border-bottom-color: ${theme.colors.primary};\n `}\n\n &:hover {\n ${({ theme, $isActive }) =>\n !$isActive &&\n css`\n color: ${theme.colors.primary};\n background-color: color-mix(\n in srgb,\n ${theme.colors.primaryLight} 10%,\n transparent\n );\n `}\n }\n\n &:focus-visible {\n outline: none;\n z-index: 1;\n box-shadow: inset 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n\n &:not(:last-child) {\n border-right: 1px solid ${({ theme }) => theme.colors.grayLight};\n }\n\n @media (prefers-reduced-motion: reduce) {\n transition: none;\n }\n`;\n\nconst TabPanel = styled.div<{ theme: Theme }>`\n background-color: ${({ theme }) => theme.colors.light};\n padding: 20px;\n border-radius: 0 0 ${({ theme }) => theme.spacing.radius.lg}\n ${({ theme }) => theme.spacing.radius.lg};\n color: ${({ theme }) => theme.colors.grayDark};\n ${({ theme }) => styledText(theme)}\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n border-top: none;\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex-wrap: wrap;\n flex: 1;\n\n &[hidden] {\n display: none;\n }\n\n &:focus-visible {\n outline: none;\n box-shadow: inset 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nconst TabContent: React.FC<TabContentProps> = ({ children }) => {\n return <>{children}</>;\n};\n\nconst Tabs: React.FC<TabsProps> = ({ children }) => {\n const [activeTab, setActiveTab] = useState(0);\n const tabsId = useId();\n const tabRefs = useRef<Array<HTMLButtonElement | null>>([]);\n const tabs = React.Children.toArray(children).filter(\n (child): child is React.ReactElement<TabContentProps> =>\n Boolean(\n React.isValidElement(child) &&\n child.props &&\n typeof child.props === \"object\" &&\n \"title\" in child.props &&\n typeof child.props.title === \"string\" &&\n child.props.title.trim() !== \"\",\n ),\n );\n\n const selectTab = (index: number) => {\n setActiveTab(index);\n tabRefs.current[index]?.focus();\n };\n\n const handleTabKeyDown = (\n event: React.KeyboardEvent<HTMLButtonElement>,\n index: number,\n ) => {\n let nextIndex: number | null = null;\n if (event.key === \"ArrowRight\") {\n nextIndex = index === tabs.length - 1 ? 0 : index + 1;\n } else if (event.key === \"ArrowLeft\") {\n nextIndex = index === 0 ? tabs.length - 1 : index - 1;\n } else if (event.key === \"Home\") {\n nextIndex = 0;\n } else if (event.key === \"End\") {\n nextIndex = tabs.length - 1;\n }\n\n if (nextIndex === null) return;\n event.preventDefault();\n selectTab(nextIndex);\n };\n\n return (\n <TabsContainer>\n <TabsList\n role=\"tablist\"\n aria-label=\"Content tabs\"\n aria-orientation=\"horizontal\"\n >\n {tabs.map((tab, index) => {\n const tabId = tabsId + \"-tab-\" + index;\n const panelId = tabsId + \"-panel-\" + index;\n return (\n <TabButton\n key={tabId}\n ref={(element) => {\n tabRefs.current[index] = element;\n }}\n id={tabId}\n role=\"tab\"\n aria-selected={activeTab === index}\n aria-controls={panelId}\n tabIndex={activeTab === index ? 0 : -1}\n $isActive={activeTab === index}\n onClick={() => setActiveTab(index)}\n onKeyDown={(event) => handleTabKeyDown(event, index)}\n type=\"button\"\n >\n {tab.props.icon && <Icon name={tab.props.icon} size={18} />}\n {tab.props.title}\n </TabButton>\n );\n })}\n </TabsList>\n {tabs.map((tab, index) => (\n <TabPanel\n key={tabsId + \"-panel-\" + index}\n id={tabsId + \"-panel-\" + index}\n role=\"tabpanel\"\n aria-labelledby={tabsId + \"-tab-\" + index}\n tabIndex={activeTab === index ? 0 : -1}\n hidden={activeTab !== index}\n >\n {tab.props.children}\n </TabPanel>\n ))}\n </TabsContainer>\n );\n};\n\nexport { Tabs, TabContent };\n";
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
export const tabsTemplate = `"use client";
|
|
2
2
|
import { Theme } from "@/app/theme";
|
|
3
|
-
import { styledText } from "cherry-styled-components";
|
|
4
|
-
import React, {
|
|
3
|
+
import { Button, resetButton, styledText } from "cherry-styled-components";
|
|
4
|
+
import React, { ReactNode, useId, useRef, useState } from "react";
|
|
5
5
|
import styled, { css } from "styled-components";
|
|
6
6
|
import { thinScrollbar } from "@/components/layout/SharedStyled";
|
|
7
7
|
import { Icon } from "@/components/layout/Icon";
|
|
8
|
+
|
|
8
9
|
interface TabContentProps {
|
|
9
10
|
title: string;
|
|
10
11
|
icon?: string;
|
|
11
12
|
children: ReactNode;
|
|
12
13
|
}
|
|
14
|
+
|
|
13
15
|
interface TabsProps {
|
|
14
16
|
children: React.ReactElement<TabContentProps>[];
|
|
15
17
|
}
|
|
18
|
+
|
|
16
19
|
const TabsContainer = styled.div\`
|
|
17
20
|
width: 100%;
|
|
18
21
|
margin: 0 auto;
|
|
19
22
|
\`;
|
|
23
|
+
|
|
20
24
|
const TabsList = styled.div<{ theme: Theme }>\`
|
|
21
25
|
display: flex;
|
|
22
26
|
overflow: hidden;
|
|
@@ -28,7 +32,10 @@ const TabsList = styled.div<{ theme: Theme }>\`
|
|
|
28
32
|
overflow-x: auto;
|
|
29
33
|
\${thinScrollbar};
|
|
30
34
|
\`;
|
|
31
|
-
|
|
35
|
+
|
|
36
|
+
const TabButton = styled(Button)<{ theme: Theme; $isActive?: boolean }>\`
|
|
37
|
+
\${resetButton};
|
|
38
|
+
appearance: none;
|
|
32
39
|
flex: 1;
|
|
33
40
|
display: flex;
|
|
34
41
|
align-items: center;
|
|
@@ -36,25 +43,30 @@ const TabButton = styled.button<{ theme: Theme; $isActive?: boolean }>\`
|
|
|
36
43
|
gap: 8px;
|
|
37
44
|
padding: 12px 20px;
|
|
38
45
|
border: none;
|
|
46
|
+
border-radius: 0;
|
|
39
47
|
background: \${({ theme }) => theme.colors.light};
|
|
40
48
|
cursor: pointer;
|
|
41
49
|
transition: all 0.2s ease;
|
|
42
50
|
border-bottom: 3px solid transparent;
|
|
43
51
|
min-width: fit-content;
|
|
52
|
+
height: auto;
|
|
53
|
+
min-height: 0;
|
|
44
54
|
\${({ theme }) => styledText(theme)};
|
|
45
55
|
color: \${({ theme }) => theme.colors.dark};
|
|
46
56
|
font-weight: 600;
|
|
57
|
+
position: relative;
|
|
47
58
|
|
|
48
59
|
& svg {
|
|
49
60
|
flex-shrink: 0;
|
|
50
61
|
}
|
|
62
|
+
|
|
51
63
|
\${({ theme, $isActive }) =>
|
|
52
64
|
$isActive &&
|
|
53
65
|
css\`
|
|
54
66
|
color: \${theme.colors.primary};
|
|
55
|
-
border-bottom:
|
|
67
|
+
border-bottom-color: \${theme.colors.primary};
|
|
56
68
|
\`}
|
|
57
|
-
|
|
69
|
+
|
|
58
70
|
&:hover {
|
|
59
71
|
\${({ theme, $isActive }) =>
|
|
60
72
|
!$isActive &&
|
|
@@ -67,13 +79,22 @@ const TabButton = styled.button<{ theme: Theme; $isActive?: boolean }>\`
|
|
|
67
79
|
);
|
|
68
80
|
\`}
|
|
69
81
|
}
|
|
70
|
-
|
|
82
|
+
|
|
83
|
+
&:focus-visible {
|
|
71
84
|
outline: none;
|
|
85
|
+
z-index: 1;
|
|
86
|
+
box-shadow: inset 0 0 0 2px \${({ theme }) => theme.colors.primaryLight};
|
|
72
87
|
}
|
|
88
|
+
|
|
73
89
|
&:not(:last-child) {
|
|
74
90
|
border-right: 1px solid \${({ theme }) => theme.colors.grayLight};
|
|
75
91
|
}
|
|
92
|
+
|
|
93
|
+
@media (prefers-reduced-motion: reduce) {
|
|
94
|
+
transition: none;
|
|
95
|
+
}
|
|
76
96
|
\`;
|
|
97
|
+
|
|
77
98
|
const TabPanel = styled.div<{ theme: Theme }>\`
|
|
78
99
|
background-color: \${({ theme }) => theme.colors.light};
|
|
79
100
|
padding: 20px;
|
|
@@ -88,12 +109,25 @@ const TabPanel = styled.div<{ theme: Theme }>\`
|
|
|
88
109
|
gap: 20px;
|
|
89
110
|
flex-wrap: wrap;
|
|
90
111
|
flex: 1;
|
|
112
|
+
|
|
113
|
+
&[hidden] {
|
|
114
|
+
display: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&:focus-visible {
|
|
118
|
+
outline: none;
|
|
119
|
+
box-shadow: inset 0 0 0 2px \${({ theme }) => theme.colors.primaryLight};
|
|
120
|
+
}
|
|
91
121
|
\`;
|
|
122
|
+
|
|
92
123
|
const TabContent: React.FC<TabContentProps> = ({ children }) => {
|
|
93
124
|
return <>{children}</>;
|
|
94
125
|
};
|
|
126
|
+
|
|
95
127
|
const Tabs: React.FC<TabsProps> = ({ children }) => {
|
|
96
128
|
const [activeTab, setActiveTab] = useState(0);
|
|
129
|
+
const tabsId = useId();
|
|
130
|
+
const tabRefs = useRef<Array<HTMLButtonElement | null>>([]);
|
|
97
131
|
const tabs = React.Children.toArray(children).filter(
|
|
98
132
|
(child): child is React.ReactElement<TabContentProps> =>
|
|
99
133
|
Boolean(
|
|
@@ -105,24 +139,79 @@ const Tabs: React.FC<TabsProps> = ({ children }) => {
|
|
|
105
139
|
child.props.title.trim() !== "",
|
|
106
140
|
),
|
|
107
141
|
);
|
|
142
|
+
|
|
143
|
+
const selectTab = (index: number) => {
|
|
144
|
+
setActiveTab(index);
|
|
145
|
+
tabRefs.current[index]?.focus();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const handleTabKeyDown = (
|
|
149
|
+
event: React.KeyboardEvent<HTMLButtonElement>,
|
|
150
|
+
index: number,
|
|
151
|
+
) => {
|
|
152
|
+
let nextIndex: number | null = null;
|
|
153
|
+
if (event.key === "ArrowRight") {
|
|
154
|
+
nextIndex = index === tabs.length - 1 ? 0 : index + 1;
|
|
155
|
+
} else if (event.key === "ArrowLeft") {
|
|
156
|
+
nextIndex = index === 0 ? tabs.length - 1 : index - 1;
|
|
157
|
+
} else if (event.key === "Home") {
|
|
158
|
+
nextIndex = 0;
|
|
159
|
+
} else if (event.key === "End") {
|
|
160
|
+
nextIndex = tabs.length - 1;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (nextIndex === null) return;
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
selectTab(nextIndex);
|
|
166
|
+
};
|
|
167
|
+
|
|
108
168
|
return (
|
|
109
169
|
<TabsContainer>
|
|
110
|
-
<TabsList
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
170
|
+
<TabsList
|
|
171
|
+
role="tablist"
|
|
172
|
+
aria-label="Content tabs"
|
|
173
|
+
aria-orientation="horizontal"
|
|
174
|
+
>
|
|
175
|
+
{tabs.map((tab, index) => {
|
|
176
|
+
const tabId = tabsId + "-tab-" + index;
|
|
177
|
+
const panelId = tabsId + "-panel-" + index;
|
|
178
|
+
return (
|
|
179
|
+
<TabButton
|
|
180
|
+
key={tabId}
|
|
181
|
+
ref={(element) => {
|
|
182
|
+
tabRefs.current[index] = element;
|
|
183
|
+
}}
|
|
184
|
+
id={tabId}
|
|
185
|
+
role="tab"
|
|
186
|
+
aria-selected={activeTab === index}
|
|
187
|
+
aria-controls={panelId}
|
|
188
|
+
tabIndex={activeTab === index ? 0 : -1}
|
|
189
|
+
$isActive={activeTab === index}
|
|
190
|
+
onClick={() => setActiveTab(index)}
|
|
191
|
+
onKeyDown={(event) => handleTabKeyDown(event, index)}
|
|
192
|
+
type="button"
|
|
193
|
+
>
|
|
194
|
+
{tab.props.icon && <Icon name={tab.props.icon} size={18} />}
|
|
195
|
+
{tab.props.title}
|
|
196
|
+
</TabButton>
|
|
197
|
+
);
|
|
198
|
+
})}
|
|
122
199
|
</TabsList>
|
|
123
|
-
|
|
200
|
+
{tabs.map((tab, index) => (
|
|
201
|
+
<TabPanel
|
|
202
|
+
key={tabsId + "-panel-" + index}
|
|
203
|
+
id={tabsId + "-panel-" + index}
|
|
204
|
+
role="tabpanel"
|
|
205
|
+
aria-labelledby={tabsId + "-tab-" + index}
|
|
206
|
+
tabIndex={activeTab === index ? 0 : -1}
|
|
207
|
+
hidden={activeTab !== index}
|
|
208
|
+
>
|
|
209
|
+
{tab.props.children}
|
|
210
|
+
</TabPanel>
|
|
211
|
+
))}
|
|
124
212
|
</TabsContainer>
|
|
125
213
|
);
|
|
126
214
|
};
|
|
215
|
+
|
|
127
216
|
export { Tabs, TabContent };
|
|
128
217
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const envExampleTemplate = "# Public Site URL\n# Used by sitemap.xml and robots.txt. Overrides `url` in config.json when set.\n# NEXT_PUBLIC_SITE_URL=https://docs.example.com\n\n# Password Protection (optional)\n# Set a shared password to gate the whole site behind a login screen. When set,\n# pages require the password, the content APIs (chat + search) return 401\n# without it, and the site is hidden from search engines and crawlers. Leave\n# unset (or remove) to keep the site public.\n# SITE_PASSWORD=choose-a-strong-shared-password\n\n# LLM Provider Configuration\n# Choose your preferred LLM provider: openai, anthropic, or google\nLLM_PROVIDER=openai\n\n# API Keys (set the one matching your provider)\nOPENAI_API_KEY=your_openai_api_key_here\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nGOOGLE_API_KEY=your_google_api_key_here\n\n# Optional: Override default chat model\n# See available models at your provider's docs:\n# OpenAI: https://platform.openai.com/docs/models\n# Anthropic: https://docs.anthropic.com/claude/docs/models-overview\n# Google: https://ai.google.dev/models/gemini\n# LLM_CHAT_MODEL=\n\n# Optional: Override default embedding model\n# See available embedding models at your provider's docs:\n# OpenAI: https://platform.openai.com/docs/guides/embeddings\n# Google: https://ai.google.dev/gemini-api/docs/embeddings\n# Note: Anthropic doesn't provide embeddings, will fallback to OpenAI\n# LLM_EMBEDDING_MODEL=\n\n# Optional: Set temperature (0-1, default: 0)\n# LLM_TEMPERATURE=0\n\n# Optional: Embedding dimensions for the prebuilt search index (default: 512)\n# Doc vectors are Matryoshka-truncated to this many dimensions and stored as\n# int8, which keeps services/mcp/docs-index.json small (~20x smaller than raw\n# floats) so large doc sets don't stall the AI chat on serverless cold starts.\n# Lower = smaller index, slightly lower recall. Values >= the model's native\n# dimension keep full precision. Rebuild after changing this.\n# LLM_EMBEDDING_DIMS=512\n";
|
|
1
|
+
export declare const envExampleTemplate = "# Public Site URL\n# Used by sitemap.xml and robots.txt. Overrides `url` in config.json when set.\n# NEXT_PUBLIC_SITE_URL=https://docs.example.com\n\n# Password Protection (optional)\n# Set a shared password to gate the whole site behind a login screen. When set,\n# pages require the password, the content APIs (chat + search) return 401\n# without it, and the site is hidden from search engines and crawlers. Leave\n# unset (or remove) to keep the site public.\n# SITE_PASSWORD=choose-a-strong-shared-password\n\n# Paid API Access (recommended for public deployments with AI enabled)\n# Public documentation remains intentionally public by default. Set RAG_API_KEY\n# to require Authorization: Bearer <key> for /api/rag and prevent anonymous LLM\n# spend. The browser chat cannot safely hold this server secret; use\n# SITE_PASSWORD instead when authenticated browser chat is required.\n# RAG_API_KEY=generate-a-long-random-secret\n# Set DOCS_API_KEY to require bearer authentication for /api/mcp. If omitted,\n# MCP follows the site access mode and remains public on an intentionally public\n# documentation site.\n# DOCS_API_KEY=generate-another-long-random-secret\n\n# LLM Provider Configuration\n# Choose your preferred LLM provider: openai, anthropic, or google\nLLM_PROVIDER=openai\n\n# API Keys (set the one matching your provider)\nOPENAI_API_KEY=your_openai_api_key_here\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nGOOGLE_API_KEY=your_google_api_key_here\n\n# Optional: Override default chat model\n# See available models at your provider's docs:\n# OpenAI: https://platform.openai.com/docs/models\n# Anthropic: https://docs.anthropic.com/claude/docs/models-overview\n# Google: https://ai.google.dev/models/gemini\n# LLM_CHAT_MODEL=\n\n# Optional: Override default embedding model\n# See available embedding models at your provider's docs:\n# OpenAI: https://platform.openai.com/docs/guides/embeddings\n# Google: https://ai.google.dev/gemini-api/docs/embeddings\n# Note: Anthropic doesn't provide embeddings, will fallback to OpenAI\n# LLM_EMBEDDING_MODEL=\n\n# Optional: Set temperature (0-1, default: 0)\n# LLM_TEMPERATURE=0\n\n# Optional: Embedding dimensions for the prebuilt search index (default: 512)\n# Doc vectors are Matryoshka-truncated to this many dimensions and stored as\n# int8, which keeps services/mcp/docs-index.json small (~20x smaller than raw\n# floats) so large doc sets don't stall the AI chat on serverless cold starts.\n# Lower = smaller index, slightly lower recall. Values >= the model's native\n# dimension keep full precision. Rebuild after changing this.\n# LLM_EMBEDDING_DIMS=512\n";
|
|
@@ -9,6 +9,17 @@ export const envExampleTemplate = `# Public Site URL
|
|
|
9
9
|
# unset (or remove) to keep the site public.
|
|
10
10
|
# SITE_PASSWORD=choose-a-strong-shared-password
|
|
11
11
|
|
|
12
|
+
# Paid API Access (recommended for public deployments with AI enabled)
|
|
13
|
+
# Public documentation remains intentionally public by default. Set RAG_API_KEY
|
|
14
|
+
# to require Authorization: Bearer <key> for /api/rag and prevent anonymous LLM
|
|
15
|
+
# spend. The browser chat cannot safely hold this server secret; use
|
|
16
|
+
# SITE_PASSWORD instead when authenticated browser chat is required.
|
|
17
|
+
# RAG_API_KEY=generate-a-long-random-secret
|
|
18
|
+
# Set DOCS_API_KEY to require bearer authentication for /api/mcp. If omitted,
|
|
19
|
+
# MCP follows the site access mode and remains public on an intentionally public
|
|
20
|
+
# documentation site.
|
|
21
|
+
# DOCS_API_KEY=generate-another-long-random-secret
|
|
22
|
+
|
|
12
23
|
# LLM Provider Configuration
|
|
13
24
|
# Choose your preferred LLM provider: openai, anthropic, or google
|
|
14
25
|
LLM_PROVIDER=openai
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const eslintConfigTemplate = "import globals from \"globals\";\nimport nextPlugin from \"@next/eslint-plugin-next\";\nimport reactPlugin from \"eslint-plugin-react\";\nimport reactHooksPlugin from \"eslint-plugin-react-hooks\";\nimport jsxA11yPlugin from \"eslint-plugin-jsx-a11y\";\nimport importPlugin from \"eslint-plugin-import\";\nimport tsParser from \"@typescript-eslint/parser\";\nimport tsPlugin from \"@typescript-eslint/eslint-plugin\";\n\n// Hand-rolled replacement for `eslint-config-next`'s default config.\n//\n// We don't use eslint-config-next under ESLint 10: its React version detection\n// (`settings.react.version: \"detect\"`) calls `context.getFilename()`, which\n// ESLint 10 removed, so it crashes on load. Composing the same plugins\n// ourselves lets us pin `react.version` (below) and stay in control.\n//\n// The recommended rule sets below mirror what eslint-config-next enables:\n// React, React Hooks, Next.js and jsx-a11y. On top of that we keep a few\n// project-specific rules (no-console and two @typescript-eslint rules).\n\nconst config = [\n {\n // node_modules/ and .git/ are ignored by default.\n ignores: [\".next/**\", \"out/**\", \"build/**\", \"next-env.d.ts\"],\n },\n {\n name: \"doccupine/base\",\n files: [\"**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}\"],\n plugins: {\n react: reactPlugin,\n \"react-hooks\": reactHooksPlugin,\n import: importPlugin,\n \"jsx-a11y\": jsxA11yPlugin,\n \"@next/next\": nextPlugin,\n \"@typescript-eslint\": tsPlugin,\n },\n languageOptions: {\n parser: tsParser,\n parserOptions: {\n sourceType: \"module\",\n ecmaFeatures: { jsx: true },\n },\n globals: { ...globals.browser, ...globals.node },\n },\n settings: {\n // Pinned (not \"detect\") on purpose: eslint-plugin-react 7.37.x's version\n // detection calls the ESLint-10-removed `context.getFilename()`. Pinning\n // skips that code path. Keep roughly in sync with the installed React.\n react: { version: \"19.2\" },\n },\n rules: {\n ...reactPlugin.configs.recommended.rules,\n ...reactHooksPlugin.configs.recommended.rules,\n ...nextPlugin.configs.recommended.rules,\n \"import/no-anonymous-default-export\": \"warn\",\n \"react/no-unknown-property\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"react/prop-types\": \"off\",\n \"jsx-a11y/alt-text\": [\"warn\", { elements: [\"img\"], img: [\"Image\"] }],\n \"jsx-a11y/aria-props\": \"warn\",\n \"jsx-a11y/aria-proptypes\": \"warn\",\n \"jsx-a11y/aria-unsupported-elements\": \"warn\",\n \"jsx-a11y/role-has-required-aria-props\": \"warn\",\n \"jsx-a11y/role-supports-aria-props\": \"warn\",\n \"react/jsx-no-target-blank\": \"off\",\n \"no-console\": [\"warn\", { allow: [\"warn\", \"error\"] }],\n \"@typescript-eslint/no-explicit-any\": \"warn\",\n \"@typescript-eslint/no-unused-vars\": [\n \"warn\",\n { argsIgnorePattern: \"^_\", varsIgnorePattern: \"^_\" },\n ],\n },\n },\n];\n\nexport default config;\n";
|
|
1
|
+
export declare const eslintConfigTemplate = "import globals from \"globals\";\nimport nextPlugin from \"@next/eslint-plugin-next\";\nimport reactPlugin from \"eslint-plugin-react\";\nimport reactHooksPlugin from \"eslint-plugin-react-hooks\";\nimport jsxA11yPlugin from \"eslint-plugin-jsx-a11y\";\nimport importPlugin from \"eslint-plugin-import\";\nimport tsParser from \"@typescript-eslint/parser\";\nimport tsPlugin from \"@typescript-eslint/eslint-plugin\";\n\n// Hand-rolled replacement for `eslint-config-next`'s default config.\n//\n// We don't use eslint-config-next under ESLint 10: its React version detection\n// (`settings.react.version: \"detect\"`) calls `context.getFilename()`, which\n// ESLint 10 removed, so it crashes on load. Composing the same plugins\n// ourselves lets us pin `react.version` (below) and stay in control.\n//\n// The recommended rule sets below mirror what eslint-config-next enables:\n// React, React Hooks, Next.js and jsx-a11y. On top of that we keep a few\n// project-specific rules (no-console and two @typescript-eslint rules).\n\nconst config = [\n {\n // node_modules/ and .git/ are ignored by default.\n ignores: [\".next/**\", \"out/**\", \"build/**\", \"next-env.d.ts\"],\n },\n {\n name: \"doccupine/base\",\n files: [\"**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}\"],\n plugins: {\n react: reactPlugin,\n \"react-hooks\": reactHooksPlugin,\n import: importPlugin,\n \"jsx-a11y\": jsxA11yPlugin,\n \"@next/next\": nextPlugin,\n \"@typescript-eslint\": tsPlugin,\n },\n languageOptions: {\n parser: tsParser,\n parserOptions: {\n sourceType: \"module\",\n ecmaFeatures: { jsx: true },\n },\n globals: { ...globals.browser, ...globals.node },\n },\n settings: {\n // Pinned (not \"detect\") on purpose: eslint-plugin-react 7.37.x's version\n // detection calls the ESLint-10-removed `context.getFilename()`. Pinning\n // skips that code path. Keep roughly in sync with the installed React.\n react: { version: \"19.2\" },\n },\n rules: {\n ...reactPlugin.configs.recommended.rules,\n ...reactHooksPlugin.configs.recommended.rules,\n ...nextPlugin.configs.recommended.rules,\n ...jsxA11yPlugin.configs.recommended.rules,\n \"import/no-anonymous-default-export\": \"warn\",\n \"react/no-unknown-property\": \"off\",\n \"react/react-in-jsx-scope\": \"off\",\n \"react/prop-types\": \"off\",\n \"jsx-a11y/alt-text\": [\"warn\", { elements: [\"img\"], img: [\"Image\"] }],\n \"jsx-a11y/aria-props\": \"warn\",\n \"jsx-a11y/aria-proptypes\": \"warn\",\n \"jsx-a11y/aria-unsupported-elements\": \"warn\",\n \"jsx-a11y/role-has-required-aria-props\": \"warn\",\n \"jsx-a11y/role-supports-aria-props\": \"warn\",\n \"react/jsx-no-target-blank\": \"off\",\n \"no-console\": [\"warn\", { allow: [\"warn\", \"error\"] }],\n \"@typescript-eslint/no-explicit-any\": \"warn\",\n \"@typescript-eslint/no-unused-vars\": [\n \"warn\",\n { argsIgnorePattern: \"^_\", varsIgnorePattern: \"^_\" },\n ],\n },\n },\n {\n // These generated previews intentionally render user-selected media without\n // author-provided caption tracks. Keep the complete recommended ruleset on\n // everywhere else while this isolated preview remains user-controlled.\n name: \"doccupine/media-preview\",\n files: [\"components/layout/ApiPlayground.tsx\"],\n rules: {\n \"jsx-a11y/media-has-caption\": \"off\",\n },\n },\n {\n // Cherry's Input owns the actual DOM input and focus behavior. Ignore only\n // non-DOM controls; raw JSX inputs remain covered by the recommended rule.\n name: \"doccupine/cherry-controls\",\n files: [\"components/layout/SiteGate.tsx\"],\n rules: {\n \"jsx-a11y/no-autofocus\": [\"error\", { ignoreNonDOM: true }],\n },\n },\n];\n\nexport default config;\n";
|
|
@@ -52,6 +52,7 @@ const config = [
|
|
|
52
52
|
...reactPlugin.configs.recommended.rules,
|
|
53
53
|
...reactHooksPlugin.configs.recommended.rules,
|
|
54
54
|
...nextPlugin.configs.recommended.rules,
|
|
55
|
+
...jsxA11yPlugin.configs.recommended.rules,
|
|
55
56
|
"import/no-anonymous-default-export": "warn",
|
|
56
57
|
"react/no-unknown-property": "off",
|
|
57
58
|
"react/react-in-jsx-scope": "off",
|
|
@@ -71,6 +72,25 @@ const config = [
|
|
|
71
72
|
],
|
|
72
73
|
},
|
|
73
74
|
},
|
|
75
|
+
{
|
|
76
|
+
// These generated previews intentionally render user-selected media without
|
|
77
|
+
// author-provided caption tracks. Keep the complete recommended ruleset on
|
|
78
|
+
// everywhere else while this isolated preview remains user-controlled.
|
|
79
|
+
name: "doccupine/media-preview",
|
|
80
|
+
files: ["components/layout/ApiPlayground.tsx"],
|
|
81
|
+
rules: {
|
|
82
|
+
"jsx-a11y/media-has-caption": "off",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
// Cherry's Input owns the actual DOM input and focus behavior. Ignore only
|
|
87
|
+
// non-DOM controls; raw JSX inputs remain covered by the recommended rule.
|
|
88
|
+
name: "doccupine/cherry-controls",
|
|
89
|
+
files: ["components/layout/SiteGate.tsx"],
|
|
90
|
+
rules: {
|
|
91
|
+
"jsx-a11y/no-autofocus": ["error", { ignoreNonDOM: true }],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
74
94
|
];
|
|
75
95
|
|
|
76
96
|
export default config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const gitignoreTemplate = "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n.yarn/install-state.gz\n\n# testing\n/coverage\n\n# next.js\n/.next/\n/out/\n.next\n\n# production\n/build\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n#
|
|
1
|
+
export declare const gitignoreTemplate = "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n.yarn/install-state.gz\n\n# testing\n/coverage\n\n# next.js\n/.next/\n/out/\n.next\n\n# production\n/build\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# environment files may contain provider and API secrets\n.env*\n!.env.example\n\n# vercel\n.vercel\n\n# typescript\n*.tsbuildinfo\nnext-env.d.ts\n\n.vscode\n.doccupine-*\n\n# generated build artifact (precomputed embeddings)\nservices/mcp/docs-index.json\n";
|
|
@@ -26,8 +26,9 @@ npm-debug.log*
|
|
|
26
26
|
yarn-debug.log*
|
|
27
27
|
yarn-error.log*
|
|
28
28
|
|
|
29
|
-
#
|
|
30
|
-
.env
|
|
29
|
+
# environment files may contain provider and API secrets
|
|
30
|
+
.env*
|
|
31
|
+
!.env.example
|
|
31
32
|
|
|
32
33
|
# vercel
|
|
33
34
|
.vercel
|
|
@@ -36,8 +37,8 @@ yarn-error.log*
|
|
|
36
37
|
*.tsbuildinfo
|
|
37
38
|
next-env.d.ts
|
|
38
39
|
|
|
39
|
-
.env
|
|
40
40
|
.vscode
|
|
41
|
+
.doccupine-*
|
|
41
42
|
|
|
42
43
|
# generated build artifact (precomputed embeddings)
|
|
43
44
|
services/mcp/docs-index.json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const accessControlTemplate = "import { cookies } from \"next/headers\";\nimport {\n GATE_COOKIE_NAME,\n isGateUnlocked,\n timingSafeEqual,\n} from \"@/lib/siteGate\";\n\nfunction bearerToken(req: Request): string | null {\n const authorization = req.headers.get(\"authorization\");\n return authorization?.startsWith(\"Bearer \")\n ? authorization.slice(\"Bearer \".length)\n : null;\n}\n\n/**\n * Route-level authorization for site content. Middleware provides the fast\n * outer gate, while this check ensures direct route invocations are protected\n * too.\n */\nexport async function isSiteRequestAuthorized(): Promise<boolean> {\n const password = process.env.SITE_PASSWORD;\n if (!password) return true;\n\n const cookieStore = await cookies();\n return isGateUnlocked(cookieStore.get(GATE_COOKIE_NAME)?.value, password);\n}\n\n/**\n * MCP clients may authenticate with DOCS_API_KEY. When no API key is configured,\n * a password-protected site requires the normal gate cookie instead of silently\n * exposing its documentation API.\n */\nexport async function isMcpRequestAuthorized(req: Request): Promise<boolean> {\n const apiKey = process.env.DOCS_API_KEY;\n if (apiKey) {\n const token = bearerToken(req);\n return token !== null && timingSafeEqual(token, apiKey);\n }\n return isSiteRequestAuthorized();\n}\n";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const accessControlTemplate = `import { cookies } from "next/headers";
|
|
2
|
+
import {
|
|
3
|
+
GATE_COOKIE_NAME,
|
|
4
|
+
isGateUnlocked,
|
|
5
|
+
timingSafeEqual,
|
|
6
|
+
} from "@/lib/siteGate";
|
|
7
|
+
|
|
8
|
+
function bearerToken(req: Request): string | null {
|
|
9
|
+
const authorization = req.headers.get("authorization");
|
|
10
|
+
return authorization?.startsWith("Bearer ")
|
|
11
|
+
? authorization.slice("Bearer ".length)
|
|
12
|
+
: null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Route-level authorization for site content. Middleware provides the fast
|
|
17
|
+
* outer gate, while this check ensures direct route invocations are protected
|
|
18
|
+
* too.
|
|
19
|
+
*/
|
|
20
|
+
export async function isSiteRequestAuthorized(): Promise<boolean> {
|
|
21
|
+
const password = process.env.SITE_PASSWORD;
|
|
22
|
+
if (!password) return true;
|
|
23
|
+
|
|
24
|
+
const cookieStore = await cookies();
|
|
25
|
+
return isGateUnlocked(cookieStore.get(GATE_COOKIE_NAME)?.value, password);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* MCP clients may authenticate with DOCS_API_KEY. When no API key is configured,
|
|
30
|
+
* a password-protected site requires the normal gate cookie instead of silently
|
|
31
|
+
* exposing its documentation API.
|
|
32
|
+
*/
|
|
33
|
+
export async function isMcpRequestAuthorized(req: Request): Promise<boolean> {
|
|
34
|
+
const apiKey = process.env.DOCS_API_KEY;
|
|
35
|
+
if (apiKey) {
|
|
36
|
+
const token = bearerToken(req);
|
|
37
|
+
return token !== null && timingSafeEqual(token, apiKey);
|
|
38
|
+
}
|
|
39
|
+
return isSiteRequestAuthorized();
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const aiAssistantMdxTemplate = "---\ntitle: \"AI Assistant\"\ndescription: \"Integrate AI capabilities into your Doccupine documentation using OpenAI, Anthropic, or Google Gemini.\"\ndate: \"2026-02-19\"\ncategory: \"AI & Integrations\"\ncategoryOrder: 3\ncategoryIcon: \"sparkles\"\norder: 1\n---\n# AI Assistant\n\nDoccupine supports AI integration to enhance your documentation experience. You can use OpenAI, Anthropic, or Google Gemini to power AI features in your documentation site. The AI assistant uses your documentation content as context, allowing users to ask questions about your docs and receive accurate answers based on the documentation.\n\n## Opening the Assistant\n\nOnce a provider is configured, an assistant button appears in the header. You can open and close the assistant from anywhere on the site by pressing <kbd>Command</kbd> + <kbd>I</kbd> (<kbd>Ctrl</kbd> + <kbd>I</kbd> on Windows). Press the same shortcut again to dismiss it.\n\n<Callout type=\"note\">\n The keyboard shortcut is only active once you have configured an LLM provider, as described below.\n</Callout>\n\n## Setup\n\nTo enable AI features, create an `.env` file in the directory where your website is generated. By default, this is the `nextjs-app/` directory.\n\n## Configuration\n\nCreate an `.env` file with the following configuration options:\n\n```env\n# LLM Provider Configuration\n# Choose your preferred LLM provider: openai, anthropic, or google\nLLM_PROVIDER=openai\n\n# API Keys (set the one matching your provider)\nOPENAI_API_KEY=your_openai_api_key_here\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nGOOGLE_API_KEY=your_google_api_key_here\n\n# Optional: Override default chat model (see your provider's docs for available models)\n# LLM_CHAT_MODEL=your-model-id\n\n# Optional: Override default embedding model (see your provider's docs for available models)\n# Note: Anthropic doesn't provide embeddings, will fallback to OpenAI\n# LLM_EMBEDDING_MODEL=your-embedding-model-id\n\n# Optional: Set temperature (0-1, default: 0)\n# LLM_TEMPERATURE=0\n\n# Optional: Embedding dimensions for the prebuilt search index (default: 512)\n# Doc vectors are truncated to this many dimensions and stored as int8 to keep\n# the search index small. Lower = smaller index, slightly lower recall.\n# Rebuild after changing this.\n# LLM_EMBEDDING_DIMS=512\n```\n\n## Provider Selection\n\nSet `LLM_PROVIDER` to one of the following values:\n\n- `openai` - Use OpenAI's models\n- `anthropic` - Use Anthropic's models\n- `google` - Use Google's models\n\n## API Keys\n\nYou need to set the API key that matches your chosen provider:\n\n- For OpenAI: Set `OPENAI_API_KEY`\n- For Anthropic: Set `ANTHROPIC_API_KEY`\n- For Google: Set `GOOGLE_API_KEY`\n\n<Callout type=\"warning\">\n Keep your API keys secure. Never commit your `.env` file to version control.\n</Callout>\n\n<Callout type=\"note\">\n Doccupine
|
|
1
|
+
export declare const aiAssistantMdxTemplate = "---\ntitle: \"AI Assistant\"\ndescription: \"Integrate AI capabilities into your Doccupine documentation using OpenAI, Anthropic, or Google Gemini.\"\ndate: \"2026-02-19\"\ncategory: \"AI & Integrations\"\ncategoryOrder: 3\ncategoryIcon: \"sparkles\"\norder: 1\n---\n# AI Assistant\n\nDoccupine supports AI integration to enhance your documentation experience. You can use OpenAI, Anthropic, or Google Gemini to power AI features in your documentation site. The AI assistant uses your documentation content as context, allowing users to ask questions about your docs and receive accurate answers based on the documentation.\n\n## Opening the Assistant\n\nOnce a provider is configured, an assistant button appears in the header. You can open and close the assistant from anywhere on the site by pressing <kbd>Command</kbd> + <kbd>I</kbd> (<kbd>Ctrl</kbd> + <kbd>I</kbd> on Windows). Press the same shortcut again to dismiss it.\n\n<Callout type=\"note\">\n The keyboard shortcut is only active once you have configured an LLM provider, as described below.\n</Callout>\n\n## Setup\n\nTo enable AI features, create an `.env` file in the directory where your website is generated. By default, this is the `nextjs-app/` directory.\n\n## Configuration\n\nCreate an `.env` file with the following configuration options:\n\n```env\n# LLM Provider Configuration\n# Choose your preferred LLM provider: openai, anthropic, or google\nLLM_PROVIDER=openai\n\n# API Keys (set the one matching your provider)\nOPENAI_API_KEY=your_openai_api_key_here\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nGOOGLE_API_KEY=your_google_api_key_here\n\n# Optional: Require a bearer token for direct /api/rag requests on a public site\n# RAG_API_KEY=generate-a-long-random-secret\n\n# Optional: Override default chat model (see your provider's docs for available models)\n# LLM_CHAT_MODEL=your-model-id\n\n# Optional: Override default embedding model (see your provider's docs for available models)\n# Note: Anthropic doesn't provide embeddings, will fallback to OpenAI\n# LLM_EMBEDDING_MODEL=your-embedding-model-id\n\n# Optional: Set temperature (0-1, default: 0)\n# LLM_TEMPERATURE=0\n\n# Optional: Embedding dimensions for the prebuilt search index (default: 512)\n# Doc vectors are truncated to this many dimensions and stored as int8 to keep\n# the search index small. Lower = smaller index, slightly lower recall.\n# Rebuild after changing this.\n# LLM_EMBEDDING_DIMS=512\n```\n\n## Provider Selection\n\nSet `LLM_PROVIDER` to one of the following values:\n\n- `openai` - Use OpenAI's models\n- `anthropic` - Use Anthropic's models\n- `google` - Use Google's models\n\n## API Keys\n\nYou need to set the API key that matches your chosen provider:\n\n- For OpenAI: Set `OPENAI_API_KEY`\n- For Anthropic: Set `ANTHROPIC_API_KEY`\n- For Google: Set `GOOGLE_API_KEY`\n\n<Callout type=\"warning\">\n Keep your API keys secure. Never commit your `.env` file to version control.\n</Callout>\n\n<Callout type=\"note\">\n Doccupine ignores every `.env*` variant except the non-secret\n `.env.example`, helping prevent development, test, and production credentials\n from being committed accidentally.\n</Callout>\n\n## Protecting model spend\n\nPublic documentation intentionally leaves the browser assistant available by default. For a public deployment where only server-to-server clients should call the paid RAG endpoint, set `RAG_API_KEY` and require `Authorization: Bearer <key>` on `/api/rag`.\n\n<Callout type=\"warning\">\n The built-in browser assistant cannot safely store a server API key. Setting\n `RAG_API_KEY` on an otherwise public site disables anonymous browser chat. Use\n `SITE_PASSWORD` instead when signed-in browser visitors should keep using the\n assistant, or leave `RAG_API_KEY` unset when public chat is intentional.\n</Callout>\n\n## Using Anthropic with OpenAI\n\nIf you want to use Anthropic as your LLM provider, you must also have an OpenAI API key set. Here's why:\n\n### The Situation\n\nAnthropic (Claude) does not provide an embeddings API. They only offer chat/completion models, not text embeddings.\n\nYour RAG (Retrieval-Augmented Generation) system has two components:\n\n- **Chat/Completion** - Generates answers, works with Anthropic.\n- **Embeddings** - Creates vector representations of text for search, Anthropic doesn't provide this.\n\nWhen using Anthropic as your `LLM_PROVIDER`, Doccupine will use Anthropic for chat/completion tasks, but will automatically fallback to OpenAI for embeddings. This means you need both API keys configured:\n\n```env\nLLM_PROVIDER=anthropic\nANTHROPIC_API_KEY=your_anthropic_api_key_here\nOPENAI_API_KEY=your_openai_api_key_here\n```\n\nThis hybrid approach allows you to leverage Anthropic's powerful chat models while still having access to embeddings functionality through OpenAI.\n\n## Default models\n\n| Provider | Chat model | Embedding model |\n| --------- | ---------------------------- | ------------------------ |\n| OpenAI | `gpt-4.1-nano` | `text-embedding-3-small` |\n| Anthropic | `claude-sonnet-4-5-20250929` | OpenAI fallback |\n| Google | `gemini-2.5-flash-lite` | `gemini-embedding-001` |\n\n## Optional Settings\n\n### Chat Model\n\nOverride the default chat model by uncommenting and setting `LLM_CHAT_MODEL`. You can use any available model from your chosen provider. For a complete list of available models, refer to the official documentation:\n\n- [OpenAI Models](https://platform.openai.com/docs/models)\n- [Anthropic Models](https://docs.anthropic.com/claude/docs/models-overview)\n- [Google Gemini Models](https://ai.google.dev/models/gemini)\n\n### Embedding Model\n\nOverride the default embedding model by uncommenting and setting `LLM_EMBEDDING_MODEL`. For a complete list of available embedding models, refer to the official documentation:\n\n- [OpenAI Embeddings](https://platform.openai.com/docs/guides/embeddings)\n- [Google Gemini Embeddings](https://ai.google.dev/gemini-api/docs/embeddings)\n- **Anthropic**: Anthropic doesn't provide embeddings. If you use Anthropic as your provider, Doccupine will fallback to OpenAI for embeddings.\n\n### Temperature\n\nControl the randomness of AI responses by setting `LLM_TEMPERATURE` to a value between 0 and 1:\n\n- `0` - More deterministic and focused responses (default)\n- `1` - More creative and varied responses\n\n### Embedding Dimensions\n\nControl the size of the prebuilt search index by setting `LLM_EMBEDDING_DIMS` (default: 512). Doc vectors are truncated to this many dimensions and stored as int8, keeping `services/mcp/docs-index.json` small so large doc sets don't stall the AI chat on serverless cold starts.\n\n- Lower values produce a smaller index with slightly lower search recall.\n- Values greater than or equal to the model's native dimension keep full precision.\n\nThis value must match between build time and runtime. A mismatch forces Doccupine to re-embed your docs at runtime, so rebuild or redeploy your site after changing it.";
|
|
@@ -37,6 +37,9 @@ OPENAI_API_KEY=your_openai_api_key_here
|
|
|
37
37
|
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
|
38
38
|
GOOGLE_API_KEY=your_google_api_key_here
|
|
39
39
|
|
|
40
|
+
# Optional: Require a bearer token for direct /api/rag requests on a public site
|
|
41
|
+
# RAG_API_KEY=generate-a-long-random-secret
|
|
42
|
+
|
|
40
43
|
# Optional: Override default chat model (see your provider's docs for available models)
|
|
41
44
|
# LLM_CHAT_MODEL=your-model-id
|
|
42
45
|
|
|
@@ -75,7 +78,20 @@ You need to set the API key that matches your chosen provider:
|
|
|
75
78
|
</Callout>
|
|
76
79
|
|
|
77
80
|
<Callout type="note">
|
|
78
|
-
Doccupine
|
|
81
|
+
Doccupine ignores every \`.env*\` variant except the non-secret
|
|
82
|
+
\`.env.example\`, helping prevent development, test, and production credentials
|
|
83
|
+
from being committed accidentally.
|
|
84
|
+
</Callout>
|
|
85
|
+
|
|
86
|
+
## Protecting model spend
|
|
87
|
+
|
|
88
|
+
Public documentation intentionally leaves the browser assistant available by default. For a public deployment where only server-to-server clients should call the paid RAG endpoint, set \`RAG_API_KEY\` and require \`Authorization: Bearer <key>\` on \`/api/rag\`.
|
|
89
|
+
|
|
90
|
+
<Callout type="warning">
|
|
91
|
+
The built-in browser assistant cannot safely store a server API key. Setting
|
|
92
|
+
\`RAG_API_KEY\` on an otherwise public site disables anonymous browser chat. Use
|
|
93
|
+
\`SITE_PASSWORD\` instead when signed-in browser visitors should keep using the
|
|
94
|
+
assistant, or leave \`RAG_API_KEY\` unset when public chat is intentional.
|
|
79
95
|
</Callout>
|
|
80
96
|
|
|
81
97
|
## Using Anthropic with OpenAI
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const apiPlaygroundMdxTemplate = "---\ntitle: \"API Playground\"\ndescription: \"Turn an OpenAPI document into an interactive API reference where readers send real requests and see live responses, right inside your docs.\"\ndate: \"2026-07-25\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 20\n---\n# API Playground\n\nPoint Doccupine at an OpenAPI document and it generates a complete, interactive API reference: one page per endpoint, grouped by tag in the sidebar, each with a \"Send request\" panel that makes real calls and shows the live response - plus copy-pasteable code snippets.\n\n<Callout type=\"note\">\nThe playground is driven entirely by your OpenAPI document. There is nothing to wire up by hand - add one line of config and every endpoint becomes a documented, runnable page.\n</Callout>\n\n## Try it\n\nPress **Try it** below to open the playground, tweak the request body, and send a real request to a live API - right from these docs.\n\n<ApiPlaygroundDemo />\n\n## Enabling the playground\n\n<Steps>\n <Step title=\"Add an openapi path to doccupine.json.\">\n Point at a local `.json`, `.yaml`, or `.yml` OpenAPI 3.0 or 3.1 document.\n\n```json\n{\n \"watchDir\": \"docs\",\n \"outputDir\": \"nextjs-app\",\n \"openapi\": \"openapi.yaml\"\n}\n```\n </Step>\n <Step title=\"Run Doccupine.\">\n On the next build (or live, while watching) Doccupine parses the document
|
|
1
|
+
export declare const apiPlaygroundMdxTemplate = "---\ntitle: \"API Playground\"\ndescription: \"Turn an OpenAPI document into an interactive API reference where readers send real requests and see live responses, right inside your docs.\"\ndate: \"2026-07-25\"\ncategory: \"Components\"\ncategoryOrder: 1\norder: 20\n---\n# API Playground\n\nPoint Doccupine at an OpenAPI document and it generates a complete, interactive API reference: one page per endpoint, grouped by tag in the sidebar, each with a \"Send request\" panel that makes real calls and shows the live response - plus copy-pasteable code snippets.\n\n<Callout type=\"note\">\nThe playground is driven entirely by your OpenAPI document. There is nothing to wire up by hand - add one line of config and every endpoint becomes a documented, runnable page.\n</Callout>\n\n## Try it\n\nPress **Try it** below to open the playground, tweak the request body, and send a real request to a live API - right from these docs.\n\n<ApiPlaygroundDemo />\n\n## Enabling the playground\n\n<Steps>\n <Step title=\"Add an openapi path to doccupine.json.\">\n Point at a local `.json`, `.yaml`, or `.yml` OpenAPI 3.0 or 3.1 document.\n\n```json\n{\n \"watchDir\": \"docs\",\n \"outputDir\": \"nextjs-app\",\n \"openapi\": \"openapi.yaml\"\n}\n```\n </Step>\n <Step title=\"Run Doccupine.\">\n On the next build (or live, while watching) Doccupine parses the document and writes an endpoint page for each operation. Local `$ref` files must stay inside the configured spec's directory, use `.json`, `.yaml`, or `.yml`, and cannot be dotfiles or live inside dot-directories.\n </Step>\n <Step title=\"Open the API Reference section.\">\n Endpoints appear in the sidebar grouped by their OpenAPI tag. Editing the spec regenerates the pages automatically.\n </Step>\n</Steps>\n\n## Example spec\n\nDo not have a document yet? This `openapi.yaml` points at [JSONPlaceholder](https://jsonplaceholder.typicode.com), a free public test API, so it works end to end - save it, set `openapi` to it, and the generated pages can send real requests:\n\n```yaml\nopenapi: 3.1.0\ninfo:\n title: JSONPlaceholder\n version: 1.0.0\nservers:\n - url: https://jsonplaceholder.typicode.com\ntags:\n - name: Todos\n - name: Posts\npaths:\n /todos/{id}:\n get:\n summary: Get a to-do\n tags: [Todos]\n parameters:\n - name: id\n in: path\n required: true\n schema:\n type: integer\n responses:\n \"200\":\n description: Just a demo of a to-do item\n /posts:\n post:\n summary: Create a post\n tags: [Posts]\n requestBody:\n required: true\n content:\n application/json:\n example:\n title: Hello\n body: Sent from the docs\n userId: 1\n responses:\n \"201\":\n description: Just a demo of the created post\n```\n\nEach part maps to something in the playground: `servers` sets the request target - and the only host the proxy will call - `tags` group endpoints in the sidebar, and `parameters` and `requestBody` become the inputs (adding a `securitySchemes` entry would produce authentication fields). Doccupine reads OpenAPI 3.0 and 3.1; see the [OpenAPI specification](https://spec.openapis.org) for the full format.\n\n## What gets generated\n\nThe generated `/api-reference` index lists every operation with a direct link, grouped by API and tag. Each operation also gets its own page under `/api-reference/{tag}/{operation}`, showing:\n\n<Field value=\"Parameters\" type=\"path, query, header, cookie\">\nEach parameter is rendered with its name, type, and whether it is required, grouped into a collapsible section with an input to fill in.\n</Field>\n\n<Field value=\"Request body\" type=\"editable\">\nA JSON editor prefilled from the schema's example, ready to tweak and send.\n</Field>\n\n<Field value=\"Authentication\" type=\"from securitySchemes\">\nInputs for the endpoint's security schemes - API keys, bearer tokens, or basic auth - generated from the document.\n</Field>\n\n<Field value=\"Response\" type=\"live\">\nThe real status, timing, and body from your API, rendered to match its content type.\n</Field>\n\n## Embedding a single endpoint\n\nTo mix prose and a live endpoint on a hand-written page, reference an operation from the page's frontmatter with `openapi`. Use `METHOD /path` or an `operationId`:\n\n```mdx\n---\ntitle: \"Create a post\"\nopenapi: \"POST /posts\"\n---\n\nPosts are created for a user. The playground above is fully live - fill in the\nbody and send a real request.\n```\n\nDoccupine renders that endpoint's playground above your prose. If the reference does not match any operation in your document, the page still renders its prose and a warning is logged.\n\n## Running requests\n\nRequests run one of two ways, and readers can switch between them:\n\n<Callout type=\"note\">\n**Proxy (default).** The request is forwarded server-side, so it works even when the target API blocks cross-origin browser calls. **Direct.** The browser calls the API itself - useful when the API allows CORS and you want requests to never leave the reader's machine.\n</Callout>\n\nThe proxy is deliberately locked down. It only forwards to servers declared in your OpenAPI document and refuses private, internal, metadata, and reserved network addresses, including IPv4 destinations represented through IPv6 translation ranges. An explicitly declared loopback server such as `http://localhost:4000` is available only outside production for local development and tests; production always blocks loopback and every other private target even when the spec declares one. Request URLs, headers, and bodies are never logged, so API keys a reader enters are not written anywhere. On a [password-protected site](/authentication), the proxy also requires the visitor's unlocked session, so it cannot be called anonymously.\n\nProxy requests are rate limited per trusted client address on recognized hosting platforms. Unknown and self-hosted proxy setups share one fallback bucket rather than trusting spoofable forwarding headers; use your trusted edge or a shared rate-limit store when those deployments need accurate per-client limits.\n\n<Callout type=\"warning\">\nKeys and tokens a reader types are used only to make the request. Turn on \"Show secrets\" to reveal them in the generated code snippets; they are redacted by default.\n</Callout>\n\n## Responses and snippets\n\nResponses render to match their type: images and video play inline, everything else is shown as a formatted, syntax-highlighted body. Alongside the response, the playground generates ready-to-run **cURL**, **JavaScript**, and **Python** snippets for the exact request you built.\n\n## Documenting more than one API\n\nPass an array to document several APIs at once. Each spec becomes its own namespaced section:\n\n```json\n{\n \"openapi\": [\n { \"name\": \"public\", \"file\": \"specs/public.yaml\" },\n { \"name\": \"admin\", \"file\": \"specs/admin.yaml\" }\n ]\n}\n```\n";
|
|
@@ -35,7 +35,7 @@ Press **Try it** below to open the playground, tweak the request body, and send
|
|
|
35
35
|
\`\`\`
|
|
36
36
|
</Step>
|
|
37
37
|
<Step title="Run Doccupine.">
|
|
38
|
-
On the next build (or live, while watching) Doccupine parses the document
|
|
38
|
+
On the next build (or live, while watching) Doccupine parses the document and writes an endpoint page for each operation. Local \`$ref\` files must stay inside the configured spec's directory, use \`.json\`, \`.yaml\`, or \`.yml\`, and cannot be dotfiles or live inside dot-directories.
|
|
39
39
|
</Step>
|
|
40
40
|
<Step title="Open the API Reference section.">
|
|
41
41
|
Endpoints appear in the sidebar grouped by their OpenAPI tag. Editing the spec regenerates the pages automatically.
|
|
@@ -91,7 +91,7 @@ Each part maps to something in the playground: \`servers\` sets the request targ
|
|
|
91
91
|
|
|
92
92
|
## What gets generated
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
The generated \`/api-reference\` index lists every operation with a direct link, grouped by API and tag. Each operation also gets its own page under \`/api-reference/{tag}/{operation}\`, showing:
|
|
95
95
|
|
|
96
96
|
<Field value="Parameters" type="path, query, header, cookie">
|
|
97
97
|
Each parameter is rendered with its name, type, and whether it is required, grouped into a collapsible section with an input to fill in.
|
|
@@ -133,7 +133,9 @@ Requests run one of two ways, and readers can switch between them:
|
|
|
133
133
|
**Proxy (default).** The request is forwarded server-side, so it works even when the target API blocks cross-origin browser calls. **Direct.** The browser calls the API itself - useful when the API allows CORS and you want requests to never leave the reader's machine.
|
|
134
134
|
</Callout>
|
|
135
135
|
|
|
136
|
-
The proxy is deliberately locked down. It only forwards to
|
|
136
|
+
The proxy is deliberately locked down. It only forwards to servers declared in your OpenAPI document and refuses private, internal, metadata, and reserved network addresses, including IPv4 destinations represented through IPv6 translation ranges. An explicitly declared loopback server such as \`http://localhost:4000\` is available only outside production for local development and tests; production always blocks loopback and every other private target even when the spec declares one. Request URLs, headers, and bodies are never logged, so API keys a reader enters are not written anywhere. On a [password-protected site](/authentication), the proxy also requires the visitor's unlocked session, so it cannot be called anonymously.
|
|
137
|
+
|
|
138
|
+
Proxy requests are rate limited per trusted client address on recognized hosting platforms. Unknown and self-hosted proxy setups share one fallback bucket rather than trusting spoofable forwarding headers; use your trusted edge or a shared rate-limit store when those deployments need accurate per-client limits.
|
|
137
139
|
|
|
138
140
|
<Callout type="warning">
|
|
139
141
|
Keys and tokens a reader types are used only to make the request. Turn on "Show secrets" to reveal them in the generated code snippets; they are redacted by default.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const authenticationMdxTemplate = "---\ntitle: \"Authentication\"\ndescription: \"Password protect your documentation site with a single environment variable that gates pages, content APIs, and search crawlers behind a shared password.\"\ndate: \"2026-07-01\"\ncategory: \"Deployment\"\ncategoryOrder: 4\norder: 2\n---\n# Authentication\n\nKeep your documentation private by putting the whole site behind a shared password. Set one environment variable and Doccupine gates every page behind a login screen, blocks the content APIs, and hides the site from search engines - no accounts, no database, no extra services.\n\n## Enabling password protection\n\nSet `SITE_PASSWORD` in your environment (for local development, add it to `.env`):\n\n```bash\nSITE_PASSWORD=choose-a-strong-shared-password\n```\n\nThat is the only setting. Everyone who visits the site shares this single password.\n\n<Callout type=\"note\">\n When `SITE_PASSWORD` is unset or empty, the site is fully public and behaves exactly as before. Removing the variable turns protection off again.\n</Callout>\n\n## What gets protected\n\nWhile a password is set, protection is enforced across three layers:\n\n- **Pages**: Every page renders a login screen instead of your documentation until the visitor enters the correct password.\n- **Content APIs**: The AI chat (`/api/rag`)
|
|
1
|
+
export declare const authenticationMdxTemplate = "---\ntitle: \"Authentication\"\ndescription: \"Password protect your documentation site with a single environment variable that gates pages, content APIs, and search crawlers behind a shared password.\"\ndate: \"2026-07-01\"\ncategory: \"Deployment\"\ncategoryOrder: 4\norder: 2\n---\n# Authentication\n\nKeep your documentation private by putting the whole site behind a shared password. Set one environment variable and Doccupine gates every page behind a login screen, blocks the content APIs, and hides the site from search engines - no accounts, no database, no extra services.\n\n## Enabling password protection\n\nSet `SITE_PASSWORD` in your environment (for local development, add it to `.env`):\n\n```bash\nSITE_PASSWORD=choose-a-strong-shared-password\n```\n\nThat is the only setting. Everyone who visits the site shares this single password.\n\n<Callout type=\"note\">\n When `SITE_PASSWORD` is unset or empty, the site is fully public and behaves exactly as before. Removing the variable turns protection off again.\n</Callout>\n\n## What gets protected\n\nWhile a password is set, protection is enforced across three layers:\n\n- **Pages**: Every page renders a login screen instead of your documentation until the visitor enters the correct password.\n- **Content APIs**: The AI chat (`/api/rag`), search (`/api/search`), and [API playground](/api-playground) proxy (`/api/playground`) endpoints return `401 Unauthorized` without a valid session. The docs cannot be scraped around the login screen, and the proxy cannot be used to relay requests on behalf of an anonymous visitor. Each route re-checks the session itself, so a direct invocation is refused even when it does not pass through the middleware.\n- **Search engines and crawlers**: `robots.txt` disallows all crawlers, every page ships a `noindex, nofollow` meta tag, and responses carry an `X-Robots-Tag: noindex, nofollow` header.\n\n<Callout type=\"note\">\n The [MCP server](/model-context-protocol) uses `DOCS_API_KEY` bearer authentication when that variable is set. Otherwise, a password-protected site requires the normal gate session for MCP too, so the endpoint cannot bypass `SITE_PASSWORD`.\n</Callout>\n\nThe AI endpoint also supports `RAG_API_KEY` for authenticated server-to-server access on public sites. Because the browser cannot safely hold that secret, use `SITE_PASSWORD` rather than `RAG_API_KEY` when authenticated browser visitors should use the built-in assistant.\n\n## How it works\n\nWhen a visitor submits the correct password, Doccupine sets a signed, `httpOnly` cookie that unlocks the site for 30 days. The cookie never stores the password itself - it holds an HMAC derived from it - and it is checked in constant time to avoid leaking information through timing.\n\nBecause the check reads `SITE_PASSWORD` at request time, you can turn protection on or off by changing the environment variable and redeploying. No rebuild of your content is required.\n\n## Security notes\n\n- **Use a strong password.** It is shared by everyone with access, so treat it like any other shared secret and rotate it when needed.\n- **Serve over HTTPS in production.** The session cookie is marked `secure` in production, so it is only sent over encrypted connections.\n- **Brute-force protection.** On recognized hosting platforms, password attempts are rate limited by the platform's trusted client address. Unknown and self-hosted proxy setups use one shared fallback bucket rather than trusting a spoofable forwarding header; configure a trusted edge limiter for accurate per-client limits there.\n- **Rotating the password.** Changing `SITE_PASSWORD` invalidates every existing session immediately - visitors will need to enter the new password.\n\n<Callout type=\"warning\">\n A shared password is meant for lightweight gating - private previews, internal docs, or work-in-progress sites. For per-user access control or audit trails, put the site behind your own identity provider or a hosting platform's access controls.\n</Callout>\n\n## Behavior\n\n- **Runtime toggle**: Protection is controlled entirely by the `SITE_PASSWORD` environment variable, evaluated on each request.\n- **Graceful default**: With no password set, nothing changes - the site stays public and fully indexable.\n- **Session length**: A successful login lasts 30 days before the visitor is asked to sign in again.\n\n## Example\n\nProtect a staging deployment while it is being reviewed:\n\n```bash\nSITE_PASSWORD=preview-2026\nNEXT_PUBLIC_SITE_URL=https://staging.example.com\n```\n\nWhen you are ready to launch publicly, remove `SITE_PASSWORD` and redeploy. The login screen disappears, crawlers are welcomed back, and your [sitemap](/deployment-and-hosting) is advertised again.";
|