doccupine 0.0.157 → 0.0.159

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.
Files changed (153) hide show
  1. package/README.md +52 -2
  2. package/dist/generator/app-scaffolder.js +11 -3
  3. package/dist/generator/generated-page-publisher.d.ts +6 -6
  4. package/dist/generator/generated-page-publisher.js +7 -5
  5. package/dist/generator/icon-registry-generator.d.ts +8 -5
  6. package/dist/generator/icon-registry-generator.js +19 -11
  7. package/dist/generator/mdx-pass-builder.d.ts +4 -4
  8. package/dist/generator/mdx-pass-builder.js +8 -1
  9. package/dist/generator/mdx-reconciliation-coordinator.d.ts +23 -9
  10. package/dist/generator/mdx-reconciliation-coordinator.js +63 -9
  11. package/dist/generator/page-catalog.d.ts +2 -4
  12. package/dist/generator/page-catalog.js +7 -2
  13. package/dist/generator/page-renderer.d.ts +15 -5
  14. package/dist/generator/page-renderer.js +38 -11
  15. package/dist/generator/project-config-repository.d.ts +4 -1
  16. package/dist/generator/project-config-repository.js +26 -0
  17. package/dist/generator/public-asset-manager.d.ts +10 -0
  18. package/dist/generator/public-asset-manager.js +63 -3
  19. package/dist/generator/section-index-generator.d.ts +10 -1
  20. package/dist/generator/section-index-generator.js +43 -15
  21. package/dist/generator/section-resolver.d.ts +8 -0
  22. package/dist/generator/site-artifacts.d.ts +4 -3
  23. package/dist/generator/site-artifacts.js +94 -9
  24. package/dist/generator/watch-coordinator.js +6 -1
  25. package/dist/lib/generated-artifacts.d.ts +3 -0
  26. package/dist/lib/generated-artifacts.js +36 -0
  27. package/dist/lib/icon-registry.d.ts +10 -4
  28. package/dist/lib/icon-registry.js +13 -4
  29. package/dist/lib/layout.d.ts +6 -3
  30. package/dist/lib/layout.js +107 -4
  31. package/dist/lib/metadata.d.ts +7 -0
  32. package/dist/lib/metadata.js +33 -10
  33. package/dist/lib/structures.js +20 -0
  34. package/dist/lib/types.d.ts +28 -0
  35. package/dist/lib/ui-strings.d.ts +44 -0
  36. package/dist/lib/ui-strings.js +48 -0
  37. package/dist/lib/variants.d.ts +91 -0
  38. package/dist/lib/variants.js +411 -0
  39. package/dist/mdx-to-nextjs-generator.d.ts +22 -5
  40. package/dist/mdx-to-nextjs-generator.js +92 -12
  41. package/dist/templates/app/api/mcp/route.d.ts +1 -1
  42. package/dist/templates/app/api/mcp/route.js +14 -1
  43. package/dist/templates/app/api/rag/route.d.ts +1 -1
  44. package/dist/templates/app/api/rag/route.js +13 -2
  45. package/dist/templates/app/api/search/route.d.ts +1 -1
  46. package/dist/templates/app/api/search/route.js +16 -1
  47. package/dist/templates/app/sitemap.d.ts +2 -0
  48. package/dist/templates/app/sitemap.js +48 -3
  49. package/dist/templates/components/Chat.d.ts +1 -1
  50. package/dist/templates/components/Chat.js +40 -12
  51. package/dist/templates/components/Docs.d.ts +1 -1
  52. package/dist/templates/components/Docs.js +5 -2
  53. package/dist/templates/components/DocsSideBar.d.ts +1 -1
  54. package/dist/templates/components/DocsSideBar.js +3 -1
  55. package/dist/templates/components/SearchDocs.d.ts +1 -1
  56. package/dist/templates/components/SearchDocs.js +17 -3
  57. package/dist/templates/components/SearchModalContent.d.ts +1 -1
  58. package/dist/templates/components/SearchModalContent.js +22 -14
  59. package/dist/templates/components/SectionNavProvider.d.ts +1 -1
  60. package/dist/templates/components/SectionNavProvider.js +32 -20
  61. package/dist/templates/components/SideBar.d.ts +1 -1
  62. package/dist/templates/components/SideBar.js +26 -12
  63. package/dist/templates/components/layout/ActionBar.d.ts +1 -1
  64. package/dist/templates/components/layout/ActionBar.js +9 -7
  65. package/dist/templates/components/layout/Code.d.ts +1 -1
  66. package/dist/templates/components/layout/Code.js +6 -3
  67. package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
  68. package/dist/templates/components/layout/DocsComponents.js +38 -5
  69. package/dist/templates/components/layout/DocsNavigation.d.ts +1 -1
  70. package/dist/templates/components/layout/DocsNavigation.js +4 -2
  71. package/dist/templates/components/layout/Dropdown.d.ts +1 -0
  72. package/dist/templates/components/layout/Dropdown.js +308 -0
  73. package/dist/templates/components/layout/FocusModeToggle.d.ts +1 -1
  74. package/dist/templates/components/layout/FocusModeToggle.js +7 -4
  75. package/dist/templates/components/layout/Footer.d.ts +1 -1
  76. package/dist/templates/components/layout/Footer.js +4 -2
  77. package/dist/templates/components/layout/Header.d.ts +1 -1
  78. package/dist/templates/components/layout/Header.js +18 -8
  79. package/dist/templates/components/layout/SectionBar.d.ts +1 -1
  80. package/dist/templates/components/layout/SectionBar.js +16 -10
  81. package/dist/templates/components/layout/VariantSwitchers.d.ts +1 -0
  82. package/dist/templates/components/layout/VariantSwitchers.js +313 -0
  83. package/dist/templates/components/useStrings.d.ts +1 -0
  84. package/dist/templates/components/useStrings.js +10 -0
  85. package/dist/templates/components/useVariant.d.ts +1 -0
  86. package/dist/templates/components/useVariant.js +13 -0
  87. package/dist/templates/llms/llmsIndex.d.ts +13 -0
  88. package/dist/templates/llms/llmsIndex.js +18 -3
  89. package/dist/templates/mdx/ai-assistant.mdx.d.ts +1 -1
  90. package/dist/templates/mdx/ai-assistant.mdx.js +2 -0
  91. package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
  92. package/dist/templates/mdx/api-playground.mdx.js +2 -0
  93. package/dist/templates/mdx/commands.mdx.d.ts +1 -1
  94. package/dist/templates/mdx/commands.mdx.js +1 -1
  95. package/dist/templates/mdx/fonts.mdx.d.ts +1 -1
  96. package/dist/templates/mdx/fonts.mdx.js +1 -1
  97. package/dist/templates/mdx/footer-links.mdx.d.ts +1 -1
  98. package/dist/templates/mdx/footer-links.mdx.js +1 -1
  99. package/dist/templates/mdx/index.mdx.d.ts +1 -1
  100. package/dist/templates/mdx/index.mdx.js +2 -0
  101. package/dist/templates/mdx/languages.mdx.d.ts +1 -0
  102. package/dist/templates/mdx/languages.mdx.js +94 -0
  103. package/dist/templates/mdx/media-and-assets.mdx.d.ts +1 -1
  104. package/dist/templates/mdx/media-and-assets.mdx.js +1 -1
  105. package/dist/templates/mdx/model-context-protocol.mdx.d.ts +1 -1
  106. package/dist/templates/mdx/model-context-protocol.mdx.js +6 -0
  107. package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
  108. package/dist/templates/mdx/navigation.mdx.js +2 -0
  109. package/dist/templates/mdx/platform/ai-assistant.mdx.d.ts +1 -1
  110. package/dist/templates/mdx/platform/ai-assistant.mdx.js +2 -0
  111. package/dist/templates/mdx/platform/api-playground.mdx.d.ts +1 -1
  112. package/dist/templates/mdx/platform/api-playground.mdx.js +2 -0
  113. package/dist/templates/mdx/platform/file-editor.mdx.d.ts +1 -1
  114. package/dist/templates/mdx/platform/file-editor.mdx.js +2 -0
  115. package/dist/templates/mdx/platform/index.mdx.d.ts +1 -1
  116. package/dist/templates/mdx/platform/index.mdx.js +1 -1
  117. package/dist/templates/mdx/platform/languages.mdx.d.ts +1 -0
  118. package/dist/templates/mdx/platform/languages.mdx.js +50 -0
  119. package/dist/templates/mdx/platform/mcp.mdx.d.ts +1 -1
  120. package/dist/templates/mdx/platform/mcp.mdx.js +2 -0
  121. package/dist/templates/mdx/platform/navigation-settings.mdx.d.ts +1 -1
  122. package/dist/templates/mdx/platform/navigation-settings.mdx.js +2 -0
  123. package/dist/templates/mdx/platform/publishing.mdx.d.ts +1 -1
  124. package/dist/templates/mdx/platform/publishing.mdx.js +4 -0
  125. package/dist/templates/mdx/platform/self-updating-docs.mdx.d.ts +1 -1
  126. package/dist/templates/mdx/platform/self-updating-docs.mdx.js +2 -0
  127. package/dist/templates/mdx/platform/versions.mdx.d.ts +1 -0
  128. package/dist/templates/mdx/platform/versions.mdx.js +33 -0
  129. package/dist/templates/mdx/sections.mdx.d.ts +1 -1
  130. package/dist/templates/mdx/sections.mdx.js +1 -1
  131. package/dist/templates/mdx/theme.mdx.d.ts +1 -1
  132. package/dist/templates/mdx/theme.mdx.js +1 -1
  133. package/dist/templates/mdx/versions.mdx.d.ts +1 -0
  134. package/dist/templates/mdx/versions.mdx.js +78 -0
  135. package/dist/templates/mdx/what-is-doccupine.mdx.d.ts +1 -1
  136. package/dist/templates/mdx/what-is-doccupine.mdx.js +1 -1
  137. package/dist/templates/prettierignore.d.ts +1 -1
  138. package/dist/templates/prettierignore.js +2 -0
  139. package/dist/templates/services/mcp/server.d.ts +1 -1
  140. package/dist/templates/services/mcp/server.js +54 -10
  141. package/dist/templates/services/mcp/tools.d.ts +1 -1
  142. package/dist/templates/services/mcp/tools.js +81 -6
  143. package/dist/templates/services/mcp/types.d.ts +1 -1
  144. package/dist/templates/services/mcp/types.js +10 -0
  145. package/dist/templates/services/search.d.ts +1 -1
  146. package/dist/templates/services/search.js +34 -4
  147. package/dist/templates/utils/orderNavItems.d.ts +1 -1
  148. package/dist/templates/utils/orderNavItems.js +2 -0
  149. package/dist/templates/utils/strings.d.ts +1 -0
  150. package/dist/templates/utils/strings.js +27 -0
  151. package/dist/templates/utils/variants.d.ts +1 -0
  152. package/dist/templates/utils/variants.js +170 -0
  153. package/package.json +1 -1
