ghostcn 1.1.0 → 1.4.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.
Files changed (70) hide show
  1. package/README.md +225 -3
  2. package/dist/commands/add.d.ts +6 -1
  3. package/dist/commands/add.js +121 -83
  4. package/dist/commands/create.js +8 -1
  5. package/dist/commands/diff.d.ts +5 -0
  6. package/dist/commands/diff.js +54 -0
  7. package/dist/commands/doctor.d.ts +1 -0
  8. package/dist/commands/doctor.js +7 -0
  9. package/dist/commands/init.js +5 -0
  10. package/dist/commands/pack.d.ts +1 -0
  11. package/dist/commands/pack.js +8 -0
  12. package/dist/commands/playground.d.ts +3 -0
  13. package/dist/commands/playground.js +29 -0
  14. package/dist/index.js +20 -2
  15. package/dist/registry/components/alert.json +62 -0
  16. package/dist/registry/components/archive-header.json +57 -0
  17. package/dist/registry/components/author-card.json +23 -2
  18. package/dist/registry/components/author-list.json +55 -0
  19. package/dist/registry/components/badge.json +51 -0
  20. package/dist/registry/components/button.json +74 -0
  21. package/dist/registry/components/card.json +70 -0
  22. package/dist/registry/components/featured-posts.json +18 -1
  23. package/dist/registry/components/input.json +94 -0
  24. package/dist/registry/components/member-cta.json +15 -1
  25. package/dist/registry/components/newsletter-form.json +23 -2
  26. package/dist/registry/components/pagination.json +12 -1
  27. package/dist/registry/components/post-card.json +25 -2
  28. package/dist/registry/components/post-grid.json +54 -0
  29. package/dist/registry/components/post-header.json +18 -1
  30. package/dist/registry/components/post-navigation.json +41 -0
  31. package/dist/registry/components/pricing-table.json +34 -5
  32. package/dist/registry/components/related-posts.json +53 -0
  33. package/dist/registry/components/site-footer.json +15 -1
  34. package/dist/registry/components/site-header.json +17 -2
  35. package/dist/registry/components/table-of-contents.json +47 -0
  36. package/dist/registry/components/tag-grid.json +64 -0
  37. package/dist/registry/components/tag-list.json +38 -0
  38. package/dist/registry/index.json +131 -0
  39. package/dist/templates/playground/index.html +5 -0
  40. package/dist/templates/playground/playground.css +18 -0
  41. package/dist/templates/playground/playground.js +71 -0
  42. package/dist/templates/playground/preview.css +5 -0
  43. package/dist/templates/playground/preview.js +12 -0
  44. package/dist/templates/theme-tools.mjs +178 -0
  45. package/dist/utils/component-diff.d.ts +18 -0
  46. package/dist/utils/component-diff.js +93 -0
  47. package/dist/utils/component-files.d.ts +9 -0
  48. package/dist/utils/component-files.js +48 -0
  49. package/dist/utils/component-history.d.ts +11 -0
  50. package/dist/utils/component-history.js +47 -0
  51. package/dist/utils/component-installer.d.ts +2 -0
  52. package/dist/utils/component-installer.js +34 -36
  53. package/dist/utils/component-plan.d.ts +7 -0
  54. package/dist/utils/component-plan.js +43 -0
  55. package/dist/utils/playground-server.d.ts +9 -0
  56. package/dist/utils/playground-server.js +189 -0
  57. package/dist/utils/preview-renderer.d.ts +143 -0
  58. package/dist/utils/preview-renderer.js +70 -0
  59. package/dist/utils/registry.d.ts +7 -0
  60. package/dist/utils/registry.js +12 -18
  61. package/dist/utils/styles.d.ts +3 -0
  62. package/dist/utils/styles.js +20 -0
  63. package/dist/utils/theme-files.d.ts +2 -0
  64. package/dist/utils/theme-files.js +46 -4
  65. package/dist/utils/theme-project.js +9 -4
  66. package/dist/utils/theme-scaffold.js +61 -24
  67. package/dist/utils/theme-tooling.d.ts +2 -0
  68. package/dist/utils/theme-tooling.js +20 -0
  69. package/dist/utils/theme.js +4 -2
  70. package/package.json +6 -4
