Skip to content
This repository was archived by the owner on Aug 14, 2026. It is now read-only.

Repository files navigation

This package is no longer actively maintained. cyguin has narrowed focus to security research (PSCryptoPatterns, PSCertPatterns, PSCMSPatterns). Existing published versions remain on npm and MIT-licensed, but no further releases are planned. See cyguin.com for current work.

@cyguin/docs

Embeddable help and documentation widget for Next.js. Searchable, markdown-backed docs in a modal or sidebar — no external service needed.

Quickstart

npm install @cyguin/docs

1. Add the widget to your app

// app/layout.tsx (or any page)import{DocsWidget}from'@cyguin/docs';import'@cyguin/docs/styles.css';exportdefaultfunctionRootLayout({ children }: {children: React.ReactNode}){return(<html><body>{children}<DocsWidgetapiUrl="/api/docs"mode="modal"triggerLabel="Help"/></body></html>);}

2. Wire up the API route

// app/api/docs/[...cyguin]/route.tsimport{createDocsHandler}from'@cyguin/docs/next';import{createSQLiteAdapter}from'@cyguin/docs/adapters/sqlite';constadapter=createSQLiteAdapter({path: './docs.db'});exportconstGET=createDocsHandler({ adapter });

3. Wire up the admin route

// app/api/admin/docs/[...route]/route.tsimport{createAdminHandler}from'@cyguin/docs/next';import{createSQLiteAdapter}from'@cyguin/docs/adapters/sqlite';constadapter=createSQLiteAdapter({path: './docs.db'});consthandler=createAdminHandler({
adapter,secret: process.env.DOCS_ADMIN_SECRET,});export{handlerasPOST,handlerasPUT,handlerasPATCH,handlerasDELETE};

DOCS_ADMIN_SECRET is required. Admin routes fail closed without it.

4. Seed some articles

import{createDocsHandler}from'@cyguin/docs/next';import{createSQLiteAdapter}from'@cyguin/docs/adapters/sqlite';constadapter=createSQLiteAdapter({path: './docs.db'});consthandler=createDocsHandler({ adapter });awaithandler.request(newRequest('http://localhost/admin/docs',{method: 'POST',headers: {Authorization: 'Bearer your-secret','Content-Type': 'application/json'},body: JSON.stringify({title: 'Getting Started',body_md: '# Getting Started\n\nWelcome to **My App**!',section: 'Introduction',article_order: 1,}),}));

Modes

Modal (default)

Floating corner button opens a centered overlay. Click the backdrop or press Esc to close.

<DocsWidgetmode="modal"triggerLabel="Help"/>

Sidebar

Panel slides in from the right — good for persistent help panels.

<DocsWidgetmode="sidebar"triggerLabel="Docs"/>

Props

PropTypeDefaultDescription
apiUrlstring"/api/docs"Endpoint returning article list
mode"modal" | "sidebar""modal"Modal or sidebar
triggerLabelstring"Help"Label on the floating trigger button
defaultOpenbooleanfalseOpen on mount
classNamestring""CSS class on root element

API Contract

The apiUrl endpoint must return a JSON array of articles:

[
{
"id": "1",
"title": "Getting Started",
"body_md": "# Getting Started\n\nWelcome...",
"section": "Introduction",
"article_order": 1,
"published_at": 1710000000
}
]

GET /api/docs from @cyguin/docs/next returns this shape automatically.

Theming

The widget is dark by default. Override --cyguin-* variables on :root:

:root {
--cyguin-bg:#0a0d17;
--cyguin-bg-subtle:#101521;
--cyguin-border:#252b3a;
--cyguin-border-focus:#f5a800;
--cyguin-fg:#f1f3f6;
--cyguin-fg-muted:#888888;
--cyguin-accent:#f5a800;
--cyguin-accent-dark:#c47f00;
--cyguin-accent-fg:#0a0a0a;
--cyguin-radius:6px;
--cyguin-shadow:01px4pxrgba(0,0,0,0.08);
}

Keyboard Navigation

KeyAction
/Focus search input
EscClose widget
/ Navigate article list
EnterOpen selected article

Exports

@cyguin/docs

ExportTypeDescription
DocsWidgetComponentSearchable docs widget (modal/sidebar)
DocsWidgetPropsInterfaceComponent props
DocArticleInterfaceArticle shape
defaultCssVarsObjectDefault CSS variable values

@cyguin/docs/next

ExportTypeDescription
createDocsHandlerFunctionFactory for Next.js API route handler
DocsAdapterInterfaceStorage adapter contract
DocArticleInterfaceArticle shape

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages