onedocs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ interface LLMsConfig {
2
+ title: string;
3
+ description?: string;
4
+ }
5
+ interface Page {
6
+ url: string;
7
+ data: {
8
+ title: string;
9
+ description?: string;
10
+ load?: () => Promise<{
11
+ structuredData?: {
12
+ content?: string;
13
+ };
14
+ }>;
15
+ getText?: (type: string) => Promise<string>;
16
+ };
17
+ }
18
+ interface Source {
19
+ getPages: () => Page[];
20
+ }
21
+ declare function getLLMText(page: Page): Promise<string>;
22
+ declare function createLLMsHandler(source: Source, config: LLMsConfig): {
23
+ GET: () => Promise<Response>;
24
+ };
25
+ declare function createLLMsFullHandler(source: Source): {
26
+ GET: () => Promise<Response>;
27
+ };
28
+
29
+ export { type LLMsConfig, createLLMsFullHandler, createLLMsHandler, getLLMText };
@@ -0,0 +1,79 @@
1
+ // src/llms/index.ts
2
+ async function getLLMText(page) {
3
+ let text = "";
4
+ if (page.data.getText) {
5
+ try {
6
+ text = await page.data.getText("processed");
7
+ } catch {
8
+ }
9
+ }
10
+ if (!text && page.data.load) {
11
+ try {
12
+ const content = await page.data.load();
13
+ text = content?.structuredData?.content || "";
14
+ } catch {
15
+ }
16
+ }
17
+ return `# ${page.data.title}
18
+ URL: ${page.url}
19
+ ${page.data.description ? `
20
+ ${page.data.description}
21
+ ` : ""}
22
+ ${text}`;
23
+ }
24
+ function sortPages(pages) {
25
+ return [...pages].sort((a, b) => {
26
+ const aDepth = a.url.split("/").length;
27
+ const bDepth = b.url.split("/").length;
28
+ if (aDepth !== bDepth) return aDepth - bDepth;
29
+ return a.url.localeCompare(b.url);
30
+ });
31
+ }
32
+ function createLLMsHandler(source, config) {
33
+ return {
34
+ GET: async () => {
35
+ const pages = sortPages(source.getPages());
36
+ const lines = [
37
+ `# ${config.title}`,
38
+ "",
39
+ config.description ? `${config.description}
40
+ ` : "",
41
+ "## Pages",
42
+ ""
43
+ ];
44
+ for (const page of pages) {
45
+ lines.push(`- ${page.data.title}: ${page.url}`);
46
+ if (page.data.description) {
47
+ lines.push(` ${page.data.description}`);
48
+ }
49
+ }
50
+ lines.push("");
51
+ lines.push("## Full Content");
52
+ lines.push("");
53
+ lines.push("For full documentation content, see /llms-full.txt");
54
+ return new Response(lines.join("\n"), {
55
+ headers: {
56
+ "Content-Type": "text/plain; charset=utf-8"
57
+ }
58
+ });
59
+ }
60
+ };
61
+ }
62
+ function createLLMsFullHandler(source) {
63
+ return {
64
+ GET: async () => {
65
+ const pages = sortPages(source.getPages());
66
+ const contents = await Promise.all(pages.map(getLLMText));
67
+ return new Response(contents.join("\n\n---\n\n"), {
68
+ headers: {
69
+ "Content-Type": "text/plain; charset=utf-8"
70
+ }
71
+ });
72
+ }
73
+ };
74
+ }
75
+ export {
76
+ createLLMsFullHandler,
77
+ createLLMsHandler,
78
+ getLLMText
79
+ };
@@ -0,0 +1,11 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ interface LogoProps {
4
+ light: string;
5
+ dark: string;
6
+ alt?: string;
7
+ className?: string;
8
+ }
9
+ declare function Logo({ light, dark, alt, className }: LogoProps): react_jsx_runtime.JSX.Element;
10
+
11
+ export { Logo as L };
@@ -0,0 +1,14 @@
1
+ import * as fumadocs_core_source from 'fumadocs-core/source';
2
+ export { loader } from 'fumadocs-core/source';
3
+
4
+ interface CreateSourceOptions {
5
+ baseUrl?: string;
6
+ }
7
+ declare function createSource(docsSource: {
8
+ toFumadocsSource: () => any;
9
+ }, options?: CreateSourceOptions): fumadocs_core_source.LoaderOutput<{
10
+ source: fumadocs_core_source.SourceConfig;
11
+ i18n: undefined;
12
+ }>;
13
+
14
+ export { type CreateSourceOptions, createSource };
@@ -0,0 +1,8 @@
1
+ import {
2
+ createSource,
3
+ loader
4
+ } from "../chunk-EKYRMBZ6.js";
5
+ export {
6
+ createSource,
7
+ loader
8
+ };
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "onedocs",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Zero-config documentation for TanStack Start + Fumadocs. Install one dependency, write markdown, ship docs.",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/inline0/onedocs.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/inline0/onedocs/issues"
13
+ },
14
+ "homepage": "https://github.com/inline0/onedocs#readme",
15
+ "keywords": [
16
+ "documentation",
17
+ "docs",
18
+ "tanstack",
19
+ "tanstack-start",
20
+ "fumadocs",
21
+ "mdx",
22
+ "markdown",
23
+ "react"
24
+ ],
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js"
31
+ },
32
+ "./components": {
33
+ "types": "./dist/components/index.d.ts",
34
+ "import": "./dist/components/index.js"
35
+ },
36
+ "./config": {
37
+ "types": "./dist/config.d.ts",
38
+ "import": "./dist/config.js"
39
+ },
40
+ "./source": {
41
+ "types": "./dist/source/index.d.ts",
42
+ "import": "./dist/source/index.js"
43
+ },
44
+ "./llms": {
45
+ "types": "./dist/llms/index.d.ts",
46
+ "import": "./dist/llms/index.js"
47
+ },
48
+ "./css/preset.css": "./src/css/preset.css"
49
+ },
50
+ "files": [
51
+ "dist",
52
+ "src/css",
53
+ "src/fonts",
54
+ "README.md",
55
+ "LICENSE"
56
+ ],
57
+ "publishConfig": {
58
+ "access": "public"
59
+ },
60
+ "engines": {
61
+ "node": ">=18"
62
+ },
63
+ "scripts": {
64
+ "build": "tsup",
65
+ "dev": "tsup --watch",
66
+ "test": "bun test",
67
+ "prepack": "bun run build"
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
+ "peerDependencies": {
76
+ "@tanstack/react-router": "^1.0.0",
77
+ "@tanstack/start": "^1.0.0",
78
+ "react": "^18.0.0 || ^19.0.0",
79
+ "react-dom": "^18.0.0 || ^19.0.0"
80
+ },
81
+ "devDependencies": {
82
+ "@onedocs/tsconfig": "workspace:*",
83
+ "@testing-library/react": "^16.3.1",
84
+ "@types/bun": "^1.3.6",
85
+ "@types/react": "^19.2.8",
86
+ "@types/react-dom": "^19.2.3",
87
+ "jsdom": "^27.4.0",
88
+ "tsup": "^8.5.1",
89
+ "typescript": "^5.9.3"
90
+ }
91
+ }
@@ -0,0 +1,48 @@
1
+ @import "tailwindcss";
2
+ @import "fumadocs-ui/css/neutral.css";
3
+ @import "fumadocs-ui/css/preset.css";
4
+
5
+ @source "../../dist/**/*.js";
6
+
7
+ @font-face {
8
+ font-family: "Inter Variable";
9
+ font-style: normal;
10
+ font-weight: 100 900;
11
+ font-display: swap;
12
+ src: url("../fonts/InterVariable.woff2") format("woff2-variations");
13
+ }
14
+
15
+ @theme {
16
+ --font-sans: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
17
+ }
18
+
19
+ @layer base {
20
+ html,
21
+ body,
22
+ #nd-home-layout {
23
+ height: 100%;
24
+ }
25
+
26
+ body {
27
+ font-feature-settings: "calt" 1, "cv02" 1, "cv03" 1, "cv04" 1, "cv11" 1, "ss08" 1;
28
+ }
29
+
30
+ h1,
31
+ h2,
32
+ h3,
33
+ h4,
34
+ h5,
35
+ h6 {
36
+ font-feature-settings: "calt" 1, "cv02" 1, "cv03" 1, "cv04" 1, "cv11" 1, "ss07" 1, "ss08" 1, "dlig" 1;
37
+ }
38
+
39
+ #nd-home-layout > header > div:first-child {
40
+ @apply mx-auto max-w-(--fd-layout-width) border-x;
41
+ }
42
+
43
+ @media (min-width: 1024px) {
44
+ [data-orientation="horizontal"] > ul:last-child {
45
+ display: none !important;
46
+ }
47
+ }
48
+ }