@@ -9,7 +9,9 @@ const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const theme_1 = require("./theme");
11
11
  const theme_files_1 = require("./theme-files");
12
+ const styles_1 = require("./styles");
12
13
  function buildGhostcnConfig(theme, paths = {}) {
14
+ const normalized = (value, fallback) => value?.trim().replace(/\\/g, '/') || fallback;
13
15
  return {
14
16
  $schema: 'https://ghostcn.com/schema.json',
15
17
  style: theme.style,
@@ -19,11 +21,11 @@ function buildGhostcnConfig(theme, paths = {}) {
19
21
  radius: theme.radius
20
22
  },
21
23
  aliases: {
22
- partials: paths.partials || 'partials/components',
23
- styles: paths.styles || 'assets/css/components',
24
- js: paths.js || 'assets/js/components'
24
+ partials: normalized(paths.partials, 'partials/components'),
25
+ styles: normalized(paths.styles, 'assets/css/components'),
26
+ js: normalized(paths.js, 'assets/js/components')
25
27
  },
26
- cssFile: paths.cssFile || 'assets/css/ghostcn.css'
28
+ cssFile: normalized(paths.cssFile, 'assets/css/ghostcn.css')
27
29
  };
28
30
  }
29
31
  function initializeThemeProject(options) {
@@ -32,6 +34,9 @@ function initializeThemeProject(options) {
32
34
  fs_1.default.mkdirSync(path_1.default.dirname(cssPath), { recursive: true });
33
35
  fs_1.default.writeFileSync(configPath, JSON.stringify(options.config, null, 2) + '\n', 'utf8');
34
36
  fs_1.default.writeFileSync(cssPath, (0, theme_1.generateThemeCss)({ style: options.config.style, ...options.config.theme }), 'utf8');
37
+ if (options.config.style === 'tailwind') {
38
+ fs_1.default.writeFileSync(path_1.default.join(path_1.default.dirname(cssPath), 'ghostcn-tailwind.css'), (0, styles_1.tailwindTheme)(), 'utf8');
39
+ }
35
40
  const styleSync = (0, theme_files_1.syncGhostcnStyles)({
36
41
  themeRoot: options.themeRoot,
37
42
  cssFile: options.config.cssFile,
@@ -9,6 +9,8 @@ exports.scaffoldTheme = scaffoldTheme;
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const theme_files_1 = require("./theme-files");
12
+ const styles_1 = require("./styles");
13
+ const theme_tooling_1 = require("./theme-tooling");
12
14
  exports.REQUIRED_STARTER_COMPONENTS = [
13
15
  'site-header',
14
16
  'site-footer',
@@ -40,6 +42,9 @@ body {
40
42
  -webkit-font-smoothing: antialiased;
41
43
  }
42
44
  img { max-width: 100%; }
45
+ /* Ghost comments paints its own text colors inside a transparent iframe.
46
+ Match the embedded document's native scheme so dark mode does not force a white canvas. */
47
+ iframe[title="comments-frame"] { color-scheme: normal; }
43
48
  h1, h2, h3, h4, h5, h6 { font-family: var(--gh-font-heading, inherit); }
44
49
  .ghcn-main { min-height: 65vh; }
45
50
  .ghcn-page-heading { width: min(100% - 2rem, 72rem); margin: 4rem auto 2rem; }
@@ -66,6 +71,7 @@ function defaultTemplate(_colorScheme) {
66
71
  <meta charset="utf-8" />
67
72
  <meta name="viewport" content="width=device-width, initial-scale=1" />
68
73
  <title>{{meta_title}}</title>
74
+ {{!-- ghostcn:theme-styles --}}
69
75
  <link rel="stylesheet" href="{{asset "built/screen.css"}}" />
70
76
  {{ghost_head}}
71
77
  </head>
@@ -114,7 +120,7 @@ function postTemplate(options) {
114
120
  <article class="ghcn-article {{post_class}}">
115
121
  <div class="ghcn-article-content">{{content}}</div>
116
122
  </article>
117
- {{> "components/member-cta"}}
123
+ {{#if access}}{{> "components/member-cta"}}{{/if}}
118
124
  ${author} {{comments}}
119
125
  {{/post}}
120
126
  `;
@@ -157,15 +163,19 @@ function packageJson(options) {
157
163
  dev: 'tailwindcss -i ./assets/css/source.css -o ./assets/built/screen.css --watch',
158
164
  build: 'tailwindcss -i ./assets/css/source.css -o ./assets/built/screen.css --minify',
159
165
  test: 'node ./scripts/check.mjs',
166
+ zip: 'npm run build && node ./scripts/zip.mjs',
160
167
  validate: gscanCommand[options.packageManager]
161
168
  }
162
169
  : {
163
170
  dev: 'node ./scripts/dev.mjs',
164
171
  build: 'node ./scripts/build.mjs',
165
172
  test: 'node ./scripts/check.mjs',
173
+ zip: 'npm run build && node ./scripts/zip.mjs',
166
174
  validate: gscanCommand[options.packageManager]
167
175
  };
168
176
  const devDependencies = {};
177
+ // Use the selected package manager for the build preceding archive creation.
178
+ scripts.zip = `${options.packageManager} run build && node ./scripts/zip.mjs`;
169
179
  if (options.style === 'tailwind') {
170
180
  devDependencies.tailwindcss = '^4.1.0';
171
181
  devDependencies['@tailwindcss/cli'] = '^4.1.0';
@@ -179,7 +189,7 @@ function packageJson(options) {
179
189
  name: options.authorName || 'Theme Author',
180
190
  email: options.authorEmail || 'hello@example.com'
181
191
  },
182
- engines: { ghost: '>=5.0.0' },
192
+ engines: { ghost: '>=5.54.1', node: options.style === 'tailwind' ? '>=20.0.0' : '>=18.0.0' },
183
193
  license: 'MIT',
184
194
  keywords: ['ghost-theme', 'ghost', 'ghostcn'],
185
195
  scripts,
@@ -209,7 +219,48 @@ ${run} dev
209
219
 
210
220
  Use \`${run} build\` for a production stylesheet, \`${run} test\` for offline scaffold checks, and \`${run} validate\` for official gscan validation (downloads the pinned validator on demand).
211
221
 
212
- Components are copied into \`partials/components\` and \`assets/css/components\`, so you own and can customize every file. Put durable overrides in \`assets/css/source.css\`.
222
+ The dev command only watches CSS. It does not start Ghost or serve this theme.
223
+ Use Node 22.13.1+ or Node 24 for official gscan validation. ${options.style === 'tailwind' ? 'The Tailwind build requires Node 20 or later.' : 'The vanilla build needs Node 18 or later.'}
224
+
225
+ ## Preview in Ghost
226
+
227
+ 1. Install and start a local Ghost development site using the [official guide](https://docs.ghost.org/install/local/).
228
+ 2. Place this entire theme folder under that site's \`content/themes\` directory. Run the commands above from the moved folder.
229
+ 3. From the Ghost installation directory, run \`ghost restart\` so Ghost discovers the new theme.
230
+ 4. Open your site's \`/ghost/\` admin, go to Settings → Design → Change theme, and activate this theme.
231
+ 5. Open the site's URL (usually http://localhost:2368). Keep \`${run} dev\` running and refresh the browser after edits. If Ghost is not running, use \`ghost start\` from its installation directory.
232
+
233
+ Do not edit or replace Ghost's own installation files. For remote Ghost or Ghost(Pro), upload a ZIP instead of using the local preview steps.
234
+
235
+ ## Customize
236
+
237
+ You own the files in \`partials/components\` and \`assets/css/components\`. ${options.style === 'tailwind'
238
+ ? 'Add normal Tailwind classes to the markup, for example `ghcn-button bg-purple-600 hover:bg-purple-700 text-white`. No important modifier is needed for ghostcn defaults. Semantic utilities such as `bg-primary` and `border-border` are configured in `assets/css/ghostcn-tailwind.css`. Put additional CSS in `assets/css/source.css`.'
239
+ : 'Edit the component CSS directly, or put token and selector overrides in `assets/css/source.css`. The built stylesheet loads after ghostcn, so equal-specificity overrides win.'}
240
+
241
+ Prefer per-instance styling parameters over modifying the shared partial:
242
+
243
+ \`\`\`handlebars
244
+ {{> "components/pricing-table"
245
+ class="${options.style === 'tailwind' ? 'mx-auto my-12 w-full max-w-md' : 'membership'}"
246
+ cardClass="${options.style === 'tailwind' ? 'rounded-2xl bg-card p-8 shadow-lg' : 'membership-card'}"
247
+ buttonClass="${options.style === 'tailwind' ? 'bg-purple-600 hover:bg-purple-700 text-white' : 'membership-button'}"
248
+ }}
249
+ \`\`\`
250
+
251
+ Every component accepts \`class\` for its root; named slots (such as \`buttonClass\`, \`titleClass\` and \`inputClass\`) apply to the corresponding internal elements when present. Available slots are listed in the installed partial's opening comment and in the ghostcn documentation. Pricing also accepts \`titleClass\` and \`gridClass\`. ${options.style === 'tailwind' ? 'Keep classes as complete literal strings in scanned .hbs files and keep the dev watcher running.' : 'Define your custom class selectors in assets/css/source.css, matching default specificity where needed.'} Re-adding a component can overwrite its partial/CSS but does not overwrite styling kept in calling templates or source.css. These parameters do not style Ghost-owned Portal, search or comments UI.
252
+
253
+ Membership UI follows Ghost's enabled/invite-only/paid settings. Pricing comes from public tiers configured in Ghost Admin; payments must be configured before paid plans appear. The custom \`partials/content-cta.hbs\` renders one paywall for protected posts without exposing restricted content.
254
+
255
+ ## Package for upload
256
+
257
+ \`\`\`bash
258
+ ${run} test
259
+ ${run} validate
260
+ ${run} zip
261
+ \`\`\`
262
+
263
+ The zip command builds first, then writes \`dist/${options.themeName}-1.0.0.zip\` (the filename follows package.json's version). It contains runtime templates and assets, not node_modules, scripts, lockfiles, or repository metadata. Re-running replaces that generated ZIP. Upload it in Ghost Admin → Settings → Design → Change theme → Upload theme. Offline checks do not replace gscan or testing on your target Ghost version (minimum 5.54.1).
213
264
  `;
214
265
  }
215
266
  const vanillaBuildScript = `import { copyFileSync, mkdirSync } from 'node:fs';
@@ -227,25 +278,6 @@ watch(source, () => {
227
278
  timer = setTimeout(() => import('./build.mjs?' + Date.now()), 50);
228
279
  });
229
280
  `;
230
- const checkScript = `import { existsSync, readFileSync } from 'node:fs';
231
- const required = ['package.json', 'default.hbs', 'index.hbs', 'post.hbs', 'page.hbs', 'assets/css/ghostcn.css', 'assets/built/screen.css'];
232
- const missing = required.filter(file => !existsSync(new URL('../' + file, import.meta.url)));
233
- if (missing.length) {
234
- console.error('Missing required theme files:', missing.join(', '));
235
- process.exit(1);
236
- }
237
- const layout = readFileSync(new URL('../default.hbs', import.meta.url), 'utf8');
238
- if (!layout.includes('{{ghost_head}}') || !layout.includes('{{ghost_foot}}')) {
239
- console.error('default.hbs must include {{ghost_head}} and {{ghost_foot}}.');
240
- process.exit(1);
241
- }
242
- const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
243
- if (!pkg.engines?.ghost || !pkg.author?.email) {
244
- console.error('package.json must define engines.ghost and author.email.');
245
- process.exit(1);
246
- }
247
- console.log('Theme scaffold checks passed.');
248
- `;
249
281
  function scaffoldTheme(options) {
250
282
  const themeName = sanitizeThemeName(options.themeName);
251
283
  const parent = path_1.default.resolve(options.parentDirectory);
@@ -259,19 +291,22 @@ function scaffoldTheme(options) {
259
291
  fs_1.default.mkdirSync(themeRoot, { recursive: true });
260
292
  const css = baseThemeCss();
261
293
  const sourceCss = options.style === 'tailwind'
262
- ? `@import "tailwindcss";\n@source "../../**/*.hbs";\n\n${css}`
294
+ ? `@import "tailwindcss";\n@source "../../**/*.hbs";\n@import "./ghostcn-tailwind.css";\n\n@layer base {\n${css}}\n`
263
295
  : css;
264
296
  const files = {
265
297
  'package.json': packageJson({ ...options, themeName }),
266
298
  'default.hbs': defaultTemplate(options.colorScheme),
267
299
  'index.hbs': indexTemplate(options),
268
300
  'post.hbs': postTemplate(options),
301
+ 'partials/content-cta.hbs': '{{{html}}}\n{{> "components/member-cta"}}\n',
269
302
  'page.hbs': pageTemplate(),
270
303
  'tag.hbs': archiveTemplate('tag'),
271
304
  'author.hbs': archiveTemplate('author'),
272
305
  'assets/css/source.css': sourceCss,
273
306
  'assets/built/screen.css': css,
274
- 'scripts/check.mjs': checkScript,
307
+ 'scripts/check.mjs': "import { fileURLToPath } from 'node:url';\nimport { reportTheme } from './theme-tools.mjs';\nif (!reportTheme(fileURLToPath(new URL('../', import.meta.url)))) process.exitCode = 1;\n",
308
+ 'scripts/zip.mjs': "import { fileURLToPath } from 'node:url';\nimport { packageTheme } from './theme-tools.mjs';\nconsole.log('Created ' + packageTheme(fileURLToPath(new URL('../', import.meta.url))).output);\n",
309
+ 'scripts/theme-tools.mjs': fs_1.default.readFileSync((0, theme_tooling_1.themeToolPath)(), 'utf8'),
275
310
  '.gitignore': 'node_modules\n*.zip\n.DS_Store\n',
276
311
  'README.md': readme(options)
277
312
  };
@@ -279,6 +314,8 @@ function scaffoldTheme(options) {
279
314
  files['scripts/build.mjs'] = vanillaBuildScript;
280
315
  files['scripts/dev.mjs'] = vanillaDevScript;
281
316
  }
317
+ if (options.style === 'tailwind')
318
+ files['assets/css/ghostcn-tailwind.css'] = (0, styles_1.tailwindTheme)();
282
319
  for (const [relativePath, content] of Object.entries(files)) {
283
320
  const target = (0, theme_files_1.resolveWithinTheme)(themeRoot, relativePath);
284
321
  fs_1.default.mkdirSync(path_1.default.dirname(target), { recursive: true });
@@ -0,0 +1,2 @@
1
+ export declare function themeToolPath(): string;
2
+ export declare function runThemeTool(action: 'doctor' | 'pack', themeRoot: string): number;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.themeToolPath = themeToolPath;
7
+ exports.runThemeTool = runThemeTool;
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const child_process_1 = require("child_process");
11
+ function themeToolPath() {
12
+ const bundled = path_1.default.join(__dirname, '../templates/theme-tools.mjs');
13
+ return fs_1.default.existsSync(bundled) ? bundled : path_1.default.join(__dirname, '../../templates/theme-tools.mjs');
14
+ }
15
+ function runThemeTool(action, themeRoot) {
16
+ const result = (0, child_process_1.spawnSync)(process.execPath, [themeToolPath(), action, themeRoot], { stdio: 'inherit' });
17
+ if (result.error)
18
+ console.error(result.error.message);
19
+ return result.status ?? 1;
20
+ }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ACCENT_COLORS = exports.BASE_PALETTES = void 0;
4
4
  exports.generateThemeCss = generateThemeCss;
5
+ const styles_1 = require("./styles");
5
6
  exports.BASE_PALETTES = {
6
7
  zinc: {
7
8
  light: {
@@ -271,7 +272,7 @@ function generateThemeCss(config) {
271
272
  --border: ${base.dark.border};
272
273
  --input: ${base.dark.input};
273
274
  --ring: ${accent.dark.ring || base.dark.ring};`;
274
- return `/*
275
+ const css = `/*
275
276
  ghostcn Design Tokens & Theming System
276
277
  Base: ${config.baseColor} | Accent: ${config.accentColor} | Radius: ${radius} | System: ${config.style}
277
278
  */
@@ -315,7 +316,7 @@ function generateThemeCss(config) {
315
316
  }
316
317
  }
317
318
 
318
- /* ghostcn Semantic Utilities (Guarantees zero-breakage across Tailwind & Vanilla CSS) */
319
+ /* Semantic fallbacks; Tailwind utilities can override these defaults. */
319
320
  .bg-background { background-color: var(--background); }
320
321
  .text-foreground { color: var(--foreground); }
321
322
  .bg-card { background-color: var(--card); }
@@ -424,4 +425,5 @@ function generateThemeCss(config) {
424
425
  border: 0;
425
426
  }
426
427
  `;
428
+ return (0, styles_1.componentCss)(css, config.style);
427
429
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ghostcn",
3
- "version": "1.1.0",
3
+ "version": "1.4.0",
4
4
  "description": "The shadcn/ui for Ghost CMS themes - component distribution system",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "README.md"
15
15
  ],
16
16
  "scripts": {
17
- "build": "tsc && node -e \"const fs=require('fs'); const path=require('path'); if(fs.existsSync('../../registry')){fs.cpSync('../../registry', 'dist/registry', {recursive:true});} if(fs.existsSync('../../README.md')){fs.copyFileSync('../../README.md', 'README.md');}\"",
17
+ "build": "tsc && node -e \"const fs=require('fs'); fs.cpSync('templates', 'dist/templates', {recursive:true}); if(fs.existsSync('../../registry')){fs.cpSync('../../registry', 'dist/registry', {recursive:true});} if(fs.existsSync('../../README.md')){fs.copyFileSync('../../README.md', 'README.md');}\"",
18
18
  "prepublishOnly": "npm run build",
19
19
  "start": "ts-node src/index.ts",
20
20
  "dev": "ts-node src/index.ts",
@@ -42,12 +42,14 @@
42
42
  },
43
43
  "homepage": "https://github.com/Geekbits-Org/ghost-ui#readme",
44
44
  "dependencies": {
45
+ "handlebars": "^4.7.9",
45
46
  "chalk": "^4.1.2",
46
47
  "commander": "^12.0.0",
47
- "prompts": "^2.4.2",
48
- "ora": "^5.4.1"
48
+ "ora": "^5.4.1",
49
+ "prompts": "^2.4.2"
49
50
  },
50
51
  "devDependencies": {
52
+ "@tailwindcss/cli": "^4.3.3",
51
53
  "@types/node": "^20.11.24",
52
54
  "@types/prompts": "^2.4.9",
53
55
  "ts-node": "^10.9.2",