@@ -4,10 +4,15 @@ import { useCallback, useContext, useEffect, useRef, useState } from "react";
4
4
  import styled, { css } from "styled-components";
5
5
  import Link from "next/link";
6
6
  import { mq, Theme } from "@/app/theme";
7
- import { ChatLauncher, useOnClickOutside } from "cherry-styled-components";
8
- import { Search } from "lucide-react";
7
+ import {
8
+ ChatLauncher,
9
+ Icon,
10
+ useOnClickOutside,
11
+ } from "cherry-styled-components";
12
+ import { Search, Sparkles } from "lucide-react";
9
13
  import { Logo } from "@/components/layout/Pictograms";
10
14
  import { ChatContext } from "@/components/Chat";
15
+ import { useStrings } from "@/components/useStrings";
11
16
  import {
12
17
  SearchContext,
13
18
  SearchKbd,
@@ -148,7 +153,6 @@ interface HeaderProps {
148
153
 
149
154
  function Header({ children }: HeaderProps) {
150
155
  const [isOptionActive, setIsOptionActive] = useState(false);
151
- const [isLangActive, setIsLangActive] = useState(false);
152
156
  const [isPinned, setIsPinned] = useState(false);
153
157
  const [headerHeight, setHeaderHeight] = useState(0);
154
158
  const headerRef = useRef<HTMLElement>(null);
@@ -171,19 +175,17 @@ function Header({ children }: HeaderProps) {
171
175
 
172
176
  const wrapperRef = useRef<HTMLSpanElement>(null);
173
177
  const elmRef = useRef<HTMLDivElement>(null);
174
- const langRef = useRef<HTMLSpanElement>(null);
175
178
  const closeMenu = useCallback(() => {
176
179
  setIsOptionActive(false);
177
- setIsLangActive(false);
178
180
  }, []);
179
181
 
180
182
  useOnClickOutside(
181
183
  [elmRef, wrapperRef],
182
184
  isOptionActive ? closeMenu : () => {},
183
185
  );
184
- useOnClickOutside([langRef, wrapperRef], isLangActive ? closeMenu : () => {});
185
186
  const { isChatActive } = useContext(ChatContext);
186
187
  const { openSearch } = useContext(SearchContext);
188
+ const t = useStrings();
187
189
 
188
190
  return (
189
191
  <StyledHeaderShell $pinned={isPinned} $height={headerHeight}>
@@ -223,11 +225,19 @@ function Header({ children }: HeaderProps) {
223
225
  </Link>
224
226
  {children}
225
227
  <StyledLeftWrapper>
226
- <StyledSearchButton onClick={openSearch} aria-label="Search docs">
228
+ <StyledSearchButton
229
+ onClick={openSearch}
230
+ aria-label={t.searchButton}
231
+ >
227
232
  <Search size={14} />
228
233
  <SearchKbd>&#8984;K</SearchKbd>
229
234
  </StyledSearchButton>
230
- {isChatActive && <ChatLauncher $glow />}
235
+ {isChatActive && (
236
+ <ChatLauncher $glow aria-label={t.askAiAssistant}>
237
+ <Icon icon={Sparkles} />
238
+ {t.askAi}
239
+ </ChatLauncher>
240
+ )}
231
241
  </StyledLeftWrapper>
232
242
  </StyledHeaderInner>
233
243
  </StyledHeader>
@@ -1 +1 @@
1
- export declare const sectionBarTemplate = "\"use client\";\nimport { usePathname } from \"next/navigation\";\nimport Link from \"next/link\";\nimport styled from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { mq, Theme } from \"@/app/theme\";\n\ninterface SectionConfig {\n label: string;\n slug: string;\n directory?: string;\n}\n\ninterface SectionBarProps {\n sections: SectionConfig[];\n}\n\nconst StyledSectionBar = styled.nav<{ theme: Theme }>`\n display: flex;\n order: 3;\n width: calc(100% + 20px);\n margin: 0 0 0 -10px;\n padding: 0;\n overflow-x: auto;\n -webkit-overflow-scrolling: touch;\n position: relative;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n padding: 0 10px;\n order: unset;\n width: 100%;\n margin: 0;\n justify-content: flex-end;\n }\n`;\n\nconst StyledSectionLink = styled(Link)<{\n theme: Theme;\n $isActive: boolean;\n}>`\n ${({ theme }) => styledText(theme)};\n text-decoration: none;\n padding: 16px 10px;\n white-space: nowrap;\n font-weight: ${({ $isActive }) => ($isActive ? \"600\" : \"500\")};\n color: ${({ theme, $isActive }) =>\n $isActive ? theme.colors.primary : theme.colors.gray};\n border-bottom: solid 2px\n ${({ theme, $isActive }) =>\n $isActive ? theme.colors.primary : \"transparent\"};\n transition: all 0.3s ease;\n min-width: fit-content;\n position: relative;\n\n /* The section bar scrolls horizontally, and overflow-x:auto makes it clip\n vertically too, so an edge-drawn ring gets shaved top and bottom. Draw the\n ring on an inset pseudo-element so it sits fully inside the link and can't\n be clipped on any side. */\n &:focus-visible {\n outline: none;\n /* Opt out of the global a:focus-visible ring; the ::after below draws it\n inset so the scroll container can't clip it. */\n box-shadow: none;\n }\n\n &:focus-visible::after {\n content: \"\";\n position: absolute;\n inset: 3px;\n border: solid 2px ${({ theme }) => theme.colors.primaryLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n pointer-events: none;\n }\n\n &:hover {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\nfunction SectionBar({ sections }: SectionBarProps) {\n const pathname = usePathname();\n const currentPath = pathname.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n\n const activeSection = sections.find((section) => {\n if (section.slug === \"\") return false;\n return (\n currentPath === section.slug || currentPath.startsWith(section.slug + \"/\")\n );\n });\n\n const activeSectionSlug = activeSection ? activeSection.slug : \"\";\n\n return (\n <StyledSectionBar>\n {sections.map((section) => (\n <StyledSectionLink\n key={section.slug}\n href={section.slug === \"\" ? \"/\" : `/${section.slug}`}\n $isActive={activeSectionSlug === section.slug}\n >\n {section.label}\n </StyledSectionLink>\n ))}\n </StyledSectionBar>\n );\n}\n\nexport { SectionBar };\n";
1
+ export declare const sectionBarTemplate = "\"use client\";\nimport Link from \"next/link\";\nimport styled from \"styled-components\";\nimport { styledText } from \"cherry-styled-components\";\nimport { mq, Theme } from \"@/app/theme\";\nimport { useVariant } from \"@/components/useVariant\";\nimport { joinVariantSlug } from \"@/utils/variants\";\n\ninterface SectionConfig {\n label: string;\n slug: string;\n directory?: string;\n}\n\ninterface SectionBarProps {\n sections: SectionConfig[];\n /** Section slugs that have pages in each language/version prefix; a\n * section absent from the current prefix is not shown there. */\n variantSections?: Record<string, string[]>;\n}\n\nconst StyledSectionBar = styled.nav<{ theme: Theme }>`\n display: flex;\n order: 3;\n width: calc(100% + 20px);\n margin: 0 0 0 -10px;\n padding: 0;\n overflow-x: auto;\n -webkit-overflow-scrolling: touch;\n position: relative;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n padding: 0 10px;\n order: unset;\n width: 100%;\n margin: 0;\n justify-content: flex-end;\n }\n`;\n\nconst StyledSectionLink = styled(Link)<{\n theme: Theme;\n $isActive: boolean;\n}>`\n ${({ theme }) => styledText(theme)};\n text-decoration: none;\n padding: 16px 10px;\n white-space: nowrap;\n font-weight: ${({ $isActive }) => ($isActive ? \"600\" : \"500\")};\n color: ${({ theme, $isActive }) =>\n $isActive ? theme.colors.primary : theme.colors.gray};\n border-bottom: solid 2px\n ${({ theme, $isActive }) =>\n $isActive ? theme.colors.primary : \"transparent\"};\n transition: all 0.3s ease;\n min-width: fit-content;\n position: relative;\n\n /* The section bar scrolls horizontally, and overflow-x:auto makes it clip\n vertically too, so an edge-drawn ring gets shaved top and bottom. Draw the\n ring on an inset pseudo-element so it sits fully inside the link and can't\n be clipped on any side. */\n &:focus-visible {\n outline: none;\n /* Opt out of the global a:focus-visible ring; the ::after below draws it\n inset so the scroll container can't clip it. */\n box-shadow: none;\n }\n\n &:focus-visible::after {\n content: \"\";\n position: absolute;\n inset: 3px;\n border: solid 2px ${({ theme }) => theme.colors.primaryLight};\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n pointer-events: none;\n }\n\n &:hover {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\nfunction SectionBar({ sections, variantSections }: SectionBarProps) {\n const { prefix, rest } = useVariant();\n const visibleSections = variantSections\n ? sections.filter((section) =>\n (variantSections[prefix] ?? []).includes(section.slug),\n )\n : sections;\n\n const activeSection = visibleSections.find((section) => {\n if (section.slug === \"\") return false;\n return rest === section.slug || rest.startsWith(section.slug + \"/\");\n });\n\n const activeSectionSlug = activeSection ? activeSection.slug : \"\";\n\n return (\n <StyledSectionBar>\n {visibleSections.map((section) => (\n <StyledSectionLink\n key={section.slug}\n href={\"/\" + joinVariantSlug(prefix, section.slug)}\n $isActive={activeSectionSlug === section.slug}\n >\n {section.label}\n </StyledSectionLink>\n ))}\n </StyledSectionBar>\n );\n}\n\nexport { SectionBar };\n";
@@ -1,9 +1,10 @@
1
1
  export const sectionBarTemplate = `"use client";
2
- import { usePathname } from "next/navigation";
3
2
  import Link from "next/link";
4
3
  import styled from "styled-components";
5
4
  import { styledText } from "cherry-styled-components";
6
5
  import { mq, Theme } from "@/app/theme";
6
+ import { useVariant } from "@/components/useVariant";
7
+ import { joinVariantSlug } from "@/utils/variants";
7
8
 
8
9
  interface SectionConfig {
9
10
  label: string;
@@ -13,6 +14,9 @@ interface SectionConfig {
13
14
 
14
15
  interface SectionBarProps {
15
16
  sections: SectionConfig[];
17
+ /** Section slugs that have pages in each language/version prefix; a
18
+ * section absent from the current prefix is not shown there. */
19
+ variantSections?: Record<string, string[]>;
16
20
  }
17
21
 
18
22
  const StyledSectionBar = styled.nav<{ theme: Theme }>\`
@@ -81,25 +85,27 @@ const StyledSectionLink = styled(Link)<{
81
85
  }
82
86
  \`;
83
87
 
84
- function SectionBar({ sections }: SectionBarProps) {
85
- const pathname = usePathname();
86
- const currentPath = pathname.replace(/^\\//, "").replace(/\\/$/, "");
88
+ function SectionBar({ sections, variantSections }: SectionBarProps) {
89
+ const { prefix, rest } = useVariant();
90
+ const visibleSections = variantSections
91
+ ? sections.filter((section) =>
92
+ (variantSections[prefix] ?? []).includes(section.slug),
93
+ )
94
+ : sections;
87
95
 
88
- const activeSection = sections.find((section) => {
96
+ const activeSection = visibleSections.find((section) => {
89
97
  if (section.slug === "") return false;
90
- return (
91
- currentPath === section.slug || currentPath.startsWith(section.slug + "/")
92
- );
98
+ return rest === section.slug || rest.startsWith(section.slug + "/");
93
99
  });
94
100
 
95
101
  const activeSectionSlug = activeSection ? activeSection.slug : "";
96
102
 
97
103
  return (
98
104
  <StyledSectionBar>
99
- {sections.map((section) => (
105
+ {visibleSections.map((section) => (
100
106
  <StyledSectionLink
101
107
  key={section.slug}
102
- href={section.slug === "" ? "/" : \`/\${section.slug}\`}
108
+ href={"/" + joinVariantSlug(prefix, section.slug)}
103
109
  $isActive={activeSectionSlug === section.slug}
104
110
  >
105
111
  {section.label}
@@ -0,0 +1 @@
1
+ export declare const variantSwitchersTemplate = "\"use client\";\nimport { useRouter } from \"next/navigation\";\nimport styled, { css } from \"styled-components\";\nimport { Check, ChevronDown, Languages, Tag } from \"lucide-react\";\nimport { mq, Theme } from \"@/app/theme\";\nimport { Dropdown, DropdownItem } from \"@/components/layout/Dropdown\";\nimport { useStrings } from \"@/components/useStrings\";\nimport { useVariant } from \"@/components/useVariant\";\nimport type { PagesProps } from \"@/utils/orderNavItems\";\nimport {\n defaultLanguage,\n joinVariantSlug,\n languages,\n pageVariantPrefix,\n stripLanguagePrefix,\n stripVariantPrefix,\n variantPrefix,\n versions,\n} from \"@/utils/variants\";\n\n// The switchers share the footer row with the focus-mode toggle at its left\n// end and the theme toggle at its right. A lone pill claims only the width\n// its label needs; a pair grows from its labels' widths into the rail's free\n// width and gives up characters, never height, when that is not enough.\nconst StyledSwitchers = styled.div<{ $dense: boolean }>`\n display: flex;\n align-items: center;\n gap: 8px;\n min-width: 0;\n\n ${({ $dense }) =>\n $dense &&\n css`\n ${mq(\"lg\")} {\n flex: 1;\n }\n `}\n`;\n\n// One pill: its trigger carries the Lucide glyph, the current label, and a\n// chevron that turns while open.\nconst StyledSwitcher = styled.div<{ $dense: boolean }>`\n display: flex;\n min-width: 0;\n\n ${({ $dense }) =>\n $dense &&\n css`\n ${mq(\"lg\")} {\n flex: 1 1 auto;\n }\n `}\n`;\n\nconst truncatedLabel = css`\n flex: 1;\n overflow: hidden;\n text-align: left;\n text-overflow: ellipsis;\n white-space: nowrap;\n`;\n\n// Fills the trigger so the label takes the width and the chevron keeps the\n// right edge when the pill is stretched across the rail.\nconst StyledTriggerContent = styled.span<{ theme: Theme }>`\n display: flex;\n align-items: center;\n gap: 6px;\n width: 100%;\n min-width: 0;\n font-size: ${({ theme }) => theme.fontSizes.small.xs};\n font-weight: 600;\n line-height: 1;\n color: ${({ theme }) => theme.colors.accentStrong};\n\n /* The glyphs sit at the toggles' own resting color and pick up the accent\n on hover, so all four controls of the row light up the same way. */\n & svg {\n flex-shrink: 0;\n color: ${({ theme }) => theme.colors.primary};\n transition: color 0.3s ease;\n }\n\n & > svg:last-child {\n transition:\n color 0.3s ease,\n transform 0.3s ease;\n }\n\n button:hover > & svg {\n color: ${({ theme }) => theme.colors.accent};\n }\n\n [aria-expanded=\"true\"] > & > svg:last-child {\n transform: rotate(180deg);\n }\n`;\n\n// Below \"lg\" the sidebar is the full-width mobile menu, so every trigger shows\n// its glyph and full label there. On the rail the two of them share about\n// 130px beside the toggles: a lone switcher still spells its label out, while\n// a pair drops to the glyphless short form (a language's code, a version's\n// own label) rather than truncating both.\nconst StyledTriggerIcon = styled.span<{ $dense: boolean }>`\n display: flex;\n\n ${({ $dense }) =>\n $dense &&\n css`\n ${mq(\"lg\")} {\n display: none;\n }\n `}\n`;\n\nconst StyledTriggerLabel = styled.span<{ $dense: boolean }>`\n ${truncatedLabel};\n\n ${({ $dense }) =>\n $dense &&\n css`\n ${mq(\"lg\")} {\n display: none;\n }\n `}\n`;\n\nconst StyledTriggerShortLabel = styled.span`\n ${truncatedLabel};\n display: none;\n\n ${mq(\"lg\")} {\n display: block;\n }\n`;\n\n// Keeps every label aligned whether or not the entry carries the check mark.\nconst StyledItemMark = styled.span`\n display: flex;\n flex-shrink: 0;\n width: 14px;\n`;\n\ninterface SwitcherOption {\n value: string;\n label: string;\n /** Rail-sized form of the label; falls back to the label itself. */\n short?: string;\n}\n\ninterface VariantSwitcherProps {\n label: string;\n icon: React.ReactNode;\n options: SwitcherOption[];\n value: string;\n /** Which edge of the trigger the menu hangs from, so it opens into the\n sidebar rather than past one of its edges. */\n align: \"left\" | \"right\";\n /** Both switchers are on the row, so the rail shows the short labels. */\n dense: boolean;\n onSelect: (value: string) => void;\n}\n\n// One dropdown of radio items above its trigger: the platform's Dropdown, so\n// the language and version pickers look like every other menu on Doccupine.\nfunction VariantSwitcher({\n label,\n icon,\n options,\n value,\n align,\n dense,\n onSelect,\n}: VariantSwitcherProps) {\n const current = options.find((option) => option.value === value);\n const currentLabel = current?.label ?? label;\n return (\n <StyledSwitcher $dense={dense}>\n <Dropdown\n role=\"menu\"\n label={label}\n triggerLabel={`${label}: ${currentLabel}`}\n align={align}\n placement=\"top\"\n compact\n fullWidth={dense}\n trigger={\n <StyledTriggerContent>\n <StyledTriggerIcon $dense={dense}>{icon}</StyledTriggerIcon>\n <StyledTriggerLabel $dense={dense}>\n {currentLabel}\n </StyledTriggerLabel>\n {dense && (\n <StyledTriggerShortLabel>\n {current?.short ?? currentLabel}\n </StyledTriggerShortLabel>\n )}\n <ChevronDown size={12} aria-hidden=\"true\" />\n </StyledTriggerContent>\n }\n >\n {options.map((option) => (\n <DropdownItem\n key={option.value}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={option.value === value}\n $checked={option.value === value}\n onClick={() => onSelect(option.value)}\n >\n <StyledItemMark aria-hidden=\"true\">\n {option.value === value && <Check size={14} />}\n </StyledItemMark>\n {option.label}\n </DropdownItem>\n ))}\n </Dropdown>\n </StyledSwitcher>\n );\n}\n\ninterface VariantSwitchersProps {\n pages: PagesProps[];\n}\n\n// The language and version switchers on the sidebar footer row, between the\n// focus-mode and theme toggles. Each is rendered only when its file declares\n// at least two entries, so a site without languages.json or versions.json\n// renders nothing here and the row keeps just its two toggles.\nfunction VariantSwitchers({ pages }: VariantSwitchersProps) {\n const router = useRouter();\n const current = useVariant();\n const t = useStrings();\n const showLanguages = (languages?.length ?? 0) >= 2;\n const showVersions = (versions?.length ?? 0) >= 2;\n if (!showLanguages && !showVersions) return null;\n\n const currentSlug = joinVariantSlug(current.prefix, current.rest);\n const currentLocale = current.locale ?? defaultLanguage()?.code;\n const currentVersion = current.version ?? \"\";\n const go = (slug: string) => router.push(slug === \"\" ? \"/\" : \"/\" + slug);\n const hasPagesIn = (prefix: string) =>\n pages.some((page) => pageVariantPrefix(page) === prefix);\n\n // The same page in the target language when it exists, otherwise that\n // language's home for the current version, otherwise its default home.\n const switchLanguage = (code: string) => {\n const key = stripLanguagePrefix(currentSlug, currentLocale);\n const match = pages.find(\n (page) =>\n page.locale === code &&\n stripLanguagePrefix(page.slug, page.locale) === key,\n );\n if (match) return go(match.slug);\n const withVersion = variantPrefix(code, currentVersion);\n go(hasPagesIn(withVersion) ? withVersion : variantPrefix(code, \"\"));\n };\n\n // The same page in the target version for the current language when it\n // exists, otherwise that version's home for the current language.\n const switchVersion = (slug: string) => {\n const key = stripVariantPrefix(currentSlug, currentLocale, currentVersion);\n const match = pages.find(\n (page) =>\n (page.locale ?? currentLocale) === currentLocale &&\n (page.version ?? \"\") === slug &&\n stripVariantPrefix(page.slug, page.locale, page.version) === key,\n );\n go(match ? match.slug : variantPrefix(currentLocale, slug));\n };\n\n // A pair spreads across the rail, so the first menu hangs from its\n // trigger's left edge and the second from its right edge: either way the\n // menu opens over the sidebar instead of past one of its sides.\n const dense = showLanguages && showVersions;\n\n return (\n <StyledSwitchers $dense={dense}>\n {showLanguages && languages && (\n <VariantSwitcher\n label={t.language}\n icon={<Languages size={16} aria-hidden=\"true\" />}\n value={currentLocale ?? \"\"}\n align=\"left\"\n dense={dense}\n onSelect={switchLanguage}\n options={languages.map((language) => ({\n value: language.code,\n label: language.label,\n short: language.code.toUpperCase(),\n }))}\n />\n )}\n {showVersions && versions && (\n <VariantSwitcher\n label={t.version}\n icon={<Tag size={16} aria-hidden=\"true\" />}\n value={currentVersion}\n align={dense ? \"right\" : \"left\"}\n dense={dense}\n onSelect={switchVersion}\n options={versions.map((version) => ({\n value: version.slug,\n label: version.label,\n }))}\n />\n )}\n </StyledSwitchers>\n );\n}\n\nexport { VariantSwitchers };\n";
@@ -0,0 +1,313 @@
1
+ export const variantSwitchersTemplate = `"use client";
2
+ import { useRouter } from "next/navigation";
3
+ import styled, { css } from "styled-components";
4
+ import { Check, ChevronDown, Languages, Tag } from "lucide-react";
5
+ import { mq, Theme } from "@/app/theme";
6
+ import { Dropdown, DropdownItem } from "@/components/layout/Dropdown";
7
+ import { useStrings } from "@/components/useStrings";
8
+ import { useVariant } from "@/components/useVariant";
9
+ import type { PagesProps } from "@/utils/orderNavItems";
10
+ import {
11
+ defaultLanguage,
12
+ joinVariantSlug,
13
+ languages,
14
+ pageVariantPrefix,
15
+ stripLanguagePrefix,
16
+ stripVariantPrefix,
17
+ variantPrefix,
18
+ versions,
19
+ } from "@/utils/variants";
20
+
21
+ // The switchers share the footer row with the focus-mode toggle at its left
22
+ // end and the theme toggle at its right. A lone pill claims only the width
23
+ // its label needs; a pair grows from its labels' widths into the rail's free
24
+ // width and gives up characters, never height, when that is not enough.
25
+ const StyledSwitchers = styled.div<{ $dense: boolean }>\`
26
+ display: flex;
27
+ align-items: center;
28
+ gap: 8px;
29
+ min-width: 0;
30
+
31
+ \${({ $dense }) =>
32
+ $dense &&
33
+ css\`
34
+ \${mq("lg")} {
35
+ flex: 1;
36
+ }
37
+ \`}
38
+ \`;
39
+
40
+ // One pill: its trigger carries the Lucide glyph, the current label, and a
41
+ // chevron that turns while open.
42
+ const StyledSwitcher = styled.div<{ $dense: boolean }>\`
43
+ display: flex;
44
+ min-width: 0;
45
+
46
+ \${({ $dense }) =>
47
+ $dense &&
48
+ css\`
49
+ \${mq("lg")} {
50
+ flex: 1 1 auto;
51
+ }
52
+ \`}
53
+ \`;
54
+
55
+ const truncatedLabel = css\`
56
+ flex: 1;
57
+ overflow: hidden;
58
+ text-align: left;
59
+ text-overflow: ellipsis;
60
+ white-space: nowrap;
61
+ \`;
62
+
63
+ // Fills the trigger so the label takes the width and the chevron keeps the
64
+ // right edge when the pill is stretched across the rail.
65
+ const StyledTriggerContent = styled.span<{ theme: Theme }>\`
66
+ display: flex;
67
+ align-items: center;
68
+ gap: 6px;
69
+ width: 100%;
70
+ min-width: 0;
71
+ font-size: \${({ theme }) => theme.fontSizes.small.xs};
72
+ font-weight: 600;
73
+ line-height: 1;
74
+ color: \${({ theme }) => theme.colors.accentStrong};
75
+
76
+ /* The glyphs sit at the toggles' own resting color and pick up the accent
77
+ on hover, so all four controls of the row light up the same way. */
78
+ & svg {
79
+ flex-shrink: 0;
80
+ color: \${({ theme }) => theme.colors.primary};
81
+ transition: color 0.3s ease;
82
+ }
83
+
84
+ & > svg:last-child {
85
+ transition:
86
+ color 0.3s ease,
87
+ transform 0.3s ease;
88
+ }
89
+
90
+ button:hover > & svg {
91
+ color: \${({ theme }) => theme.colors.accent};
92
+ }
93
+
94
+ [aria-expanded="true"] > & > svg:last-child {
95
+ transform: rotate(180deg);
96
+ }
97
+ \`;
98
+
99
+ // Below "lg" the sidebar is the full-width mobile menu, so every trigger shows
100
+ // its glyph and full label there. On the rail the two of them share about
101
+ // 130px beside the toggles: a lone switcher still spells its label out, while
102
+ // a pair drops to the glyphless short form (a language's code, a version's
103
+ // own label) rather than truncating both.
104
+ const StyledTriggerIcon = styled.span<{ $dense: boolean }>\`
105
+ display: flex;
106
+
107
+ \${({ $dense }) =>
108
+ $dense &&
109
+ css\`
110
+ \${mq("lg")} {
111
+ display: none;
112
+ }
113
+ \`}
114
+ \`;
115
+
116
+ const StyledTriggerLabel = styled.span<{ $dense: boolean }>\`
117
+ \${truncatedLabel};
118
+
119
+ \${({ $dense }) =>
120
+ $dense &&
121
+ css\`
122
+ \${mq("lg")} {
123
+ display: none;
124
+ }
125
+ \`}
126
+ \`;
127
+
128
+ const StyledTriggerShortLabel = styled.span\`
129
+ \${truncatedLabel};
130
+ display: none;
131
+
132
+ \${mq("lg")} {
133
+ display: block;
134
+ }
135
+ \`;
136
+
137
+ // Keeps every label aligned whether or not the entry carries the check mark.
138
+ const StyledItemMark = styled.span\`
139
+ display: flex;
140
+ flex-shrink: 0;
141
+ width: 14px;
142
+ \`;
143
+
144
+ interface SwitcherOption {
145
+ value: string;
146
+ label: string;
147
+ /** Rail-sized form of the label; falls back to the label itself. */
148
+ short?: string;
149
+ }
150
+
151
+ interface VariantSwitcherProps {
152
+ label: string;
153
+ icon: React.ReactNode;
154
+ options: SwitcherOption[];
155
+ value: string;
156
+ /** Which edge of the trigger the menu hangs from, so it opens into the
157
+ sidebar rather than past one of its edges. */
158
+ align: "left" | "right";
159
+ /** Both switchers are on the row, so the rail shows the short labels. */
160
+ dense: boolean;
161
+ onSelect: (value: string) => void;
162
+ }
163
+
164
+ // One dropdown of radio items above its trigger: the platform's Dropdown, so
165
+ // the language and version pickers look like every other menu on Doccupine.
166
+ function VariantSwitcher({
167
+ label,
168
+ icon,
169
+ options,
170
+ value,
171
+ align,
172
+ dense,
173
+ onSelect,
174
+ }: VariantSwitcherProps) {
175
+ const current = options.find((option) => option.value === value);
176
+ const currentLabel = current?.label ?? label;
177
+ return (
178
+ <StyledSwitcher $dense={dense}>
179
+ <Dropdown
180
+ role="menu"
181
+ label={label}
182
+ triggerLabel={\`\${label}: \${currentLabel}\`}
183
+ align={align}
184
+ placement="top"
185
+ compact
186
+ fullWidth={dense}
187
+ trigger={
188
+ <StyledTriggerContent>
189
+ <StyledTriggerIcon $dense={dense}>{icon}</StyledTriggerIcon>
190
+ <StyledTriggerLabel $dense={dense}>
191
+ {currentLabel}
192
+ </StyledTriggerLabel>
193
+ {dense && (
194
+ <StyledTriggerShortLabel>
195
+ {current?.short ?? currentLabel}
196
+ </StyledTriggerShortLabel>
197
+ )}
198
+ <ChevronDown size={12} aria-hidden="true" />
199
+ </StyledTriggerContent>
200
+ }
201
+ >
202
+ {options.map((option) => (
203
+ <DropdownItem
204
+ key={option.value}
205
+ type="button"
206
+ role="menuitemradio"
207
+ aria-checked={option.value === value}
208
+ $checked={option.value === value}
209
+ onClick={() => onSelect(option.value)}
210
+ >
211
+ <StyledItemMark aria-hidden="true">
212
+ {option.value === value && <Check size={14} />}
213
+ </StyledItemMark>
214
+ {option.label}
215
+ </DropdownItem>
216
+ ))}
217
+ </Dropdown>
218
+ </StyledSwitcher>
219
+ );
220
+ }
221
+
222
+ interface VariantSwitchersProps {
223
+ pages: PagesProps[];
224
+ }
225
+
226
+ // The language and version switchers on the sidebar footer row, between the
227
+ // focus-mode and theme toggles. Each is rendered only when its file declares
228
+ // at least two entries, so a site without languages.json or versions.json
229
+ // renders nothing here and the row keeps just its two toggles.
230
+ function VariantSwitchers({ pages }: VariantSwitchersProps) {
231
+ const router = useRouter();
232
+ const current = useVariant();
233
+ const t = useStrings();
234
+ const showLanguages = (languages?.length ?? 0) >= 2;
235
+ const showVersions = (versions?.length ?? 0) >= 2;
236
+ if (!showLanguages && !showVersions) return null;
237
+
238
+ const currentSlug = joinVariantSlug(current.prefix, current.rest);
239
+ const currentLocale = current.locale ?? defaultLanguage()?.code;
240
+ const currentVersion = current.version ?? "";
241
+ const go = (slug: string) => router.push(slug === "" ? "/" : "/" + slug);
242
+ const hasPagesIn = (prefix: string) =>
243
+ pages.some((page) => pageVariantPrefix(page) === prefix);
244
+
245
+ // The same page in the target language when it exists, otherwise that
246
+ // language's home for the current version, otherwise its default home.
247
+ const switchLanguage = (code: string) => {
248
+ const key = stripLanguagePrefix(currentSlug, currentLocale);
249
+ const match = pages.find(
250
+ (page) =>
251
+ page.locale === code &&
252
+ stripLanguagePrefix(page.slug, page.locale) === key,
253
+ );
254
+ if (match) return go(match.slug);
255
+ const withVersion = variantPrefix(code, currentVersion);
256
+ go(hasPagesIn(withVersion) ? withVersion : variantPrefix(code, ""));
257
+ };
258
+
259
+ // The same page in the target version for the current language when it
260
+ // exists, otherwise that version's home for the current language.
261
+ const switchVersion = (slug: string) => {
262
+ const key = stripVariantPrefix(currentSlug, currentLocale, currentVersion);
263
+ const match = pages.find(
264
+ (page) =>
265
+ (page.locale ?? currentLocale) === currentLocale &&
266
+ (page.version ?? "") === slug &&
267
+ stripVariantPrefix(page.slug, page.locale, page.version) === key,
268
+ );
269
+ go(match ? match.slug : variantPrefix(currentLocale, slug));
270
+ };
271
+
272
+ // A pair spreads across the rail, so the first menu hangs from its
273
+ // trigger's left edge and the second from its right edge: either way the
274
+ // menu opens over the sidebar instead of past one of its sides.
275
+ const dense = showLanguages && showVersions;
276
+
277
+ return (
278
+ <StyledSwitchers $dense={dense}>
279
+ {showLanguages && languages && (
280
+ <VariantSwitcher
281
+ label={t.language}
282
+ icon={<Languages size={16} aria-hidden="true" />}
283
+ value={currentLocale ?? ""}
284
+ align="left"
285
+ dense={dense}
286
+ onSelect={switchLanguage}
287
+ options={languages.map((language) => ({
288
+ value: language.code,
289
+ label: language.label,
290
+ short: language.code.toUpperCase(),
291
+ }))}
292
+ />
293
+ )}
294
+ {showVersions && versions && (
295
+ <VariantSwitcher
296
+ label={t.version}
297
+ icon={<Tag size={16} aria-hidden="true" />}
298
+ value={currentVersion}
299
+ align={dense ? "right" : "left"}
300
+ dense={dense}
301
+ onSelect={switchVersion}
302
+ options={versions.map((version) => ({
303
+ value: version.slug,
304
+ label: version.label,
305
+ }))}
306
+ />
307
+ )}
308
+ </StyledSwitchers>
309
+ );
310
+ }
311
+
312
+ export { VariantSwitchers };
313
+ `;
@@ -0,0 +1 @@
1
+ export declare const useStringsTemplate = "\"use client\";\nimport { useVariant } from \"@/components/useVariant\";\nimport { getStrings, type UiStrings } from \"@/utils/strings\";\n\n/** The chrome strings of the current route's language. */\nexport function useStrings(): UiStrings {\n const { locale } = useVariant();\n return getStrings(locale);\n}\n";
@@ -0,0 +1,10 @@
1
+ export const useStringsTemplate = `"use client";
2
+ import { useVariant } from "@/components/useVariant";
3
+ import { getStrings, type UiStrings } from "@/utils/strings";
4
+
5
+ /** The chrome strings of the current route's language. */
6
+ export function useStrings(): UiStrings {
7
+ const { locale } = useVariant();
8
+ return getStrings(locale);
9
+ }
10
+ `;
@@ -0,0 +1 @@
1
+ export declare const useVariantTemplate = "\"use client\";\nimport { usePathname } from \"next/navigation\";\nimport {\n resolveVariantFromSlug,\n type VariantResolution,\n} from \"@/utils/variants\";\n\n/** The language and version of the current route, read from its URL prefix. */\nexport function useVariant(): VariantResolution {\n const pathname = usePathname();\n return resolveVariantFromSlug(pathname);\n}\n";
@@ -0,0 +1,13 @@
1
+ export const useVariantTemplate = `"use client";
2
+ import { usePathname } from "next/navigation";
3
+ import {
4
+ resolveVariantFromSlug,
5
+ type VariantResolution,
6
+ } from "@/utils/variants";
7
+
8
+ /** The language and version of the current route, read from its URL prefix. */
9
+ export function useVariant(): VariantResolution {
10
+ const pathname = usePathname();
11
+ return resolveVariantFromSlug(pathname);
12
+ }
13
+ `;
@@ -1,10 +1,23 @@
1
1
  import type { PageMeta, SectionConfig } from "../../lib/types.js";
2
+ export interface LlmsVariantLink {
3
+ label: string;
4
+ url: string;
5
+ }
2
6
  export interface LlmsIndexArgs {
3
7
  siteName: string;
4
8
  siteDescription?: string;
5
9
  baseUrl: string | null;
6
10
  pages: PageMeta[];
7
11
  sectionsConfig: SectionConfig[] | null;
12
+ /** The `llms.txt` of every other language/version of the site, appended as
13
+ * a final section so an agent can find the variant it needs. */
14
+ variantLinks?: {
15
+ heading: string;
16
+ links: LlmsVariantLink[];
17
+ };
18
+ /** URL prefix of the language/version this index describes ("" at the
19
+ * root); its full-corpus file lives under the same prefix. */
20
+ variantPrefix?: string;
8
21
  }
9
22
  export interface CategoryGroup {
10
23
  category: string;
@@ -69,10 +69,23 @@ export function buildSectionGroups(pages, sectionsConfig) {
69
69
  groups.sort((a, b) => a.sectionOrder - b.sectionOrder);
70
70
  return groups;
71
71
  }
72
+ function variantLinkLines(variantLinks) {
73
+ if (!variantLinks || variantLinks.links.length === 0)
74
+ return [];
75
+ return [
76
+ `## ${variantLinks.heading}`,
77
+ "",
78
+ ...variantLinks.links.map((link) => `- [${link.label}](${link.url})`),
79
+ "",
80
+ ];
81
+ }
72
82
  export function llmsIndexTemplate(args) {
73
- const { siteName, siteDescription, baseUrl, pages, sectionsConfig } = args;
83
+ const { siteName, siteDescription, baseUrl, pages, sectionsConfig, variantLinks, variantPrefix = "", } = args;
74
84
  const lines = [];
75
85
  const prefix = baseUrl ?? "";
86
+ const fullCorpusPath = variantPrefix
87
+ ? `/${variantPrefix}/llms-full.txt`
88
+ : "/llms-full.txt";
76
89
  lines.push(`# ${siteName}`);
77
90
  lines.push("");
78
91
  const summary = siteDescription && siteDescription.trim() !== ""
@@ -81,12 +94,13 @@ export function llmsIndexTemplate(args) {
81
94
  lines.push(`> ${summary}`);
82
95
  lines.push("");
83
96
  lines.push("Every page link below points to a markdown mirror; drop the .md suffix for the HTML version.");
84
- lines.push(`Full corpus in one file: ${prefix}/llms-full.txt`);
97
+ lines.push(`Full corpus in one file: ${prefix}${fullCorpusPath}`);
85
98
  lines.push(`Agent skill: ${prefix}/skill.md`);
86
99
  lines.push(`MCP server (streamable HTTP; tools: search_docs, get_doc, list_docs): ${prefix}/api/mcp`);
87
100
  lines.push("");
88
101
  if (pages.length === 0) {
89
- return lines.join("\n") + "\n";
102
+ lines.push(...variantLinkLines(variantLinks));
103
+ return lines.join("\n").replace(/\n+$/, "\n");
90
104
  }
91
105
  const groups = buildSectionGroups(pages, sectionsConfig);
92
106
  for (const group of groups) {
@@ -109,5 +123,6 @@ export function llmsIndexTemplate(args) {
109
123
  lines.push("");
110
124
  }
111
125
  }
126
+ lines.push(...variantLinkLines(variantLinks));
112
127
  return lines.join("\n").replace(/\n+$/, "\n");
113
128
  }
@@ -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: 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.";
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\nOn a site with [languages](/languages) or [versions](/versions), the assistant answers from the pages of the language and version the reader is on.\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.";
@@ -19,6 +19,8 @@ Once a provider is configured, an assistant button appears in the header. You ca
19
19
  The keyboard shortcut is only active once you have configured an LLM provider, as described below.
20
20
  </Callout>
21
21
 
22
+ On a site with [languages](/languages) or [versions](/versions), the assistant answers from the pages of the language and version the reader is on.
23
+
22
24
  ## Setup
23
25
 
24
26
  To enable AI features, create an \`.env\` file in the directory where your website is generated. By default, this is the \`nextjs-app/\` directory.