@cyguin/docs 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/.github/workflows/publish.yml +27 -0
- package/LICENSE +7 -0
- package/README.md +152 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +438 -0
- package/dist/index.mjs +438 -0
- package/dist/next.d.mts +10 -0
- package/dist/next.d.ts +10 -0
- package/dist/next.js +53 -0
- package/dist/next.mjs +53 -0
- package/dist/styles.css +11 -0
- package/dist/types-0oOQLVHA.d.mts +52 -0
- package/dist/types-0oOQLVHA.d.ts +52 -0
- package/package.json +46 -0
- package/src/adapters/index.ts +1 -0
- package/src/adapters/sqlite.ts +95 -0
- package/src/app/admin/docs/[...route]/route.ts +31 -0
- package/src/app/api/docs/[...cyguin]/route.ts +10 -0
- package/src/components/DocsWidget.tsx +521 -0
- package/src/components/index.ts +2 -0
- package/src/handlers/admin.ts +89 -0
- package/src/handlers/route.ts +70 -0
- package/src/index.ts +5 -0
- package/src/next.ts +3 -0
- package/src/styles.css +11 -0
- package/src/types.ts +62 -0
- package/tsconfig.json +18 -0
- package/tsup.config.ts +12 -0
package/src/styles.css
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--cyguin-docs-bg: var(--cyguin-bg, #ffffff);
|
|
3
|
+
--cyguin-docs-text: var(--cyguin-fg, #0a0a0a);
|
|
4
|
+
--cyguin-docs-border: var(--cyguin-border, #e5e5e5);
|
|
5
|
+
--cyguin-docs-accent: var(--cyguin-accent, #f5a800);
|
|
6
|
+
--cyguin-docs-muted: var(--cyguin-fg-muted, #888888);
|
|
7
|
+
--cyguin-docs-backdrop-opacity: 0.5;
|
|
8
|
+
--cyguin-docs-radius: var(--cyguin-radius, 6px);
|
|
9
|
+
--cyguin-docs-shadow: var(--cyguin-shadow, 0 1px 4px rgba(0,0,0,0.08));
|
|
10
|
+
--cyguin-docs-font: system-ui, sans-serif;
|
|
11
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export interface DocArticle {
|
|
2
|
+
id: string
|
|
3
|
+
title: string
|
|
4
|
+
body_md: string
|
|
5
|
+
section: string
|
|
6
|
+
article_order: number
|
|
7
|
+
published_at: number | null
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CreateArticleInput {
|
|
11
|
+
title: string
|
|
12
|
+
body_md: string
|
|
13
|
+
section: string
|
|
14
|
+
article_order: number
|
|
15
|
+
published_at?: number | null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface UpdateArticleInput {
|
|
19
|
+
title?: string
|
|
20
|
+
body_md?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface DocsAdapter {
|
|
24
|
+
list(params?: { section?: string; published?: boolean }): Promise<DocArticle[]>
|
|
25
|
+
get(id: string): Promise<DocArticle | null>
|
|
26
|
+
create(data: CreateArticleInput): Promise<DocArticle>
|
|
27
|
+
update(id: string, data: Partial<UpdateArticleInput>): Promise<DocArticle>
|
|
28
|
+
delete(id: string): Promise<void>
|
|
29
|
+
reorder(id: string, newOrder: number): Promise<void>
|
|
30
|
+
moveSection(id: string, newSection: string): Promise<void>
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface DocsHandlerOptions {
|
|
34
|
+
adapter?: DocsAdapter
|
|
35
|
+
secret?: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type NextHandler = (
|
|
39
|
+
req: Request,
|
|
40
|
+
context?: { params?: Record<string, string | string[]> }
|
|
41
|
+
) => Promise<Response>
|
|
42
|
+
|
|
43
|
+
export interface DocsWidgetProps {
|
|
44
|
+
apiUrl?: string
|
|
45
|
+
mode?: 'modal' | 'sidebar'
|
|
46
|
+
triggerLabel?: string
|
|
47
|
+
defaultOpen?: boolean
|
|
48
|
+
className?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const defaultCssVars = {
|
|
52
|
+
'--cyguin-docs-bg': 'var(--cyguin-surface, #ffffff)',
|
|
53
|
+
'--cyguin-docs-text': 'var(--cyguin-text, #1a1a1a)',
|
|
54
|
+
'--cyguin-docs-border': 'var(--cyguin-border, #e5e5e5)',
|
|
55
|
+
'--cyguin-docs-accent': 'var(--cyguin-primary, #6366f1)',
|
|
56
|
+
'--cyguin-docs-muted': 'var(--cyguin-muted, #737373)',
|
|
57
|
+
'--cyguin-docs-backdrop-opacity': '0.5',
|
|
58
|
+
'--cyguin-docs-radius': 'var(--cyguin-radius, 8px)',
|
|
59
|
+
'--cyguin-docs-shadow': 'var(--cyguin-shadow, 0 4px 24px rgba(0,0,0,0.12))',
|
|
60
|
+
'--cyguin-docs-trigger-size': '48px',
|
|
61
|
+
'--cyguin-docs-font': 'var(--cyguin-font, system-ui, sans-serif)',
|
|
62
|
+
} as const
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"jsx": "react-jsx",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"rootDir": "./src",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/**/*"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|
package/tsup.config.ts
ADDED