doccupine 0.0.151 → 0.0.153
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/dist/lib/constants.d.ts +1 -1
- package/dist/lib/constants.js +1 -1
- package/dist/lib/layout.js +24 -20
- package/dist/templates/components/layout/CherryThemeProvider.d.ts +1 -1
- package/dist/templates/components/layout/CherryThemeProvider.js +8 -7
- package/dist/templates/mdx/theme.mdx.d.ts +1 -1
- package/dist/templates/mdx/theme.mdx.js +1 -1
- package/dist/templates/package.js +1 -1
- package/dist/templates/utils/icons.d.ts +1 -1
- package/dist/templates/utils/mermaid.d.ts +1 -1
- package/dist/templates/utils/mermaid.js +47 -1
- package/package.json +1 -1
package/dist/lib/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const DEFAULT_DESCRIPTION = "Doccupine is a free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.";
|
|
2
2
|
export declare const DEFAULT_SITE_NAME = "Doccupine";
|
|
3
3
|
export declare const DEFAULT_META_DESCRIPTION = "Generated with Doccupine";
|
|
4
|
-
export declare const DEFAULT_FAVICON = "https://docs.doccupine.com/
|
|
4
|
+
export declare const DEFAULT_FAVICON = "https://docs.doccupine.com/icon.png";
|
|
5
5
|
export declare const DEFAULT_OG_IMAGE = "https://docs.doccupine.com/preview.png";
|
|
6
6
|
export declare const DEFAULT_URL = "https://docs.doccupine.com";
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const DEFAULT_DESCRIPTION = "Doccupine is a free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.";
|
|
2
2
|
export const DEFAULT_SITE_NAME = "Doccupine";
|
|
3
3
|
export const DEFAULT_META_DESCRIPTION = "Generated with Doccupine";
|
|
4
|
-
export const DEFAULT_FAVICON = "https://docs.doccupine.com/
|
|
4
|
+
export const DEFAULT_FAVICON = "https://docs.doccupine.com/icon.png";
|
|
5
5
|
export const DEFAULT_OG_IMAGE = "https://docs.doccupine.com/preview.png";
|
|
6
6
|
export const DEFAULT_URL = "https://docs.doccupine.com";
|
package/dist/lib/layout.js
CHANGED
|
@@ -90,13 +90,28 @@ function fontDeclLine(fontConfig) {
|
|
|
90
90
|
// and seeding the cookie so Cherry's ClientThemeProvider reconciles against
|
|
91
91
|
// the same answer on mount instead of flipping the class back.
|
|
92
92
|
//
|
|
93
|
-
// The theme-color meta
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
|
|
93
|
+
// The script also emits the theme-color meta for the resolved mode through
|
|
94
|
+
// document.write, which hands the tag to the HTML parser itself: Safari only
|
|
95
|
+
// tints its chrome reliably from a parser-inserted tag - one created through
|
|
96
|
+
// the DOM APIs is honored inconsistently or not at all - though it does track
|
|
97
|
+
// content updates to such a tag, which is how Cherry's post-hydration sync
|
|
98
|
+
// and theme toggles keep it current. The meta cannot be rendered from the
|
|
99
|
+
// layout instead: pages are static, so the server would emit one mode's color
|
|
100
|
+
// and this script would have to correct it before paint, and React 19
|
|
101
|
+
// hydration treats a head meta whose attributes differ from its props as
|
|
102
|
+
// missing and inserts a duplicate with the stale light color beside it -
|
|
103
|
+
// suppressHydrationWarning does not cover hoisted metas, and a meta emitted
|
|
104
|
+
// through Next's viewport export hydrates the same way (both verified against
|
|
105
|
+
// Next 16.3; the duplicate is what broke the chrome tint on iPad Safari).
|
|
106
|
+
// OS-scheme-scoped SSR metas are no answer either: the site's mode is
|
|
107
|
+
// cookie-based, so a dark site on a light-OS device would show the wrong
|
|
108
|
+
// browser chrome until hydration - a visible flash on every load. Keeping the
|
|
109
|
+
// tag out of React leaves exactly one meta that nothing ever re-inserts. The
|
|
110
|
+
// \${...} palette interpolations below are escaped so they resolve in the
|
|
111
|
+
// generated layout, at app build time, from the imported theme palettes. The
|
|
112
|
+
// token must match the provider's $themeColor (primary), so the pre-paint
|
|
113
|
+
// chrome color equals what Cherry syncs after hydration.
|
|
114
|
+
const THEME_INIT_SCRIPT = `(function(){try{var c=document.cookie.split(";").map(function(s){return s.trim();}).find(function(s){return s.indexOf("theme=")===0;});var v=c?c.split("=")[1]:null;var d=v?v==="dark":(window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches);if(!v){document.cookie="theme="+(d?"dark":"light")+";path=/;max-age=31536000;SameSite=Lax";}var r=document.documentElement;r.dataset.theme=d?"dark":"light";if(d){r.classList.add("dark");}document.write('<meta name="theme-color" content="'+(d?"\${colorsDark.primary}":"\${colorsLight.primary}")+'">');}catch(e){}})();`;
|
|
100
115
|
/**
|
|
101
116
|
* Root layout ("app/layout.tsx"). Minimal shell: html/body, fonts, the theme
|
|
102
117
|
* provider stack, and (optionally) PostHog. It renders `children` directly so
|
|
@@ -107,10 +122,10 @@ const THEME_INIT_SCRIPT = `(function(){try{var c=document.cookie.split(";").map(
|
|
|
107
122
|
* rewrites locked page requests to "/gate".
|
|
108
123
|
*/
|
|
109
124
|
export const rootLayoutTemplate = (fontConfig, analyticsEnabled = false) => {
|
|
110
|
-
return `import type { Metadata
|
|
125
|
+
return `import type { Metadata } from "next";
|
|
111
126
|
${fontImportLine(fontConfig)}
|
|
112
127
|
import { StyledComponentsRegistry } from "cherry-styled-components";
|
|
113
|
-
import { colorsLight, theme, themeDark } from "@/app/theme";
|
|
128
|
+
import { colorsDark, colorsLight, theme, themeDark } from "@/app/theme";
|
|
114
129
|
import { CherryThemeProvider } from "@/components/layout/CherryThemeProvider";
|
|
115
130
|
import { config } from "@/utils/config";
|
|
116
131
|
import { siteIcons } from "@/utils/icons";
|
|
@@ -127,17 +142,6 @@ function resolveSiteUrl(): URL | undefined {
|
|
|
127
142
|
}
|
|
128
143
|
}
|
|
129
144
|
|
|
130
|
-
// A single unscoped tag, server-rendered in the first bytes of head - the
|
|
131
|
-
// same channel the Doccupine platform site uses. Pages are static, so the
|
|
132
|
-
// server cannot know the cookie-based mode and renders the light \`primary\`;
|
|
133
|
-
// Cherry's provider ($themeColor="primary") corrects the tag's content after
|
|
134
|
-
// hydration, exactly as it does on the platform. The pre-paint script never
|
|
135
|
-
// touches it: a pre-paint edit makes React 19 hydration insert a duplicate
|
|
136
|
-
// with the stale value beside it.
|
|
137
|
-
export const viewport: Viewport = {
|
|
138
|
-
themeColor: colorsLight.primary,
|
|
139
|
-
};
|
|
140
|
-
|
|
141
145
|
export const metadata: Metadata = {
|
|
142
146
|
metadataBase: resolveSiteUrl(),
|
|
143
147
|
title: config.name || "${DEFAULT_SITE_NAME}",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const cherryThemeProviderTemplate = "\"use client\";\nimport React, { useEffect, useRef } from \"react\";\nimport { useTheme } from \"styled-components\";\nimport { ClientThemeProvider } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { GlobalStyles } from \"@/components/layout/GlobalStyles\";\n\n/**\n * Mirrors the active mode onto the data-theme attribute that every themed\n * selector keys off (see GlobalStyles).\n *\n * The attribute is already correct before the first paint - the blocking script\n * in the root layout sets it from the theme cookie - but the provider's first\n * client render still carries the light theme the server rendered, so the\n * active theme cannot be trusted until the provider has reconciled it against\n * the cookie. The mirror therefore reads the cookie, not the theme object:\n * the blocking script seeds it pre-paint and Cherry persists it synchronously\n * before any re-render on toggles and reconciliation, so writing it is\n * idempotent. Counting effect passes instead (a \"skip the first run\" ref)\n * breaks under StrictMode's dev double-invocation: the second pass writes the\n * unreconciled light theme and the whole page flashes white on dark loads.\n * The theme object is only a fallback for browsers that block cookies, where\n * the first (unreconciled) pass must still be skipped.\n *\n * This effect must stay a child of ClientThemeProvider: child effects run\n * first, so the attribute is
|
|
1
|
+
export declare const cherryThemeProviderTemplate = "\"use client\";\nimport React, { useEffect, useRef } from \"react\";\nimport { useTheme } from \"styled-components\";\nimport { ClientThemeProvider } from \"cherry-styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { GlobalStyles } from \"@/components/layout/GlobalStyles\";\n\n/**\n * Mirrors the active mode onto the data-theme attribute that every themed\n * selector keys off (see GlobalStyles).\n *\n * The attribute is already correct before the first paint - the blocking script\n * in the root layout sets it from the theme cookie - but the provider's first\n * client render still carries the light theme the server rendered, so the\n * active theme cannot be trusted until the provider has reconciled it against\n * the cookie. The mirror therefore reads the cookie, not the theme object:\n * the blocking script seeds it pre-paint and Cherry persists it synchronously\n * before any re-render on toggles and reconciliation, so writing it is\n * idempotent. Counting effect passes instead (a \"skip the first run\" ref)\n * breaks under StrictMode's dev double-invocation: the second pass writes the\n * unreconciled light theme and the whole page flashes white on dark loads.\n * The theme object is only a fallback for browsers that block cookies, where\n * the first (unreconciled) pass must still be skipped.\n *\n * This effect must stay a child of ClientThemeProvider: child effects run\n * first, so the attribute is updated before the provider's own theme-color\n * sync resolves var(--color-primary) against the document's computed styles.\n */\nfunction ThemeModeAttribute() {\n const activeTheme = useTheme() as Theme;\n const settled = useRef(false);\n\n useEffect(() => {\n const mode = /(?:^|;\\s*)theme=(dark|light)(?:;|$)/.exec(document.cookie);\n if (mode) {\n document.documentElement.dataset.theme = mode[1];\n } else if (settled.current) {\n document.documentElement.dataset.theme = activeTheme.isDark\n ? \"dark\"\n : \"light\";\n } else {\n settled.current = true;\n }\n }, [activeTheme.isDark]);\n\n return null;\n}\n\n/**\n * Wraps Cherry's ClientThemeProvider, which swaps theme/themeDark on toggle and\n * persists the choice to the `theme` cookie + localStorage. Deliberately reads\n * NO request data (cookies/headers) so pages stay statically renderable.\n *\n * The two theme objects hold the same CSS-variable colors and differ only in\n * `isDark`, so the visible mode is decided entirely by the data-theme\n * attribute on <html>, which ThemeModeAttribute keeps in step. The provider\n * also maintains a \"dark\" class of its own; nothing here depends on it, because\n * it is briefly out of step on mount while the provider reconciles the\n * server-rendered light theme against the cookie.\n *\n * $globalStyles is off because this app ships its own GlobalStyles.\n * $themeColor=\"primary\" hands the post-hydration theme-color sync to Cherry\n * with the branded chrome Cherry's own site uses: since 0.2.15 the provider\n * resolves var() color references through computed styles, so the `primary`\n * token yields each mode's brand hex for the active data-theme. The blocking\n * script in the root layout writes the same token's value before first\n * paint; the provider takes over from there, so the two must stay on the\n * same token.\n */\nfunction CherryThemeProvider({\n children,\n theme,\n themeDark,\n}: {\n children: React.ReactNode;\n theme: Theme;\n themeDark: Theme;\n}) {\n return (\n <ClientThemeProvider\n theme={theme}\n themeDark={themeDark}\n $globalStyles={false}\n $themeColor=\"primary\"\n >\n <GlobalStyles />\n <ThemeModeAttribute />\n {children}\n </ClientThemeProvider>\n );\n}\n\nexport { CherryThemeProvider };\n";
|
|
@@ -23,8 +23,8 @@ import { GlobalStyles } from "@/components/layout/GlobalStyles";
|
|
|
23
23
|
* the first (unreconciled) pass must still be skipped.
|
|
24
24
|
*
|
|
25
25
|
* This effect must stay a child of ClientThemeProvider: child effects run
|
|
26
|
-
* first, so the attribute is
|
|
27
|
-
*
|
|
26
|
+
* first, so the attribute is updated before the provider's own theme-color
|
|
27
|
+
* sync resolves var(--color-primary) against the document's computed styles.
|
|
28
28
|
*/
|
|
29
29
|
function ThemeModeAttribute() {
|
|
30
30
|
const activeTheme = useTheme() as Theme;
|
|
@@ -59,12 +59,13 @@ function ThemeModeAttribute() {
|
|
|
59
59
|
* server-rendered light theme against the cookie.
|
|
60
60
|
*
|
|
61
61
|
* $globalStyles is off because this app ships its own GlobalStyles.
|
|
62
|
-
* $themeColor="primary" hands the post-hydration theme-color sync to Cherry
|
|
63
|
-
*
|
|
62
|
+
* $themeColor="primary" hands the post-hydration theme-color sync to Cherry
|
|
63
|
+
* with the branded chrome Cherry's own site uses: since 0.2.15 the provider
|
|
64
64
|
* resolves var() color references through computed styles, so the \`primary\`
|
|
65
|
-
* token yields each mode's brand hex for the active data-theme. The
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* token yields each mode's brand hex for the active data-theme. The blocking
|
|
66
|
+
* script in the root layout writes the same token's value before first
|
|
67
|
+
* paint; the provider takes over from there, so the two must stay on the
|
|
68
|
+
* same token.
|
|
68
69
|
*/
|
|
69
70
|
function CherryThemeProvider({
|
|
70
71
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const themeMdxTemplate = "---\ntitle: \"Theme\"\ndescription: \"Customize the documentation UI colors with a theme.json file.\"\ndate: \"2026-02-19\"\nupdated: \"2026-08-04\"\ncategory: \"Configuration\"\ncategoryOrder: 2\norder: 5\n---\n# Theme\n\nDefine your site\u2019s color system with a `theme.json` file. This lets you tailor the look and feel of your documentation without changing content.\n\n## theme.json\n\nPlace a `theme.json` at your project root (the same directory where you execute `npx doccupine`). It supports multiple modes. Define a `default` mode and a `dark` mode.\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#93c5fd\",\n \"primary\": \"#2563eb\",\n \"primaryDark\": \"#1e40af\",\n \"secondaryLight\": \"#c4b5fd\",\n \"secondary\": \"#8b5cf6\",\n \"secondaryDark\": \"#5b21b6\",\n \"tertiaryLight\": \"#fbbf24\",\n \"tertiary\": \"#f59e0b\",\n \"tertiaryDark\": \"#d97706\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#9bcaff\",\n \"primary\": \"#1e7ae0\",\n \"primaryDark\": \"#033d7e\",\n \"secondaryLight\": \"#ddd6fe\",\n \"secondary\": \"#a78bfa\",\n \"secondaryDark\": \"#7c3aed\",\n \"tertiaryLight\": \"#fed7aa\",\n \"tertiary\": \"#fb923c\",\n \"tertiaryDark\": \"#ea580c\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n },\n \"logo\": {\n \"dark\": \"https://docs.doccupine.com/logo-dark.svg\",\n \"light\": \"https://docs.doccupine.com/logo-light.svg\"\n }\n}\n```\n\n## Modes\n\n- **default**: The base color palette for your site.\n- **dark**: Dark\u2011mode palette.\n\n## Fields\n\n- **primaryLight**: A lighter variant of your brand color, used for subtle accents and backgrounds.\n- **primary**: The main brand color.\n- **primaryDark**: A darker variant of your brand color for emphasis and hover states.\n- **secondaryLight**: A lighter variant of your secondary color, used for subtle accents and backgrounds.\n- **secondary**: The secondary brand color used for highlights and UI accents.\n- **secondaryDark**: A darker variant of your secondary color for emphasis and hover states.\n- **tertiaryLight**: A lighter variant of your tertiary color, used for subtle accents and backgrounds.\n- **tertiary**: The tertiary accent color.\n- **tertiaryDark**: A darker variant of your tertiary color for emphasis and hover states.\n- **grayLight**: Light gray for surfaces and borders.\n- **gray**: Neutral gray for text and UI elements.\n- **grayDark**: Dark gray for headings or high\u2011contrast text.\n- **success**: Positive/confirmation color.\n- **error**: Error/destructive color.\n- **warning**: Warning/attention color.\n- **info**: Informational/highlight color.\n- **dark**: The darkest/base color (often page background in dark mode).\n- **light**: The lightest/base color (often page background in light mode).\n- **logo.light**: Path or URL to the logo used on light backgrounds. Recommended size: 164\u00D730 px.\n- **logo.dark**: Path or URL to the logo used on dark backgrounds. Recommended size: 164\u00D730 px.\n\n## Behavior\n\n- **Placement**: Put `theme.json` in the project root alongside `config.json`.\n- **Partial palettes**: If a key is missing in a mode, consumers may fall back to the `default` value.\n- **Logo size**: Recommended dimensions are 164px width and 30px height.\n- **Browser chrome**: The `theme-color` shown in browser UI (such as the iOS Safari status bar)
|
|
1
|
+
export declare const themeMdxTemplate = "---\ntitle: \"Theme\"\ndescription: \"Customize the documentation UI colors with a theme.json file.\"\ndate: \"2026-02-19\"\nupdated: \"2026-08-04\"\ncategory: \"Configuration\"\ncategoryOrder: 2\norder: 5\n---\n# Theme\n\nDefine your site\u2019s color system with a `theme.json` file. This lets you tailor the look and feel of your documentation without changing content.\n\n## theme.json\n\nPlace a `theme.json` at your project root (the same directory where you execute `npx doccupine`). It supports multiple modes. Define a `default` mode and a `dark` mode.\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#93c5fd\",\n \"primary\": \"#2563eb\",\n \"primaryDark\": \"#1e40af\",\n \"secondaryLight\": \"#c4b5fd\",\n \"secondary\": \"#8b5cf6\",\n \"secondaryDark\": \"#5b21b6\",\n \"tertiaryLight\": \"#fbbf24\",\n \"tertiary\": \"#f59e0b\",\n \"tertiaryDark\": \"#d97706\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#9bcaff\",\n \"primary\": \"#1e7ae0\",\n \"primaryDark\": \"#033d7e\",\n \"secondaryLight\": \"#ddd6fe\",\n \"secondary\": \"#a78bfa\",\n \"secondaryDark\": \"#7c3aed\",\n \"tertiaryLight\": \"#fed7aa\",\n \"tertiary\": \"#fb923c\",\n \"tertiaryDark\": \"#ea580c\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n },\n \"logo\": {\n \"dark\": \"https://docs.doccupine.com/logo-dark.svg\",\n \"light\": \"https://docs.doccupine.com/logo-light.svg\"\n }\n}\n```\n\n## Modes\n\n- **default**: The base color palette for your site.\n- **dark**: Dark\u2011mode palette.\n\n## Fields\n\n- **primaryLight**: A lighter variant of your brand color, used for subtle accents and backgrounds.\n- **primary**: The main brand color.\n- **primaryDark**: A darker variant of your brand color for emphasis and hover states.\n- **secondaryLight**: A lighter variant of your secondary color, used for subtle accents and backgrounds.\n- **secondary**: The secondary brand color used for highlights and UI accents.\n- **secondaryDark**: A darker variant of your secondary color for emphasis and hover states.\n- **tertiaryLight**: A lighter variant of your tertiary color, used for subtle accents and backgrounds.\n- **tertiary**: The tertiary accent color.\n- **tertiaryDark**: A darker variant of your tertiary color for emphasis and hover states.\n- **grayLight**: Light gray for surfaces and borders.\n- **gray**: Neutral gray for text and UI elements.\n- **grayDark**: Dark gray for headings or high\u2011contrast text.\n- **success**: Positive/confirmation color.\n- **error**: Error/destructive color.\n- **warning**: Warning/attention color.\n- **info**: Informational/highlight color.\n- **dark**: The darkest/base color (often page background in dark mode).\n- **light**: The lightest/base color (often page background in light mode).\n- **logo.light**: Path or URL to the logo used on light backgrounds. Recommended size: 164\u00D730 px.\n- **logo.dark**: Path or URL to the logo used on dark backgrounds. Recommended size: 164\u00D730 px.\n\n## Behavior\n\n- **Placement**: Put `theme.json` in the project root alongside `config.json`.\n- **Partial palettes**: If a key is missing in a mode, consumers may fall back to the `default` value.\n- **Logo size**: Recommended dimensions are 164px width and 30px height.\n- **Browser chrome**: The `theme-color` shown in browser UI (such as the iOS Safari status bar) is derived from each mode's `primary` token, so it carries your brand color in both modes.\n\n<Callout type=\"warning\">\n Use valid hex colors (e.g., `#22c55e`). Invalid color values may cause unexpected rendering.\n</Callout>\n\n## Tips\n\n- **Contrast**: Ensure sufficient contrast between text and backgrounds for readability.\n- **Branding**: Start with your brand\u2019s `primary` color, then derive `primaryLight` and `primaryDark`.\n- **Iterate**: Adjust colors and refresh the site to preview changes quickly.\n\n# Demo\n\nIn the following demos, you can see how the theme can be changed. To override the theme, create a `theme.json` file in the project root and copy paste the code below.\n\n<DemoTheme variant=\"purple\" />\n<DemoTheme variant=\"green\" />\n<DemoTheme variant=\"yellow\" />\n<DemoTheme />\n\n## Purple\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#c4b5fd\",\n \"primary\": \"#8b5cf6\",\n \"primaryDark\": \"#5b21b6\",\n \"secondaryLight\": \"#86efac\",\n \"secondary\": \"#22c55e\",\n \"secondaryDark\": \"#15803d\",\n \"tertiaryLight\": \"#fbbf24\",\n \"tertiary\": \"#f59e0b\",\n \"tertiaryDark\": \"#d97706\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#ddd6fe\",\n \"primary\": \"#a78bfa\",\n \"primaryDark\": \"#7c3aed\",\n \"secondaryLight\": \"#6ee7b7\",\n \"secondary\": \"#10b981\",\n \"secondaryDark\": \"#065f46\",\n \"tertiaryLight\": \"#fed7aa\",\n \"tertiary\": \"#fb923c\",\n \"tertiaryDark\": \"#ea580c\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n }\n}\n```\n\n<DemoTheme variant=\"purple\" />\n\n## Green\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#86efac\",\n \"primary\": \"#22c55e\",\n \"primaryDark\": \"#15803d\",\n \"secondaryLight\": \"#c4b5fd\",\n \"secondary\": \"#8b5cf6\",\n \"secondaryDark\": \"#5b21b6\",\n \"tertiaryLight\": \"#fbbf24\",\n \"tertiary\": \"#f59e0b\",\n \"tertiaryDark\": \"#d97706\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#6ee7b7\",\n \"primary\": \"#10b981\",\n \"primaryDark\": \"#065f46\",\n \"secondaryLight\": \"#ddd6fe\",\n \"secondary\": \"#a78bfa\",\n \"secondaryDark\": \"#7c3aed\",\n \"tertiaryLight\": \"#fed7aa\",\n \"tertiary\": \"#fb923c\",\n \"tertiaryDark\": \"#ea580c\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n }\n}\n```\n\n<DemoTheme variant=\"green\" />\n\n## Yellow\n\n```json\n{\n \"default\": {\n \"primaryLight\": \"#fbbf24\",\n \"primary\": \"#f59e0b\",\n \"primaryDark\": \"#d97706\",\n \"secondaryLight\": \"#c4b5fd\",\n \"secondary\": \"#8b5cf6\",\n \"secondaryDark\": \"#5b21b6\",\n \"tertiaryLight\": \"#86efac\",\n \"tertiary\": \"#22c55e\",\n \"tertiaryDark\": \"#15803d\",\n \"grayLight\": \"#f3f4f6\",\n \"gray\": \"#9ca3af\",\n \"grayDark\": \"#374151\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#000000\",\n \"light\": \"#ffffff\"\n },\n \"dark\": {\n \"primaryLight\": \"#fed7aa\",\n \"primary\": \"#fb923c\",\n \"primaryDark\": \"#ea580c\",\n \"secondaryLight\": \"#ddd6fe\",\n \"secondary\": \"#a78bfa\",\n \"secondaryDark\": \"#7c3aed\",\n \"tertiaryLight\": \"#6ee7b7\",\n \"tertiary\": \"#10b981\",\n \"tertiaryDark\": \"#065f46\",\n \"grayLight\": \"#1f2937\",\n \"gray\": \"#6b7280\",\n \"grayDark\": \"#9ca3af\",\n \"success\": \"#10b981\",\n \"error\": \"#f43f5e\",\n \"warning\": \"#f59e0b\",\n \"info\": \"#3b82f6\",\n \"dark\": \"#ffffff\",\n \"light\": \"#000000\"\n }\n}\n```\n\n<DemoTheme variant=\"yellow\" />";
|
|
@@ -97,7 +97,7 @@ Place a \`theme.json\` at your project root (the same directory where you execut
|
|
|
97
97
|
- **Placement**: Put \`theme.json\` in the project root alongside \`config.json\`.
|
|
98
98
|
- **Partial palettes**: If a key is missing in a mode, consumers may fall back to the \`default\` value.
|
|
99
99
|
- **Logo size**: Recommended dimensions are 164px width and 30px height.
|
|
100
|
-
- **Browser chrome**: The \`theme-color\` shown in browser UI (such as the iOS Safari status bar)
|
|
100
|
+
- **Browser chrome**: The \`theme-color\` shown in browser UI (such as the iOS Safari status bar) is derived from each mode's \`primary\` token, so it carries your brand color in both modes.
|
|
101
101
|
|
|
102
102
|
<Callout type="warning">
|
|
103
103
|
Use valid hex colors (e.g., \`#22c55e\`). Invalid color values may cause unexpected rendering.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const iconsTemplate = "import type { Metadata } from \"next\";\nimport iconsData from \"@/icons.json\";\nimport { config } from \"@/utils/config\";\n\n// icons.json is written by the Doccupine CLI from icon files at the project\n// root (icon.png, icon-dark.png, apple-icon.png). Every URL carries a\n// content-hash query so a replaced icon busts browser caches.\ninterface IconManifest {\n icon?: string;\n iconDark?: string;\n appleIcon?: string;\n}\n\nconst icons = iconsData as IconManifest;\n\nconst fallbackIcon = config.icon || \"https://docs.doccupine.com/
|
|
1
|
+
export declare const iconsTemplate = "import type { Metadata } from \"next\";\nimport iconsData from \"@/icons.json\";\nimport { config } from \"@/utils/config\";\n\n// icons.json is written by the Doccupine CLI from icon files at the project\n// root (icon.png, icon-dark.png, apple-icon.png). Every URL carries a\n// content-hash query so a replaced icon busts browser caches.\ninterface IconManifest {\n icon?: string;\n iconDark?: string;\n appleIcon?: string;\n}\n\nconst icons = iconsData as IconManifest;\n\nconst fallbackIcon = config.icon || \"https://docs.doccupine.com/icon.png\";\n\n/** Single icon URL for JSON-LD logos and other one-value consumers. */\nexport const primaryIconUrl: string = icons.icon ?? fallbackIcon;\n\nfunction buildSiteIcons(): Metadata[\"icons\"] {\n if (!icons.icon && !icons.appleIcon) return fallbackIcon;\n const iconEntries: { url: string; media?: string }[] = [];\n if (icons.icon && icons.iconDark) {\n iconEntries.push({\n url: icons.icon,\n media: \"(prefers-color-scheme: light)\",\n });\n iconEntries.push({\n url: icons.iconDark,\n media: \"(prefers-color-scheme: dark)\",\n });\n } else if (icons.icon) {\n iconEntries.push({ url: icons.icon });\n }\n return {\n icon: iconEntries.length > 0 ? iconEntries : fallbackIcon,\n ...(icons.appleIcon ? { apple: icons.appleIcon } : {}),\n };\n}\n\nexport const siteIcons: Metadata[\"icons\"] = buildSiteIcons();\n\n/**\n * Icon entries for the web app manifest. Only the root icon files are\n * listed - their true pixel dimensions are unknown to the generator, so the\n * spec's \"any\" stands in - and a site without them gets a manifest without\n * icons rather than a guessed format.\n */\nexport const manifestIcons: { src: string; sizes: string; type: string }[] = [\n ...(icons.icon ? [{ src: icons.icon, sizes: \"any\", type: \"image/png\" }] : []),\n ...(icons.appleIcon\n ? [{ src: icons.appleIcon, sizes: \"any\", type: \"image/png\" }]\n : []),\n];\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const mermaidTemplate = "import \"server-only\";\nimport { renderMermaidSVG } from \"beautiful-mermaid\";\n\nconst DIAGRAM_OPTIONS = {\n bg: \"var(--mermaid-bg)\",\n fg: \"var(--mermaid-fg)\",\n line: \"var(--mermaid-line)\",\n accent: \"var(--mermaid-accent)\",\n muted: \"var(--mermaid-muted)\",\n surface: \"var(--mermaid-surface)\",\n border: \"var(--mermaid-border)\",\n transparent: true,\n};\n\nexport type MermaidResult =\n | { ok: true; svg: string; width: number | null }\n | { ok: false; error: string };\n\nfunction normalizeSvg(svg: string): {\n ok: true;\n svg: string;\n width: number | null;\n} {\n const openTag = /^<svg\\b[^>]*>/.exec(svg);\n if (!openTag) return { ok: true, svg, width: null };\n\n const widthMatch = /\\swidth=\"([\\d.]+)\"/.exec(openTag[0]);\n const width = widthMatch ? Number.parseFloat(widthMatch[1]) : null;\n\n const stripped = openTag[0].replace(/\\s(?:width|height)=\"[^\"]*\"/g, \"\");\n return {\n ok: true,\n svg: stripped + svg.slice(openTag[0].length),\n width: width !== null && Number.isFinite(width) ? width : null,\n };\n}\n\nexport function renderDiagram(code: string): MermaidResult {\n try {\n return normalizeSvg(renderMermaidSVG(code, DIAGRAM_OPTIONS));\n } catch (error) {\n return {\n ok: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n";
|
|
1
|
+
export declare const mermaidTemplate = "import \"server-only\";\nimport { renderMermaidSVG } from \"beautiful-mermaid\";\n\nconst DIAGRAM_OPTIONS = {\n bg: \"var(--mermaid-bg)\",\n fg: \"var(--mermaid-fg)\",\n line: \"var(--mermaid-line)\",\n accent: \"var(--mermaid-accent)\",\n muted: \"var(--mermaid-muted)\",\n surface: \"var(--mermaid-surface)\",\n border: \"var(--mermaid-border)\",\n transparent: true,\n};\n\nexport type MermaidResult =\n | { ok: true; svg: string; width: number | null }\n | { ok: false; error: string };\n\nfunction parseColor(value: string): [number, number, number] | null {\n const hex = /^#([0-9a-f]{3,8})$/i.exec(value.trim());\n if (hex) {\n let channels = hex[1];\n if (channels.length === 3 || channels.length === 4) {\n channels = channels\n .slice(0, 3)\n .split(\"\")\n .map((c) => c + c)\n .join(\"\");\n }\n if (channels.length !== 6 && channels.length !== 8) return null;\n return [\n Number.parseInt(channels.slice(0, 2), 16),\n Number.parseInt(channels.slice(2, 4), 16),\n Number.parseInt(channels.slice(4, 6), 16),\n ];\n }\n const rgb = /^rgba?\\(\\s*(\\d+)[\\s,]+(\\d+)[\\s,]+(\\d+)/i.exec(value.trim());\n if (rgb) return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])];\n return null;\n}\n\n// beautiful-mermaid labels nodes with the theme foreground (white in dark\n// mode) even when the diagram sets an explicit fill via classDef/style, which\n// leaves white text on light colored boxes. The SVG renders once and is shared\n// by both modes, so bake a literal contrast color into the labels of nodes\n// whose shape has a literal fill.\nfunction contrastNodeLabels(svg: string): string {\n return svg.replace(/<g class=\"node\"[^>]*>[\\s\\S]*?<\\/g>/g, (group) => {\n const shapeFill = /fill=\"([^\"]*)\"/.exec(group)?.[1] ?? \"\";\n if (shapeFill.startsWith(\"var(\") || shapeFill === \"none\") return group;\n const rgb = parseColor(shapeFill);\n // YIQ perceived brightness. Unparseable literals (named colors) default\n // to black text \u2014 classDef fills are overwhelmingly light pastels.\n const yiq = rgb ? (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000 : 255;\n const label = yiq >= 128 ? \"#000000\" : \"#ffffff\";\n return group.replace(\n /(<text[^>]*fill=\")var\\(--_text\\)(\")/g,\n \"$1\" + label + \"$2\",\n );\n });\n}\n\nfunction normalizeSvg(svg: string): {\n ok: true;\n svg: string;\n width: number | null;\n} {\n const openTag = /^<svg\\b[^>]*>/.exec(svg);\n if (!openTag) return { ok: true, svg, width: null };\n\n const widthMatch = /\\swidth=\"([\\d.]+)\"/.exec(openTag[0]);\n const width = widthMatch ? Number.parseFloat(widthMatch[1]) : null;\n\n const stripped = openTag[0].replace(/\\s(?:width|height)=\"[^\"]*\"/g, \"\");\n return {\n ok: true,\n svg: stripped + svg.slice(openTag[0].length),\n width: width !== null && Number.isFinite(width) ? width : null,\n };\n}\n\nexport function renderDiagram(code: string): MermaidResult {\n try {\n return normalizeSvg(\n contrastNodeLabels(renderMermaidSVG(code, DIAGRAM_OPTIONS)),\n );\n } catch (error) {\n return {\n ok: false,\n error: error instanceof Error ? error.message : String(error),\n };\n }\n}\n";
|
|
@@ -16,6 +16,50 @@ export type MermaidResult =
|
|
|
16
16
|
| { ok: true; svg: string; width: number | null }
|
|
17
17
|
| { ok: false; error: string };
|
|
18
18
|
|
|
19
|
+
function parseColor(value: string): [number, number, number] | null {
|
|
20
|
+
const hex = /^#([0-9a-f]{3,8})$/i.exec(value.trim());
|
|
21
|
+
if (hex) {
|
|
22
|
+
let channels = hex[1];
|
|
23
|
+
if (channels.length === 3 || channels.length === 4) {
|
|
24
|
+
channels = channels
|
|
25
|
+
.slice(0, 3)
|
|
26
|
+
.split("")
|
|
27
|
+
.map((c) => c + c)
|
|
28
|
+
.join("");
|
|
29
|
+
}
|
|
30
|
+
if (channels.length !== 6 && channels.length !== 8) return null;
|
|
31
|
+
return [
|
|
32
|
+
Number.parseInt(channels.slice(0, 2), 16),
|
|
33
|
+
Number.parseInt(channels.slice(2, 4), 16),
|
|
34
|
+
Number.parseInt(channels.slice(4, 6), 16),
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
const rgb = /^rgba?\\(\\s*(\\d+)[\\s,]+(\\d+)[\\s,]+(\\d+)/i.exec(value.trim());
|
|
38
|
+
if (rgb) return [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])];
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// beautiful-mermaid labels nodes with the theme foreground (white in dark
|
|
43
|
+
// mode) even when the diagram sets an explicit fill via classDef/style, which
|
|
44
|
+
// leaves white text on light colored boxes. The SVG renders once and is shared
|
|
45
|
+
// by both modes, so bake a literal contrast color into the labels of nodes
|
|
46
|
+
// whose shape has a literal fill.
|
|
47
|
+
function contrastNodeLabels(svg: string): string {
|
|
48
|
+
return svg.replace(/<g class="node"[^>]*>[\\s\\S]*?<\\/g>/g, (group) => {
|
|
49
|
+
const shapeFill = /fill="([^"]*)"/.exec(group)?.[1] ?? "";
|
|
50
|
+
if (shapeFill.startsWith("var(") || shapeFill === "none") return group;
|
|
51
|
+
const rgb = parseColor(shapeFill);
|
|
52
|
+
// YIQ perceived brightness. Unparseable literals (named colors) default
|
|
53
|
+
// to black text — classDef fills are overwhelmingly light pastels.
|
|
54
|
+
const yiq = rgb ? (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000 : 255;
|
|
55
|
+
const label = yiq >= 128 ? "#000000" : "#ffffff";
|
|
56
|
+
return group.replace(
|
|
57
|
+
/(<text[^>]*fill=")var\\(--_text\\)(")/g,
|
|
58
|
+
"$1" + label + "$2",
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
19
63
|
function normalizeSvg(svg: string): {
|
|
20
64
|
ok: true;
|
|
21
65
|
svg: string;
|
|
@@ -37,7 +81,9 @@ function normalizeSvg(svg: string): {
|
|
|
37
81
|
|
|
38
82
|
export function renderDiagram(code: string): MermaidResult {
|
|
39
83
|
try {
|
|
40
|
-
return normalizeSvg(
|
|
84
|
+
return normalizeSvg(
|
|
85
|
+
contrastNodeLabels(renderMermaidSVG(code, DIAGRAM_OPTIONS)),
|
|
86
|
+
);
|
|
41
87
|
} catch (error) {
|
|
42
88
|
return {
|
|
43
89
|
ok: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "doccupine",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.153",
|
|
4
4
|
"description": "Free and open-source documentation platform. Write MDX, get a production-ready site with AI chat, built-in components, and an MCP server - in one command.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|