@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.
- package/README.md +142 -0
- package/README.repo.md +68 -0
- package/dist/cn.d.ts +3 -0
- package/dist/cn.d.ts.map +1 -0
- package/dist/components/api-tabs.d.ts +9 -0
- package/dist/components/api-tabs.d.ts.map +1 -0
- package/dist/components/code-block.d.ts +11 -0
- package/dist/components/code-block.d.ts.map +1 -0
- package/dist/components/mermaid.d.ts +4 -0
- package/dist/components/mermaid.d.ts.map +1 -0
- package/dist/docpage.d.ts +9 -0
- package/dist/docpage.d.ts.map +1 -0
- package/dist/hooks/use-active-scroll-section-ids.d.ts +8 -0
- package/dist/hooks/use-active-scroll-section-ids.d.ts.map +1 -0
- package/dist/hooks/use-color-scheme.d.ts +4 -0
- package/dist/hooks/use-color-scheme.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +832 -0
- package/dist/package.md +142 -0
- package/dist/styles/docpage.css +1002 -0
- package/dist/types.d.ts +162 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +72 -0
- package/styles/docpage-theme.css +162 -0
- package/styles/tailwind.css +5 -0
package/README.md
ADDED
|
@@ -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`
|
package/README.repo.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @nendlabs/docpage repo
|
|
2
|
+
|
|
3
|
+
this repository contains the `@nendlabs/docpage` package, its playground, and internal docs.
|
|
4
|
+
|
|
5
|
+
### repository overview
|
|
6
|
+
|
|
7
|
+
key paths:
|
|
8
|
+
|
|
9
|
+
- `src/`: the package source
|
|
10
|
+
- `styles/`: tailwind entry + theme tokens
|
|
11
|
+
- `playground/`: local app to preview configs
|
|
12
|
+
- `docs/`: deeper documentation and publishing notes
|
|
13
|
+
- `.github/workflows/`: ci and main-branch publishing
|
|
14
|
+
|
|
15
|
+
### npm readme behavior
|
|
16
|
+
|
|
17
|
+
npm always reads `README.md` at publish time.
|
|
18
|
+
|
|
19
|
+
to keep this repo readme maintainer-focused while shipping a package-focused npm readme:
|
|
20
|
+
|
|
21
|
+
- `docs/package.md` is the source of truth for the npm readme
|
|
22
|
+
- `prepack` copies `docs/package.md` into `README.md`
|
|
23
|
+
- `postpack` restores the original `README.md`
|
|
24
|
+
|
|
25
|
+
relevant scripts:
|
|
26
|
+
|
|
27
|
+
- `bun run readme:package`
|
|
28
|
+
- `bun run readme:restore`
|
|
29
|
+
- `bun run build`
|
|
30
|
+
|
|
31
|
+
### development
|
|
32
|
+
|
|
33
|
+
install and run the playground:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bun install
|
|
37
|
+
bun run dev
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
run local validation:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun run typecheck
|
|
44
|
+
bun run test
|
|
45
|
+
bun run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### docs
|
|
49
|
+
|
|
50
|
+
deeper documentation lives under `docs/`:
|
|
51
|
+
|
|
52
|
+
- `docs/authoring.md`
|
|
53
|
+
- `docs/mdx.md`
|
|
54
|
+
- `docs/publishing.md`
|
|
55
|
+
- `docs/package.md`
|
|
56
|
+
|
|
57
|
+
### release flow
|
|
58
|
+
|
|
59
|
+
publishing is automated on pushes to `main`.
|
|
60
|
+
|
|
61
|
+
high level:
|
|
62
|
+
|
|
63
|
+
1. open a pr into `main`
|
|
64
|
+
2. bump `package.json` version in the pr
|
|
65
|
+
3. merge to `main`
|
|
66
|
+
4. ci validates and the publish workflow runs `npm publish`
|
|
67
|
+
|
|
68
|
+
see `docs/publishing.md` for details.
|
package/dist/cn.d.ts
ADDED
package/dist/cn.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../src/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAG7C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DocApiTab } from "../types";
|
|
2
|
+
type ApiTabsProps = {
|
|
3
|
+
tabs: DocApiTab[];
|
|
4
|
+
defaultTabId?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function ApiTabs({ tabs, defaultTabId, className }: ApiTabsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=api-tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-tabs.d.ts","sourceRoot":"","sources":["../../src/components/api-tabs.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAcF,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,YAAY,kDA0CtE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type CodeBlockProps = {
|
|
2
|
+
code: string;
|
|
3
|
+
language?: string;
|
|
4
|
+
caption?: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
preClassName?: string;
|
|
7
|
+
codeClassName?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function CodeBlock({ code, language, caption, className, preClassName, codeClassName, }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=code-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../src/components/code-block.tsx"],"names":[],"mappings":"AAWA,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAoBF,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,YAAY,EACZ,aAAa,GACd,EAAE,cAAc,2CAwChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid.d.ts","sourceRoot":"","sources":["../../src/components/mermaid.tsx"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,2CA8CnD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import type { DocPageProps } from "./types";
|
|
3
|
+
type MdxPreProps = HTMLAttributes<HTMLPreElement> & {
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export declare function MdxCodeBlockPre(props: MdxPreProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function DocPage({ config, className }: DocPageProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=docpage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docpage.d.ts","sourceRoot":"","sources":["../src/docpage.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,cAAc,EAEnB,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAKV,YAAY,EAIb,MAAM,SAAS,CAAC;AA6OjB,KAAK,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAClD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAiBF,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,2CAmBjD;AAqPD,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,YAAY,2CAiD1D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Options = {
|
|
2
|
+
rootMargin?: string;
|
|
3
|
+
threshold?: number | number[];
|
|
4
|
+
syncToUrl?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function useActiveScrollSectionIds(ids: string[], options?: Options): string;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=use-active-scroll-section-ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-active-scroll-section-ids.d.ts","sourceRoot":"","sources":["../../src/hooks/use-active-scroll-section-ids.tsx"],"names":[],"mappings":"AAEA,KAAK,OAAO,GAAG;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAUF,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,UA0CzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-color-scheme.d.ts","sourceRoot":"","sources":["../../src/hooks/use-color-scheme.tsx"],"names":[],"mappings":"AAEA,KAAK,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAS/B,wBAAgB,cAAc,IAAI,MAAM,CAmBvC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { cn } from "./cn";
|
|
2
|
+
export { DocPage, MdxCodeBlockPre } from "./docpage";
|
|
3
|
+
export { ApiTabs } from "./components/api-tabs";
|
|
4
|
+
export { CodeBlock } from "./components/code-block";
|
|
5
|
+
export { Mermaid } from "./components/mermaid";
|
|
6
|
+
export { useActiveScrollSectionIds } from "./hooks/use-active-scroll-section-ids";
|
|
7
|
+
export { useColorScheme } from "./hooks/use-color-scheme";
|
|
8
|
+
export type { DocApiSection, DocApiTab, DocBlock, DocBrand, DocCalloutBlock, DocCalloutTone, DocFooter, DocFooterLink, DocHeader, DocListBlock, DocLabeledListBlock, DocMdxSection, DocOptions, DocPageConfig, DocPageProps, DocParagraphBlock, DocPreBlock, DocProseSection, DocSection, DocSectionBase, DocTheme, DocThemeTokens, DocTocEntry, } from "./types";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,YAAY,EACV,aAAa,EACb,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,UAAU,EACV,cAAc,EACd,QAAQ,EACR,cAAc,EACd,WAAW,GACZ,MAAM,SAAS,CAAC"}
|