@nendlabs/docpage 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,142 @@
1
+ # @nendlabs/docpage
2
+
3
+ a config-first, interactive paper-style project page renderer for nendlabs.
4
+
5
+ it ships fully compiled styles, so consumers only need one css import.
6
+
7
+ ### install
8
+
9
+ use your package manager of choice:
10
+
11
+ ```bash
12
+ npm install @nendlabs/docpage
13
+ ```
14
+
15
+ ```bash
16
+ bun add @nendlabs/docpage
17
+ ```
18
+
19
+ ### quick start
20
+
21
+ import the styles once near your app root:
22
+
23
+ ```ts
24
+ import "@nendlabs/docpage/styles.css";
25
+ ```
26
+
27
+ render a page from a typed config:
28
+
29
+ ```tsx
30
+ import { DocPage, type DocPageConfig } from "@nendlabs/docpage";
31
+
32
+ const CONFIG: DocPageConfig = {
33
+ brand: { name: "nendlabs" },
34
+ header: {
35
+ title: "a project page",
36
+ subtitle: "how we built it",
37
+ },
38
+ toc: [
39
+ { id: "abstract", label: "abstract" },
40
+ { id: "api", label: "api" },
41
+ ],
42
+ sections: [
43
+ {
44
+ kind: "prose",
45
+ id: "abstract",
46
+ titleBorder: true,
47
+ blocks: [
48
+ { kind: "p", text: "we start with the concept and work backward." },
49
+ {
50
+ kind: "ul",
51
+ items: [
52
+ "derive signals from raw events",
53
+ "compress context with retrieval",
54
+ "reason over multi-day windows",
55
+ ],
56
+ },
57
+ ],
58
+ },
59
+ {
60
+ kind: "api",
61
+ id: "api",
62
+ intro: "a tiny example with tabs.",
63
+ tabs: [
64
+ {
65
+ id: "curl",
66
+ language: "bash",
67
+ code: "curl https://example.com/v1/events",
68
+ },
69
+ {
70
+ id: "ts",
71
+ label: "typescript",
72
+ language: "typescript",
73
+ code: "client.event(\"user.login\", { userId: \"123\" })",
74
+ },
75
+ ],
76
+ },
77
+ ],
78
+ footer: { copyrightName: "nendlabs" },
79
+ };
80
+
81
+ export default function ProjectPage() {
82
+ return <DocPage config={CONFIG} />;
83
+ }
84
+ ```
85
+
86
+ ### requirements
87
+
88
+ - react and react-dom are peer dependencies (react 18+ recommended)
89
+ - mdx sections require your host app to compile mdx into react components
90
+
91
+ ### mdx sections
92
+
93
+ the renderer is config-first, but mdx is supported via `kind: "mdx"` sections.
94
+
95
+ ```tsx
96
+ import type { DocPageConfig } from "@nendlabs/docpage";
97
+ import AbstractSection from "./sections/abstract.mdx";
98
+
99
+ const CONFIG: DocPageConfig = {
100
+ brand: { name: "nendlabs" },
101
+ header: { title: "mdx section example" },
102
+ sections: [
103
+ {
104
+ kind: "mdx",
105
+ id: "abstract",
106
+ titleBorder: true,
107
+ Component: AbstractSection,
108
+ },
109
+ ],
110
+ };
111
+ ```
112
+
113
+ code fences inside mdx are automatically rendered through the shared highlighted code block.
114
+
115
+ ### styling model
116
+
117
+ consumers only need this import:
118
+
119
+ ```ts
120
+ import "@nendlabs/docpage/styles.css";
121
+ ```
122
+
123
+ this package compiles its own tailwind classes into the shipped css.
124
+
125
+ important note about custom classes:
126
+
127
+ - classes used inside this package are included in the shipped css
128
+ - classes that only appear in your mdx or custom nodes are not guaranteed to exist
129
+ - if you want arbitrary tailwind classes in your content, also run tailwind in the host app
130
+
131
+ ### config reference
132
+
133
+ sections are discriminated by `kind`:
134
+
135
+ - `kind: "prose"` with `blocks`
136
+ - `kind: "api"` with `tabs`
137
+ - `kind: "mdx"` with a compiled `Component`
138
+
139
+ for the concrete shapes, see:
140
+
141
+ - `src/types.ts`
142
+ - `playground/src/logst-config.tsx`