@farming-labs/docs 0.1.1-beta.2 → 0.1.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts DELETED
@@ -1,100 +0,0 @@
1
- import { A as SidebarNode, C as PageActionsConfig, D as SidebarComponentProps, E as PageTwitter, F as UIConfig, M as SidebarTree, N as ThemeToggleConfig, O as SidebarConfig, P as TypographyConfig, S as OrderingItem, T as PageOpenGraph, _ as LlmsTxtConfig, a as CopyMarkdownConfig, b as OpenDocsProvider, c as DocsFeedbackValue, d as DocsNav, f as DocsTheme, g as LastUpdatedConfig, h as GithubConfig, i as CodeBlockCopyData, j as SidebarPageNode, k as SidebarFolderNode, l as DocsI18nConfig, m as FontStyle, n as ApiReferenceConfig, o as DocsConfig, p as FeedbackConfig, r as BreadcrumbConfig, s as DocsFeedbackData, t as AIConfig, u as DocsMetadata, v as OGConfig, w as PageFrontmatter, x as OpenGraphImage, y as OpenDocsConfig } from "./types-DpijZMth.mjs";
2
-
3
- //#region src/define-docs.d.ts
4
- /**
5
- * Define docs configuration. Validates and returns the config.
6
- */
7
- declare function defineDocs(config: DocsConfig): DocsConfig;
8
- //#endregion
9
- //#region src/utils.d.ts
10
- /**
11
- * Deep merge utility for theme overrides.
12
- * Merges objects recursively; later values override earlier ones.
13
- */
14
- declare function deepMerge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T;
15
- //#endregion
16
- //#region src/create-theme.d.ts
17
- /**
18
- * Create a theme preset factory.
19
- *
20
- * Returns a function that accepts optional overrides and deep-merges them
21
- * with the base theme defaults. This is the same pattern used by the
22
- * built-in `fumadocs()`, `darksharp()`, and `pixelBorder()` presets.
23
- *
24
- * @param baseTheme - The default theme configuration
25
- * @returns A factory function `(overrides?) => DocsTheme`
26
- *
27
- * @example
28
- * ```ts
29
- * import { createTheme } from "@farming-labs/docs";
30
- *
31
- * export const myTheme = createTheme({
32
- * name: "my-theme",
33
- * ui: {
34
- * colors: { primary: "#6366f1" },
35
- * layout: { contentWidth: 800 },
36
- * },
37
- * });
38
- * ```
39
- */
40
- declare function createTheme(baseTheme: DocsTheme): (overrides?: Partial<DocsTheme>) => DocsTheme;
41
- /**
42
- * Extend an existing theme preset with additional defaults.
43
- *
44
- * Useful when you want to build on top of an existing theme (e.g. fumadocs)
45
- * rather than starting from scratch.
46
- *
47
- * @example
48
- * ```ts
49
- * import { extendTheme } from "@farming-labs/docs";
50
- * import { fumadocs } from "@farming-labs/theme/default";
51
- *
52
- * // Start with fumadocs defaults, override some values
53
- * export const myTheme = extendTheme(fumadocs(), {
54
- * name: "my-custom-fumadocs",
55
- * ui: { colors: { primary: "#22c55e" } },
56
- * });
57
- * ```
58
- */
59
- declare function extendTheme(baseTheme: DocsTheme, extensions: Partial<DocsTheme>): DocsTheme;
60
- //#endregion
61
- //#region src/i18n.d.ts
62
- interface ResolvedDocsI18n {
63
- locales: string[];
64
- defaultLocale: string;
65
- }
66
- interface DocsPathMatch {
67
- /** Slug path relative to the docs root (no leading slash). */
68
- slug: string;
69
- /** Entry path used for URLs (no locale segment). */
70
- entryPath: string;
71
- }
72
- declare function resolveDocsI18n(config?: DocsI18nConfig | null): ResolvedDocsI18n | null;
73
- declare function resolveDocsLocale(searchParams: URLSearchParams, i18n?: ResolvedDocsI18n | null): string | undefined;
74
- declare function resolveDocsPath(pathname: string, entry: string): DocsPathMatch;
75
- //#endregion
76
- //#region src/metadata.d.ts
77
- /**
78
- * Resolve page title using metadata titleTemplate.
79
- * %s is replaced with page title.
80
- */
81
- declare function resolveTitle(pageTitle: string, metadata?: DocsMetadata): string;
82
- /**
83
- * Resolve OG image URL for a page.
84
- * Prefers page.openGraph.images[0], then page.ogImage, then config endpoint/default.
85
- */
86
- declare function resolveOGImage(page: PageFrontmatter, ogConfig?: OGConfig, baseUrl?: string): string | undefined;
87
- /**
88
- * Build the Open Graph metadata object for a page.
89
- * When the page has openGraph in frontmatter, uses it (with title/description filled from page if omitted).
90
- * Otherwise uses ogImage or config (dynamic endpoint / defaultImage).
91
- */
92
- declare function buildPageOpenGraph(page: Pick<PageFrontmatter, "title" | "description" | "ogImage" | "openGraph">, ogConfig?: OGConfig, baseUrl?: string): PageOpenGraph | undefined;
93
- /**
94
- * Build the Twitter card metadata object for a page.
95
- * When the page has twitter in frontmatter, uses it.
96
- * Otherwise builds from ogImage or config (dynamic endpoint).
97
- */
98
- declare function buildPageTwitter(page: Pick<PageFrontmatter, "title" | "description" | "ogImage" | "openGraph" | "twitter">, ogConfig?: OGConfig, baseUrl?: string): PageTwitter | undefined;
99
- //#endregion
100
- export { type AIConfig, type ApiReferenceConfig, type BreadcrumbConfig, type CodeBlockCopyData, type CopyMarkdownConfig, type DocsConfig, type DocsFeedbackData, type DocsFeedbackValue, type DocsI18nConfig, type DocsMetadata, type DocsNav, type DocsPathMatch, type DocsTheme, type FeedbackConfig, type FontStyle, type GithubConfig, type LastUpdatedConfig, type LlmsTxtConfig, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, type OpenGraphImage, type OrderingItem, type PageActionsConfig, type PageFrontmatter, type PageOpenGraph, type PageTwitter, type ResolvedDocsI18n, type SidebarComponentProps, type SidebarConfig, type SidebarFolderNode, type SidebarNode, type SidebarPageNode, type SidebarTree, type ThemeToggleConfig, type TypographyConfig, type UIConfig, buildPageOpenGraph, buildPageTwitter, createTheme, deepMerge, defineDocs, extendTheme, resolveDocsI18n, resolveDocsLocale, resolveDocsPath, resolveOGImage, resolveTitle };
package/dist/index.mjs DELETED
@@ -1,226 +0,0 @@
1
- //#region src/define-docs.ts
2
- /**
3
- * Define docs configuration. Validates and returns the config.
4
- */
5
- function defineDocs(config) {
6
- return {
7
- entry: config.entry ?? "docs",
8
- contentDir: config.contentDir,
9
- i18n: config.i18n,
10
- theme: config.theme,
11
- nav: config.nav,
12
- github: config.github,
13
- themeToggle: config.themeToggle,
14
- breadcrumb: config.breadcrumb,
15
- sidebar: config.sidebar,
16
- components: config.components,
17
- onCopyClick: config.onCopyClick,
18
- feedback: config.feedback,
19
- icons: config.icons,
20
- pageActions: config.pageActions,
21
- lastUpdated: config.lastUpdated,
22
- llmsTxt: config.llmsTxt,
23
- ai: config.ai,
24
- ordering: config.ordering,
25
- metadata: config.metadata,
26
- og: config.og,
27
- apiReference: config.apiReference
28
- };
29
- }
30
-
31
- //#endregion
32
- //#region src/utils.ts
33
- /**
34
- * Deep merge utility for theme overrides.
35
- * Merges objects recursively; later values override earlier ones.
36
- */
37
- function deepMerge(target, ...sources) {
38
- if (!sources.length) return target;
39
- const source = sources.shift();
40
- if (!source) return target;
41
- const result = { ...target };
42
- for (const key of Object.keys(source)) {
43
- const sourceVal = source[key];
44
- const targetVal = result[key];
45
- if (sourceVal && typeof sourceVal === "object" && !Array.isArray(sourceVal) && targetVal && typeof targetVal === "object" && !Array.isArray(targetVal)) result[key] = deepMerge(targetVal, sourceVal);
46
- else if (sourceVal !== void 0) result[key] = sourceVal;
47
- }
48
- if (sources.length) return deepMerge(result, ...sources);
49
- return result;
50
- }
51
-
52
- //#endregion
53
- //#region src/create-theme.ts
54
- /**
55
- * Create a theme preset factory.
56
- *
57
- * Returns a function that accepts optional overrides and deep-merges them
58
- * with the base theme defaults. This is the same pattern used by the
59
- * built-in `fumadocs()`, `darksharp()`, and `pixelBorder()` presets.
60
- *
61
- * @param baseTheme - The default theme configuration
62
- * @returns A factory function `(overrides?) => DocsTheme`
63
- *
64
- * @example
65
- * ```ts
66
- * import { createTheme } from "@farming-labs/docs";
67
- *
68
- * export const myTheme = createTheme({
69
- * name: "my-theme",
70
- * ui: {
71
- * colors: { primary: "#6366f1" },
72
- * layout: { contentWidth: 800 },
73
- * },
74
- * });
75
- * ```
76
- */
77
- function createTheme(baseTheme) {
78
- return function themeFactory(overrides = {}) {
79
- const merged = deepMerge(baseTheme, overrides);
80
- if (overrides.ui?.colors) merged._userColorOverrides = { ...overrides.ui.colors };
81
- return merged;
82
- };
83
- }
84
- /**
85
- * Extend an existing theme preset with additional defaults.
86
- *
87
- * Useful when you want to build on top of an existing theme (e.g. fumadocs)
88
- * rather than starting from scratch.
89
- *
90
- * @example
91
- * ```ts
92
- * import { extendTheme } from "@farming-labs/docs";
93
- * import { fumadocs } from "@farming-labs/theme/default";
94
- *
95
- * // Start with fumadocs defaults, override some values
96
- * export const myTheme = extendTheme(fumadocs(), {
97
- * name: "my-custom-fumadocs",
98
- * ui: { colors: { primary: "#22c55e" } },
99
- * });
100
- * ```
101
- */
102
- function extendTheme(baseTheme, extensions) {
103
- return deepMerge(baseTheme, extensions);
104
- }
105
-
106
- //#endregion
107
- //#region src/i18n.ts
108
- function normalizeSegment(value) {
109
- return value.replace(/^\/+|\/+$/g, "");
110
- }
111
- function splitSegments(value) {
112
- const cleaned = normalizeSegment(value);
113
- return cleaned ? cleaned.split("/").filter(Boolean) : [];
114
- }
115
- function resolveDocsI18n(config) {
116
- if (!config || !Array.isArray(config.locales)) return null;
117
- const locales = Array.from(new Set(config.locales.map((l) => l.trim()).filter(Boolean)));
118
- if (locales.length === 0) return null;
119
- return {
120
- locales,
121
- defaultLocale: config.defaultLocale && locales.includes(config.defaultLocale) ? config.defaultLocale : locales[0]
122
- };
123
- }
124
- function resolveDocsLocale(searchParams, i18n) {
125
- if (!i18n) return void 0;
126
- const raw = searchParams.get("lang") ?? searchParams.get("locale");
127
- if (!raw) return void 0;
128
- if (i18n.locales.includes(raw)) return raw;
129
- return i18n.defaultLocale;
130
- }
131
- function resolveDocsPath(pathname, entry) {
132
- const entryBase = normalizeSegment(entry || "docs") || "docs";
133
- const entryParts = splitSegments(entryBase);
134
- const pathParts = splitSegments(pathname);
135
- let rest = pathParts;
136
- if (entryParts.length > 0) {
137
- if (pathParts.slice(0, entryParts.length).join("/") === entryParts.join("/")) rest = pathParts.slice(entryParts.length);
138
- }
139
- return {
140
- slug: rest.join("/"),
141
- entryPath: entryBase
142
- };
143
- }
144
-
145
- //#endregion
146
- //#region src/metadata.ts
147
- /**
148
- * Resolve page title using metadata titleTemplate.
149
- * %s is replaced with page title.
150
- */
151
- function resolveTitle(pageTitle, metadata) {
152
- return (metadata?.titleTemplate ?? "%s").replace("%s", pageTitle);
153
- }
154
- /**
155
- * Resolve OG image URL for a page.
156
- * Prefers page.openGraph.images[0], then page.ogImage, then config endpoint/default.
157
- */
158
- function resolveOGImage(page, ogConfig, baseUrl) {
159
- if (page.openGraph?.images?.length) return resolveImageUrl(page.openGraph.images[0].url, baseUrl);
160
- if (!ogConfig?.enabled) return void 0;
161
- if (page.ogImage) return resolveImageUrl(page.ogImage, baseUrl);
162
- if (ogConfig.type === "dynamic" && ogConfig.endpoint) return `${baseUrl ?? ""}${ogConfig.endpoint}`;
163
- return ogConfig.defaultImage;
164
- }
165
- function resolveImageUrl(url, baseUrl) {
166
- if (url.startsWith("/") || url.startsWith("http")) return url;
167
- const base = baseUrl ?? "";
168
- return `${base}${base.length > 0 && !base.endsWith("/") ? "/" : ""}${url}`;
169
- }
170
- /**
171
- * Build the Open Graph metadata object for a page.
172
- * When the page has openGraph in frontmatter, uses it (with title/description filled from page if omitted).
173
- * Otherwise uses ogImage or config (dynamic endpoint / defaultImage).
174
- */
175
- function buildPageOpenGraph(page, ogConfig, baseUrl) {
176
- if (page.openGraph) {
177
- const images = page.openGraph.images?.length ? page.openGraph.images.map((img) => ({
178
- url: resolveImageUrl(img.url, baseUrl),
179
- width: img.width ?? 1200,
180
- height: img.height ?? 630
181
- })) : void 0;
182
- return {
183
- title: page.openGraph.title ?? page.title,
184
- description: page.openGraph.description ?? page.description,
185
- ...images && { images }
186
- };
187
- }
188
- const url = resolveOGImage(page, ogConfig, baseUrl);
189
- if (!url) return void 0;
190
- return {
191
- title: page.title,
192
- ...page.description && { description: page.description },
193
- images: [{
194
- url,
195
- width: 1200,
196
- height: 630
197
- }]
198
- };
199
- }
200
- /**
201
- * Build the Twitter card metadata object for a page.
202
- * When the page has twitter in frontmatter, uses it.
203
- * Otherwise builds from ogImage or config (dynamic endpoint).
204
- */
205
- function buildPageTwitter(page, ogConfig, baseUrl) {
206
- if (page.twitter) {
207
- const images = page.twitter.images?.length ? page.twitter.images.map((url) => resolveImageUrl(url, baseUrl)) : void 0;
208
- return {
209
- ...page.twitter.card && { card: page.twitter.card },
210
- ...page.twitter.title !== void 0 && { title: page.twitter.title },
211
- ...page.twitter.description !== void 0 && { description: page.twitter.description },
212
- ...images && { images }
213
- };
214
- }
215
- const url = resolveOGImage(page, ogConfig, baseUrl);
216
- if (!url) return void 0;
217
- return {
218
- card: "summary_large_image",
219
- title: page.title,
220
- ...page.description && { description: page.description },
221
- images: [url]
222
- };
223
- }
224
-
225
- //#endregion
226
- export { buildPageOpenGraph, buildPageTwitter, createTheme, deepMerge, defineDocs, extendTheme, resolveDocsI18n, resolveDocsLocale, resolveDocsPath, resolveOGImage, resolveTitle };
package/dist/server.d.mts DELETED
@@ -1,38 +0,0 @@
1
- import { o as DocsConfig } from "./types-DpijZMth.mjs";
2
-
3
- //#region src/api-reference.d.ts
4
- type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
5
- type ApiReferenceFramework = "next" | "tanstack-start" | "sveltekit" | "astro" | "nuxt";
6
- interface ApiReferenceRoute {
7
- title: string;
8
- summary: string;
9
- description?: string;
10
- routePath: string;
11
- sourceFile: string;
12
- methods: HttpMethod[];
13
- tag: string;
14
- parameters: Array<Record<string, unknown>>;
15
- }
16
- interface ResolvedApiReferenceConfig {
17
- enabled: boolean;
18
- path: string;
19
- specUrl?: string;
20
- routeRoot: string;
21
- exclude: string[];
22
- }
23
- interface BuildApiReferenceOptions {
24
- framework: ApiReferenceFramework;
25
- rootDir?: string;
26
- }
27
- interface BuildApiReferenceHtmlOptions extends BuildApiReferenceOptions {
28
- title?: string;
29
- }
30
- declare function resolveApiReferenceConfig(value: DocsConfig["apiReference"]): ResolvedApiReferenceConfig;
31
- declare function buildApiReferencePageTitle(config: DocsConfig, title?: string): string;
32
- declare function buildApiReferenceScalarCss(config: DocsConfig): string;
33
- declare function buildApiReferenceOpenApiDocument(config: DocsConfig, options: BuildApiReferenceOptions): Record<string, unknown>;
34
- declare function buildApiReferenceOpenApiDocumentAsync(config: DocsConfig, options: BuildApiReferenceOptions): Promise<Record<string, unknown>>;
35
- declare function buildApiReferenceHtmlDocument(config: DocsConfig, options: BuildApiReferenceHtmlOptions): string;
36
- declare function buildApiReferenceHtmlDocumentAsync(config: DocsConfig, options: BuildApiReferenceHtmlOptions): Promise<string>;
37
- //#endregion
38
- export { type ApiReferenceFramework, type ApiReferenceRoute, type ResolvedApiReferenceConfig, buildApiReferenceHtmlDocument, buildApiReferenceHtmlDocumentAsync, buildApiReferenceOpenApiDocument, buildApiReferenceOpenApiDocumentAsync, buildApiReferencePageTitle, buildApiReferenceScalarCss, resolveApiReferenceConfig };