onedocs 0.1.0 → 0.1.2
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.js +56 -1
- package/dist/llms/index.d.ts +32 -4
- package/dist/llms/index.js +26 -0
- package/package.json +9 -7
package/dist/index.js
CHANGED
|
@@ -14,9 +14,64 @@ import {
|
|
|
14
14
|
|
|
15
15
|
// src/layouts/root.tsx
|
|
16
16
|
import { RootProvider } from "fumadocs-ui/provider/tanstack";
|
|
17
|
+
import { FrameworkProvider } from "fumadocs-core/framework";
|
|
18
|
+
import {
|
|
19
|
+
Link,
|
|
20
|
+
useParams,
|
|
21
|
+
useRouter,
|
|
22
|
+
useRouterState
|
|
23
|
+
} from "@tanstack/react-router";
|
|
24
|
+
import { useMemo, useRef } from "react";
|
|
17
25
|
import { jsx } from "react/jsx-runtime";
|
|
18
26
|
function RootLayout({ children }) {
|
|
19
|
-
return /* @__PURE__ */ jsx(
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
FrameworkProvider,
|
|
29
|
+
{
|
|
30
|
+
Link: FrameworkLink,
|
|
31
|
+
usePathname,
|
|
32
|
+
useRouter: useFrameworkRouter,
|
|
33
|
+
useParams: useFrameworkParams,
|
|
34
|
+
children: /* @__PURE__ */ jsx(RootProvider, { children })
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function FrameworkLink({
|
|
39
|
+
href,
|
|
40
|
+
prefetch = true,
|
|
41
|
+
...props
|
|
42
|
+
}) {
|
|
43
|
+
return /* @__PURE__ */ jsx(Link, { to: href ?? "#", preload: prefetch ? "intent" : false, ...props, children: props.children });
|
|
44
|
+
}
|
|
45
|
+
function usePathname() {
|
|
46
|
+
const { isLoading, pathname } = useRouterState({
|
|
47
|
+
select: (state) => ({
|
|
48
|
+
isLoading: state.isLoading,
|
|
49
|
+
pathname: state.location.pathname
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
const activePathname = useRef(pathname);
|
|
53
|
+
return useMemo(() => {
|
|
54
|
+
if (isLoading) return activePathname.current;
|
|
55
|
+
activePathname.current = pathname;
|
|
56
|
+
return pathname;
|
|
57
|
+
}, [isLoading, pathname]);
|
|
58
|
+
}
|
|
59
|
+
function useFrameworkRouter() {
|
|
60
|
+
const router = useRouter();
|
|
61
|
+
return useMemo(
|
|
62
|
+
() => ({
|
|
63
|
+
push(url) {
|
|
64
|
+
router.navigate({ href: url });
|
|
65
|
+
},
|
|
66
|
+
refresh() {
|
|
67
|
+
router.invalidate();
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
[router]
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function useFrameworkParams() {
|
|
74
|
+
return useParams({ strict: false });
|
|
20
75
|
}
|
|
21
76
|
|
|
22
77
|
// src/layouts/docs.tsx
|
package/dist/llms/index.d.ts
CHANGED
|
@@ -15,15 +15,43 @@ interface Page {
|
|
|
15
15
|
getText?: (type: string) => Promise<string>;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
18
|
+
interface LLMsSource {
|
|
19
19
|
getPages: () => Page[];
|
|
20
20
|
}
|
|
21
|
+
type FumadocsPageData = {
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
getText?: (type: "raw" | "processed") => Promise<string>;
|
|
25
|
+
load?: () => Promise<unknown>;
|
|
26
|
+
};
|
|
27
|
+
type FumadocsPage = {
|
|
28
|
+
url: string;
|
|
29
|
+
slugs: string[];
|
|
30
|
+
data: FumadocsPageData;
|
|
31
|
+
};
|
|
32
|
+
declare function createLLMsSource(source: {
|
|
33
|
+
getPages: () => FumadocsPage[];
|
|
34
|
+
}): {
|
|
35
|
+
getPages: () => {
|
|
36
|
+
url: string;
|
|
37
|
+
data: {
|
|
38
|
+
title: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
load?: () => Promise<{
|
|
41
|
+
structuredData?: {
|
|
42
|
+
content?: string;
|
|
43
|
+
};
|
|
44
|
+
}>;
|
|
45
|
+
getText?: (type: string) => Promise<string>;
|
|
46
|
+
};
|
|
47
|
+
}[];
|
|
48
|
+
};
|
|
21
49
|
declare function getLLMText(page: Page): Promise<string>;
|
|
22
|
-
declare function createLLMsHandler(source:
|
|
50
|
+
declare function createLLMsHandler(source: LLMsSource, config: LLMsConfig): {
|
|
23
51
|
GET: () => Promise<Response>;
|
|
24
52
|
};
|
|
25
|
-
declare function createLLMsFullHandler(source:
|
|
53
|
+
declare function createLLMsFullHandler(source: LLMsSource): {
|
|
26
54
|
GET: () => Promise<Response>;
|
|
27
55
|
};
|
|
28
56
|
|
|
29
|
-
export { type LLMsConfig, createLLMsFullHandler, createLLMsHandler, getLLMText };
|
|
57
|
+
export { type LLMsConfig, type LLMsSource, createLLMsFullHandler, createLLMsHandler, createLLMsSource, getLLMText };
|
package/dist/llms/index.js
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
// src/llms/index.ts
|
|
2
|
+
function toLLMPageData(data, fallbackTitle) {
|
|
3
|
+
const getText = data.getText;
|
|
4
|
+
const load = data.load ? async () => {
|
|
5
|
+
const loaded = await data.load?.();
|
|
6
|
+
const structuredData = typeof loaded === "object" && loaded !== null ? loaded.structuredData : void 0;
|
|
7
|
+
return structuredData ? { structuredData } : {};
|
|
8
|
+
} : void 0;
|
|
9
|
+
return {
|
|
10
|
+
title: data.title ?? fallbackTitle,
|
|
11
|
+
description: data.description,
|
|
12
|
+
getText: getText ? (type) => getText(type) : void 0,
|
|
13
|
+
load
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function createLLMsSource(source) {
|
|
17
|
+
return {
|
|
18
|
+
getPages: () => source.getPages().map((page) => ({
|
|
19
|
+
url: page.url,
|
|
20
|
+
data: toLLMPageData(
|
|
21
|
+
page.data,
|
|
22
|
+
page.slugs[page.slugs.length - 1] ?? page.url
|
|
23
|
+
)
|
|
24
|
+
}))
|
|
25
|
+
};
|
|
26
|
+
}
|
|
2
27
|
async function getLLMText(page) {
|
|
3
28
|
let text = "";
|
|
4
29
|
if (page.data.getText) {
|
|
@@ -75,5 +100,6 @@ function createLLMsFullHandler(source) {
|
|
|
75
100
|
export {
|
|
76
101
|
createLLMsFullHandler,
|
|
77
102
|
createLLMsHandler,
|
|
103
|
+
createLLMsSource,
|
|
78
104
|
getLLMText
|
|
79
105
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onedocs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Zero-config documentation for TanStack Start + Fumadocs. Install one dependency, write markdown, ship docs.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -66,15 +66,13 @@
|
|
|
66
66
|
"test": "bun test",
|
|
67
67
|
"prepack": "bun run build"
|
|
68
68
|
},
|
|
69
|
-
"dependencies": {
|
|
70
|
-
"fumadocs-core": "^16.4.7",
|
|
71
|
-
"fumadocs-mdx": "^14.2.5",
|
|
72
|
-
"fumadocs-ui": "^16.4.7",
|
|
73
|
-
"lucide-react": "^0.562.0"
|
|
74
|
-
},
|
|
75
69
|
"peerDependencies": {
|
|
76
70
|
"@tanstack/react-router": "^1.0.0",
|
|
77
71
|
"@tanstack/start": "^1.0.0",
|
|
72
|
+
"fumadocs-core": "^16.4.7",
|
|
73
|
+
"fumadocs-mdx": "^14.2.5",
|
|
74
|
+
"fumadocs-ui": "^16.4.7",
|
|
75
|
+
"lucide-react": "^0.562.0",
|
|
78
76
|
"react": "^18.0.0 || ^19.0.0",
|
|
79
77
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
80
78
|
},
|
|
@@ -84,7 +82,11 @@
|
|
|
84
82
|
"@types/bun": "^1.3.6",
|
|
85
83
|
"@types/react": "^19.2.8",
|
|
86
84
|
"@types/react-dom": "^19.2.3",
|
|
85
|
+
"fumadocs-core": "^16.4.7",
|
|
86
|
+
"fumadocs-mdx": "^14.2.5",
|
|
87
|
+
"fumadocs-ui": "^16.4.7",
|
|
87
88
|
"jsdom": "^27.4.0",
|
|
89
|
+
"lucide-react": "^0.562.0",
|
|
88
90
|
"tsup": "^8.5.1",
|
|
89
91
|
"typescript": "^5.9.3"
|
|
90
92
|
}
|