ghostcn 1.1.0 β 1.2.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 +44 -3
- package/dist/commands/create.js +8 -1
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +7 -0
- package/dist/commands/init.js +5 -0
- package/dist/commands/pack.d.ts +1 -0
- package/dist/commands/pack.js +8 -0
- package/dist/index.js +4 -0
- package/dist/registry/components/member-cta.json +1 -1
- package/dist/registry/components/newsletter-form.json +1 -1
- package/dist/registry/components/pricing-table.json +5 -5
- package/dist/registry/components/site-header.json +2 -2
- package/dist/templates/theme-tools.mjs +178 -0
- package/dist/utils/component-installer.js +2 -1
- package/dist/utils/styles.d.ts +3 -0
- package/dist/utils/styles.js +20 -0
- package/dist/utils/theme-files.js +5 -1
- package/dist/utils/theme-project.js +9 -4
- package/dist/utils/theme-scaffold.js +49 -24
- package/dist/utils/theme-tooling.d.ts +2 -0
- package/dist/utils/theme-tooling.js +20 -0
- package/dist/utils/theme.js +4 -2
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
<a href="https://www.npmjs.com/package/ghostcn"><img src="https://img.shields.io/npm/v/ghostcn?color=6366f1&style=flat-square" alt="npm version" /></a>
|
|
10
10
|
<a href="https://www.npmjs.com/package/ghostcn"><img src="https://img.shields.io/npm/dm/ghostcn?color=3b82f6&style=flat-square" alt="npm downloads" /></a>
|
|
11
11
|
<a href="https://ghost.org"><img src="https://img.shields.io/badge/Ghost-%3E%3D5.0.0-15171a?style=flat-square" alt="Ghost Version" /></a>
|
|
12
|
-
<a href="https://gscan.ghost.org"><img src="https://img.shields.io/badge/gscan-100%25%20valid-22c55e?style=flat-square" alt="gscan validation" /></a>
|
|
13
12
|
<a href="https://github.com/Geekbits-Org/ghost-ui/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="License" /></a>
|
|
14
13
|
</p>
|
|
15
14
|
|
|
@@ -32,7 +31,7 @@ You own the code. You customize the classes. Zero vendor lock-in.
|
|
|
32
31
|
- π― **Interactive Multi-Select**: Run `npx ghostcn add` without arguments to select and batch-install multiple components interactively.
|
|
33
32
|
- π¨ **Tailwind & Vanilla CSS**: Pre-styled with utility classes and full Vanilla CSS stylesheets with Ghost CSS custom properties.
|
|
34
33
|
- π **Ghost Members API**: Native support for Ghost attributes (`data-members-form="subscribe"`, Portal checkout triggers).
|
|
35
|
-
- π‘οΈ **
|
|
34
|
+
- π‘οΈ **Theme validation**: Generated themes include offline diagnostics and official gscan validation. Validate your customized theme against your target Ghost version before shipping.
|
|
36
35
|
|
|
37
36
|
---
|
|
38
37
|
|
|
@@ -41,7 +40,7 @@ You own the code. You customize the classes. Zero vendor lock-in.
|
|
|
41
40
|
| Component | Description | Files |
|
|
42
41
|
| :--- | :--- | :--- |
|
|
43
42
|
| **`newsletter-form`** | Native Ghost members subscription form with success/error states | `newsletter-form.hbs`, `newsletter-form.css` |
|
|
44
|
-
| **`pricing-table`** |
|
|
43
|
+
| **`pricing-table`** | Public Ghost tiers with live prices, currencies, benefits and tier-specific Portal checkout | `pricing-table.hbs`, `pricing-table.css` |
|
|
45
44
|
| **`author-card`** | Author bio box with avatar, biography, social links, and post counts | `author-card.hbs`, `author-card.css` |
|
|
46
45
|
| **`post-card`** | Post loop preview card with feature image, tags, excerpt, and reading time | `post-card.hbs`, `post-card.css` |
|
|
47
46
|
| **`site-header`** | Responsive navigation with search, mobile menu, sign-in, and subscribe actions | `site-header.hbs`, `site-header.css` |
|
|
@@ -80,6 +79,48 @@ npm run dev
|
|
|
80
79
|
|
|
81
80
|
Generated themes also include `npm test` for offline scaffold checks and `npm run validate` for official, pinned gscan validation. The validator is downloaded only when requested, keeping validator-only dependencies out of the day-to-day theme install.
|
|
82
81
|
|
|
82
|
+
`npm run dev` watches CSS; it does **not** start Ghost. To preview, place the theme folder under a local Ghost installation's `content/themes`, restart Ghost from its installation directory, activate the theme in Ghost Admin β Settings β Design β Change theme, then visit your site's URL. Follow the [local Ghost setup guide](https://docs.ghost.org/install/local/) if you do not have an installation yet. Generated starters require Ghost 5.54.1+; use Node 22.13.1+ or Node 24 for gscan (Tailwind builds need Node 20+).
|
|
83
|
+
|
|
84
|
+
Build, validate and package for a remote site:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm test
|
|
88
|
+
npm run validate
|
|
89
|
+
npm run zip
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The ZIP is written to `dist/<theme-name>-<version>.zip`, with runtime templates and assets at its root. It excludes dependencies, scripts, lockfiles and repository metadata. Upload it in Ghost Admin's theme picker. Re-running replaces the generated ZIP.
|
|
93
|
+
|
|
94
|
+
For an existing theme, run `npx ghostcn doctor` to check configuration, linked assets, partials and Ghost hooks. After running **your theme's build**, `npx ghostcn pack` packages it without invoking or changing its build system. Doctor is an offline diagnostic, not a replacement for gscan or browser testing.
|
|
95
|
+
|
|
96
|
+
### Styling components
|
|
97
|
+
|
|
98
|
+
For a generated Tailwind theme, customize the markup with ordinary utilities:
|
|
99
|
+
|
|
100
|
+
```handlebars
|
|
101
|
+
<a class="ghcn-button bg-purple-600 hover:bg-purple-700 text-white" href="#/portal/signup" data-portal="signup">Subscribe</a>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
No `!` modifier is required to override ghostcn defaults. Component styles and primitives use Tailwind's `components` layer; utilities take precedence, even if a component stylesheet loads later. Semantic colors (`bg-primary`, `text-muted-foreground`, `border-border`, `ring-ring`) and `rounded-ghostcn` are mapped by `assets/css/ghostcn-tailwind.css`. Ghost's explicit and automatic dark modes are supported.
|
|
105
|
+
|
|
106
|
+
For **existing Tailwind v4 themes**, import the generated `ghostcn-tailwind.css` into your Tailwind source and make sure the build scans `.hbs` files. For example, when using `assets/css/source.css`:
|
|
107
|
+
|
|
108
|
+
```css
|
|
109
|
+
@import "tailwindcss";
|
|
110
|
+
@import "./ghostcn-tailwind.css";
|
|
111
|
+
@source "../../**/*.hbs";
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`init` and `add` do not replace an existing theme's build pipeline. Unlayered host CSS can still override layered styles; place such host rules in an appropriate lower layer or adjust your theme deliberately. Older Tailwind builds must configure their own semantic token mappings.
|
|
115
|
+
|
|
116
|
+
Vanilla themes ship standalone CSS: edit component files or put token and selector overrides in `assets/css/source.css`. The generated build stylesheet loads after ghostcn defaults. On an existing theme, link your override stylesheet after the managed ghostcn block.
|
|
117
|
+
|
|
118
|
+
Membership components respect disabled, invite-only and self-signup settings. Paid pricing is shown only when Ghost enables paid membership, using active public tiers configured in Ghost Adminβnot sample amounts or invented benefits. The starter uses `partials/content-cta.hbs` for one custom paywall; adding `member-cta` below native `{{content}}` on an existing protected post can otherwise duplicate Ghost's paywall. Follow the starter pattern rather than rendering both.
|
|
119
|
+
|
|
120
|
+
### Updating an existing ghostcn theme
|
|
121
|
+
|
|
122
|
+
Your copied files are yours; an npm update does not silently rewrite them. Back up or commit your theme first. Compare the new components in a fresh throwaway theme, then merge the changes you want. To replace unmodified files directly, run `ghostcn init` with your existing palette/paths and re-add the relevant components. Initialization regenerates tokens; `add -y` overwrites component customizations, so use it only deliberately. Existing Tailwind styles from older ghostcn releases are unlayered and need the new token/component CSS for ordinary utility overrides to work.
|
|
123
|
+
|
|
83
124
|
### 1. Initialize your Ghost Theme
|
|
84
125
|
|
|
85
126
|
Run the `init` command from the root of any Ghost theme (must have `engines.ghost` in its `package.json`):
|
package/dist/commands/create.js
CHANGED
|
@@ -91,15 +91,22 @@ async function create(themeNameArgument, options = {}) {
|
|
|
91
91
|
shell: process.platform === 'win32'
|
|
92
92
|
});
|
|
93
93
|
if (installed.status !== 0) {
|
|
94
|
+
process.exitCode = 1;
|
|
95
|
+
installDependencies = false;
|
|
94
96
|
console.warn(chalk_1.default.yellow(`Dependency installation did not finish. The generated theme is intact; run "${packageManager} install" inside it.`));
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
const run = packageManager === 'npm' ? 'npm run' : `${packageManager} run`;
|
|
98
|
-
console.log(`\n${chalk_1.default.bold.green('Your Ghost theme
|
|
100
|
+
console.log(`\n${chalk_1.default.bold.green('Your Ghost theme files are ready.')}`);
|
|
99
101
|
console.log(` ${chalk_1.default.cyan(`cd ${path_1.default.basename(scaffold.themeRoot)}`)}`);
|
|
100
102
|
if (!installDependencies)
|
|
101
103
|
console.log(` ${chalk_1.default.cyan(`${packageManager} install`)}`);
|
|
102
104
|
console.log(` ${chalk_1.default.cyan(`${run} dev`)}\n`);
|
|
105
|
+
console.log('The dev command watches CSS; it does not start Ghost.');
|
|
106
|
+
console.log('Move this folder into your local Ghost content/themes directory, restart Ghost,');
|
|
107
|
+
console.log('then activate the theme in Ghost Admin β Settings β Design β Change theme.');
|
|
108
|
+
console.log(`Open your Ghost site to preview. See README.md for the full workflow.`);
|
|
109
|
+
console.log(`For upload: ${run} test β ${run} validate β ${run} zip.\n`);
|
|
103
110
|
}
|
|
104
111
|
catch (error) {
|
|
105
112
|
spinner.fail(chalk_1.default.red(error.message));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function doctor(): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doctor = doctor;
|
|
4
|
+
const theme_tooling_1 = require("../utils/theme-tooling");
|
|
5
|
+
function doctor() {
|
|
6
|
+
process.exitCode = (0, theme_tooling_1.runThemeTool)('doctor', process.cwd());
|
|
7
|
+
}
|
package/dist/commands/init.js
CHANGED
|
@@ -170,4 +170,9 @@ async function init(options = {}) {
|
|
|
170
170
|
}
|
|
171
171
|
console.log(` ${chalk_1.default.cyan('npx ghostcn add')}`);
|
|
172
172
|
console.log(` ${chalk_1.default.cyan('npx ghostcn add newsletter-form')}\n`);
|
|
173
|
+
if (style === 'tailwind') {
|
|
174
|
+
console.log('Component defaults use @layer components so normal Tailwind utilities can override them.');
|
|
175
|
+
console.log('For Tailwind v4 semantic utilities, import ghostcn-tailwind.css from your Tailwind source.');
|
|
176
|
+
console.log('Existing themes must already have a Tailwind build scanning their .hbs files; init does not replace their build system.');
|
|
177
|
+
}
|
|
173
178
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pack(): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pack = pack;
|
|
4
|
+
const theme_tooling_1 = require("../utils/theme-tooling");
|
|
5
|
+
function pack() {
|
|
6
|
+
console.log('Build your theme first. This command packages existing runtime files only.');
|
|
7
|
+
process.exitCode = (0, theme_tooling_1.runThemeTool)('pack', process.cwd());
|
|
8
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,8 @@ const init_1 = require("./commands/init");
|
|
|
9
9
|
const add_1 = require("./commands/add");
|
|
10
10
|
const list_1 = require("./commands/list");
|
|
11
11
|
const create_1 = require("./commands/create");
|
|
12
|
+
const doctor_1 = require("./commands/doctor");
|
|
13
|
+
const pack_1 = require("./commands/pack");
|
|
12
14
|
const package_json_1 = __importDefault(require("../package.json"));
|
|
13
15
|
function main() {
|
|
14
16
|
const program = new commander_1.Command()
|
|
@@ -37,6 +39,8 @@ function main() {
|
|
|
37
39
|
.argument('[component]', 'The component to add (leave blank for interactive selection)')
|
|
38
40
|
.option('-y, --yes', 'Overwrite existing files without prompting')
|
|
39
41
|
.action(add_1.add);
|
|
42
|
+
program.command('doctor').description('Check theme configuration, local assets, partials and build readiness').action(doctor_1.doctor);
|
|
43
|
+
program.command('pack').description('Package built theme runtime files as a Ghost-uploadable ZIP').action(pack_1.pack);
|
|
40
44
|
program.parse();
|
|
41
45
|
}
|
|
42
46
|
main();
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"name": "member-cta.hbs",
|
|
10
10
|
"type": "partial",
|
|
11
11
|
"target": "partials/components/member-cta.hbs",
|
|
12
|
-
"content": "{{!-- Component: Member CTA | Usage: inside {{#post}} after {{content}} --}}\n<aside class=\"ghcn-member-cta\">\n {{#if access}}\n {{#if @member}}\n <span class=\"ghcn-badge\">Member access</span>\n <h2>Youβre all caught up</h2>\n <p>Manage your subscription, email preferences, and account details in Portal.</p>\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Manage account</a>\n {{else}}\n <span class=\"ghcn-badge\">Join the publication</span>\n <h2>Enjoying this story?</h2>\n <p>Subscribe for new posts and member updates delivered directly to your inbox.</p>\n <div class=\"ghcn-member-cta__actions\"><a class=\"ghcn-button\" href=\"#/portal/signup\" data-portal=\"signup\">Subscribe</a><a class=\"ghcn-button ghcn-button--ghost\" href=\"#/portal/signin\" data-portal=\"signin\">Sign in</a></div>\n {{/if}}\n {{else}}\n {{#if @member.paid}}\n <span class=\"ghcn-badge\">Account required</span>\n <h2>This post isnβt included in your plan</h2>\n <p>Open your account to review your membership and available plans.</p>\n <a class=\"ghcn-button\" href=\"#/portal/account
|
|
12
|
+
"content": "{{!-- Component: Member CTA | Usage: inside {{#post}} after {{content}} --}}\n{{#if @site.members_enabled}}\n<aside class=\"ghcn-member-cta\">\n {{#if access}}\n {{#if @member}}\n <span class=\"ghcn-badge\">Member access</span>\n <h2>Youβre all caught up</h2>\n <p>Manage your subscription, email preferences, and account details in Portal.</p>\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Manage account</a>\n {{else}}\n {{#if @site.allow_self_signup}}\n <span class=\"ghcn-badge\">Join the publication</span>\n <h2>Enjoying this story?</h2>\n <p>Subscribe for new posts and member updates delivered directly to your inbox.</p>\n <div class=\"ghcn-member-cta__actions\"><a class=\"ghcn-button\" href=\"#/portal/signup\" data-portal=\"signup\">Subscribe</a><a class=\"ghcn-button ghcn-button--ghost\" href=\"#/portal/signin\" data-portal=\"signin\">Sign in</a></div>\n {{else}}\n <h2>Already a member?</h2>\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/signin\" data-portal=\"signin\">Sign in</a>\n {{/if}}\n {{/if}}\n {{else}}\n {{#if @member.paid}}\n <span class=\"ghcn-badge\">Account required</span>\n <h2>This post isnβt included in your plan</h2>\n <p>Open your account to review your membership and available plans.</p>\n <a class=\"ghcn-button\" href=\"#/portal/account\" data-portal=\"account\">Manage account</a>\n {{else if @member}}\n {{#if @site.paid_members_enabled}}\n {{#if @site.allow_self_signup}}\n <span class=\"ghcn-badge\">Paid members</span>\n <h2>Upgrade to continue reading</h2>\n <p>Review the available plans to find one that includes this post.</p>\n <a class=\"ghcn-button\" href=\"#/portal/account/plans\" data-portal=\"account/plans\">Upgrade membership</a>\n {{else}}\n <h2>This post requires a different membership</h2>\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Manage account</a>\n {{/if}}\n {{else}}\n <h2>This post is not available with your membership</h2>\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Manage account</a>\n {{/if}}\n {{else}}\n <span class=\"ghcn-badge\">Members only</span>\n <h2>Continue reading with a membership</h2>\n <p>This post requires a membership with access. Already a member? Sign in to continue.</p>\n <div class=\"ghcn-member-cta__actions\">{{#if @site.allow_self_signup}}<a class=\"ghcn-button\" href=\"#/portal/signup\" data-portal=\"signup\">View memberships</a>{{/if}}<a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/signin\" data-portal=\"signin\">Sign in</a></div>\n {{/if}}\n {{/if}}\n</aside>\n{{/if}}"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "member-cta.css",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"name": "newsletter-form.hbs",
|
|
10
10
|
"type": "partial",
|
|
11
11
|
"target": "partials/components/newsletter-form.hbs",
|
|
12
|
-
"content": "{{!--\n Component: Newsletter Form\n Usage: {{> \"components/newsletter-form\" title=\"Subscribe to our newsletter\" description=\"Get the latest posts delivered right to your inbox.\"}}\n--}}\n<section class=\"gh-newsletter-form bg-card text-card-foreground border border-border p-8 rounded-ghostcn text-center max-w-2xl mx-auto my-8 shadow-sm\">\n <div class=\"mb-6\">\n <h3 class=\"gh-newsletter-title text-2xl font-bold tracking-tight mb-2 text-foreground\">\n {{#if title}}{{title}}{{else}}Subscribe to our newsletter{{/if}}\n </h3>\n <p class=\"gh-newsletter-desc text-muted-foreground max-w-md mx-auto text-sm leading-relaxed\">\n {{#if description}}{{description}}{{else}}Get the latest stories, news, and perspectives delivered directly to your inbox.{{/if}}\n </p>\n </div>\n\n {{!-- Ghost native members form handling --}}\n <form data-members-form=\"subscribe\" class=\"gh-newsletter-fields flex flex-col sm:flex-row gap-3 max-w-md mx-auto relative\">\n <
|
|
12
|
+
"content": "{{!--\n Component: Newsletter Form\n Usage: {{> \"components/newsletter-form\" title=\"Subscribe to our newsletter\" description=\"Get the latest posts delivered right to your inbox.\"}}\n--}}\n{{#if @site.members_enabled}}\n{{#unless @site.members_invite_only}}\n{{#if @site.allow_self_signup}}\n{{#unless @member}}\n<section class=\"gh-newsletter-form bg-card text-card-foreground border border-border p-8 rounded-ghostcn text-center max-w-2xl mx-auto my-8 shadow-sm\">\n <div class=\"mb-6\">\n <h3 class=\"gh-newsletter-title text-2xl font-bold tracking-tight mb-2 text-foreground\">\n {{#if title}}{{title}}{{else}}Subscribe to our newsletter{{/if}}\n </h3>\n <p class=\"gh-newsletter-desc text-muted-foreground max-w-md mx-auto text-sm leading-relaxed\">\n {{#if description}}{{description}}{{else}}Get the latest stories, news, and perspectives delivered directly to your inbox.{{/if}}\n </p>\n </div>\n\n {{!-- Ghost native members form handling --}}\n {{#if @site.portal_signup_checkbox_required}}\n <a class=\"ghcn-button\" href=\"#/portal/signup\" data-portal=\"signup\">Subscribe</a>\n {{else}}\n <form data-members-form=\"subscribe\" class=\"gh-newsletter-fields flex flex-col sm:flex-row gap-3 max-w-md mx-auto relative\">\n <input\n data-members-email\n type=\"email\"\n aria-label=\"Email address\"\n autocomplete=\"email\"\n required\n placeholder=\"jamie@example.com\"\n class=\"gh-newsletter-input flex-1 px-4 py-2.5 bg-background text-foreground border border-input rounded-ghostcn text-sm focus:outline-none focus:ring-2 focus:ring-ring transition-shadow\"\n />\n <button type=\"submit\" class=\"gh-newsletter-btn bg-primary text-primary-foreground px-6 py-2.5 rounded-ghostcn text-sm font-medium hover:opacity-90 transition-opacity flex items-center justify-center shadow-sm\">\n <span class=\"button-text\">Subscribe</span>\n </button>\n\n {{!-- Ghost automatic states (hidden by default, shown via Ghost Portal JS) --}}\n <div class=\"gh-newsletter-msg-success message-success absolute -bottom-7 left-0 right-0 text-xs text-green-600 dark:text-green-400 font-medium\" role=\"status\" data-members-success>\n β Check your inbox to confirm your subscription!\n </div>\n <div class=\"gh-newsletter-msg-error message-error absolute -bottom-7 left-0 right-0 text-xs text-red-600 dark:text-red-400 font-medium\" role=\"alert\" data-members-error>\n β Please enter a valid email address.\n </div>\n </form>\n {{/if}}\n</section>\n{{/unless}}\n{{/if}}\n{{/unless}}\n{{/if}}"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "newsletter-form.css",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pricing-table",
|
|
3
|
-
"type": "components:
|
|
4
|
-
"description": "
|
|
3
|
+
"type": "components:members",
|
|
4
|
+
"description": "Live Ghost tiers, prices, currencies and benefits with tier-specific Portal checkout.",
|
|
5
5
|
"dependencies": [],
|
|
6
6
|
"ghost_version": ">=5.0.0",
|
|
7
7
|
"files": [
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
"name": "pricing-table.hbs",
|
|
10
10
|
"type": "partial",
|
|
11
11
|
"target": "partials/components/pricing-table.hbs",
|
|
12
|
-
"content": "{{
|
|
12
|
+
"content": "{{!-- Component: Pricing Table | Usage: {{> \"components/pricing-table\"}} --}}\n{{#if @site.members_enabled}}\n{{#unless @site.members_invite_only}}\n{{#if @site.allow_self_signup}}\n<section class=\"gh-pricing\" aria-label=\"Membership plans\">\n <h2 class=\"gh-pricing-title\">{{#if title}}{{title}}{{else}}Choose your membership{{/if}}</h2>\n <div class=\"gh-pricing-grid\">\n {{#get \"tiers\" filter=\"visibility:public+active:true\" include=\"monthly_price,yearly_price,benefits\"}}\n {{#foreach tiers}}\n {{#match type \"free\"}}\n <article class=\"gh-pricing-card\">\n <h3>{{name}}</h3>\n {{#if description}}<p>{{description}}</p>{{/if}}\n <p class=\"gh-pricing-price\">Free</p>\n {{#if benefits}}<ul>{{#foreach benefits}}<li>{{this}}</li>{{/foreach}}</ul>{{/if}}\n {{#if @member}}<a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Manage account</a>\n {{else}}<a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/signup/free\" data-portal=\"signup/free\">Join free</a>{{/if}}\n </article>\n {{else}}\n {{#if @site.paid_members_enabled}}\n <article class=\"gh-pricing-card\">\n <h3>{{name}}</h3>\n {{#if description}}<p>{{description}}</p>{{/if}}\n {{#if benefits}}<ul>{{#foreach benefits}}<li>{{this}}</li>{{/foreach}}</ul>{{/if}}\n {{#if monthly_price}}<p class=\"gh-pricing-price\">{{price monthly_price currency=currency}} <span>/ month</span></p>{{/if}}\n {{#if yearly_price}}<p class=\"gh-pricing-price\">{{price yearly_price currency=currency}} <span>/ year</span></p>{{/if}}\n <div class=\"gh-pricing-actions\">\n {{#if @member}}\n <a class=\"ghcn-button\" href=\"#/portal/account/plans\" data-portal=\"account/plans\">{{#if @member.paid}}Manage plan{{else}}Upgrade membership{{/if}}</a>\n {{else}}\n {{#if monthly_price}}<a class=\"ghcn-button\" href=\"#/portal/signup/{{id}}/monthly\" data-portal=\"signup/{{id}}/monthly\">Subscribe monthly</a>{{/if}}\n {{#if yearly_price}}<a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/signup/{{id}}/yearly\" data-portal=\"signup/{{id}}/yearly\">Subscribe yearly</a>{{/if}}\n {{/if}}\n </div>\n </article>\n {{/if}}\n {{/match}}\n {{/foreach}}\n {{else}}\n <p>Membership plans are currently unavailable.</p>\n {{/get}}\n </div>\n</section>\n{{/if}}\n{{/unless}}\n{{/if}}"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "pricing-table.css",
|
|
16
16
|
"type": "style",
|
|
17
17
|
"target": "assets/css/components/pricing-table.css",
|
|
18
|
-
"content": "/* ghostcn:
|
|
18
|
+
"content": "/* ghostcn: live membership pricing */\n.gh-pricing { box-sizing: border-box; width: min(100% - 2em, 72em); margin: 3em auto; color: var(--foreground); font-size: 16px; line-height: 1.5; }\n.gh-pricing *, .gh-pricing *::before, .gh-pricing *::after { box-sizing: border-box; }\n.gh-pricing-title { margin: 0 0 1.5em; text-align: center; font-size: 2em; }\n.gh-pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18em), 1fr)); gap: 1.25em; }\n.gh-pricing-card { display: flex; flex-direction: column; gap: 1em; padding: 1.5em; border: 1px solid var(--border); border-radius: min(var(--radius), 1.5em); background: var(--card); color: var(--card-foreground); }\n.gh-pricing-card h3 { margin: 0; font-size: 1.25em; }\n.gh-pricing-card p { margin: 0; }\n.gh-pricing-card ul { margin: 0; padding-left: 1.25em; color: var(--muted-foreground); }\n.gh-pricing-price { font-size: 1.75em; font-weight: 700; }\n.gh-pricing-price span { font-size: 0.875em; font-weight: 400; color: var(--muted-foreground); }\n.gh-pricing-actions { display: flex; flex-wrap: wrap; gap: 0.5em; margin-top: auto; }\n"
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"gscan": {
|
|
22
22
|
"rules_satisfied": [
|
|
23
23
|
"GS010-PJ-VALID"
|
|
24
24
|
],
|
|
25
|
-
"notes": "
|
|
25
|
+
"notes": "Reads public Ghost tiers; no placeholder pricing or invented benefits."
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"name": "site-header.hbs",
|
|
10
10
|
"type": "partial",
|
|
11
11
|
"target": "partials/components/site-header.hbs",
|
|
12
|
-
"content": "{{!-- Component: Site Header | Usage: {{> \"components/site-header\"}} --}}\n<header class=\"ghcn-header\">\n <div class=\"ghcn-header__inner ghcn-container\">\n <a class=\"ghcn-header__brand\" href=\"{{@site.url}}\" aria-label=\"{{@site.title}} home\">\n {{#if @site.logo}}\n <img src=\"{{@site.logo}}\" alt=\"{{@site.title}}\" />\n {{else}}\n <span>{{@site.title}}</span>\n {{/if}}\n </a>\n\n <nav class=\"ghcn-header__nav\" aria-label=\"Primary navigation\">{{navigation}}</nav>\n\n <div class=\"ghcn-header__actions\">\n {{search}}\n {{#if @member}}\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Account</a>\n {{else}}\n <a class=\"ghcn-header__signin\" href=\"#/portal/signin\" data-portal=\"signin\">Sign in</a>\n <a class=\"ghcn-button\" href=\"#/portal/signup\" data-portal=\"signup\">Subscribe</a>\n {{/if}}\n </div>\n\n <details class=\"ghcn-header__mobile\">\n <summary class=\"ghcn-icon-button ghcn-button--outline\" aria-label=\"Open navigation\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" width=\"20\" height=\"20\"><path d=\"M4 7h16M4 12h16M4 17h16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>\n </summary>\n <div class=\"ghcn-header__panel\">\n <nav aria-label=\"Mobile navigation\">{{navigation}}</nav>\n <div class=\"ghcn-header__mobile-actions\">\n {{search}}\n {{#if @member}}\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Account</a>\n {{else}}\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/signin\" data-portal=\"signin\">Sign in</a>\n <a class=\"ghcn-button\" href=\"#/portal/signup\" data-portal=\"signup\">Subscribe</a>\n {{/if}}\n </div>\n </div>\n </details>\n </div>\n</header>"
|
|
12
|
+
"content": "{{!-- Component: Site Header | Usage: {{> \"components/site-header\"}} --}}\n<header class=\"ghcn-header\">\n <div class=\"ghcn-header__inner ghcn-container\">\n <a class=\"ghcn-header__brand\" href=\"{{@site.url}}\" aria-label=\"{{@site.title}} home\">\n {{#if @site.logo}}\n <img src=\"{{@site.logo}}\" alt=\"{{@site.title}}\" />\n {{else}}\n <span>{{@site.title}}</span>\n {{/if}}\n </a>\n\n <nav class=\"ghcn-header__nav\" aria-label=\"Primary navigation\">{{navigation}}</nav>\n\n <div class=\"ghcn-header__actions\">\n {{search}}\n {{#if @site.members_enabled}}\n {{#if @member}}\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Account</a>\n {{else}}\n <a class=\"ghcn-header__signin\" href=\"#/portal/signin\" data-portal=\"signin\">Sign in</a>\n {{#unless @site.members_invite_only}}\n {{#if @site.allow_self_signup}}\n <a class=\"ghcn-button\" href=\"#/portal/signup\" data-portal=\"signup\">Subscribe</a>\n {{/if}}\n {{/unless}}\n {{/if}}\n {{/if}}\n </div>\n\n <details class=\"ghcn-header__mobile\">\n <summary class=\"ghcn-icon-button ghcn-button--outline\" aria-label=\"Open navigation\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" width=\"20\" height=\"20\"><path d=\"M4 7h16M4 12h16M4 17h16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>\n </summary>\n <div class=\"ghcn-header__panel\">\n <nav aria-label=\"Mobile navigation\">{{navigation}}</nav>\n <div class=\"ghcn-header__mobile-actions\">\n {{search}}\n {{#if @site.members_enabled}}\n {{#if @member}}\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/account\" data-portal=\"account\">Account</a>\n {{else}}\n <a class=\"ghcn-button ghcn-button--outline\" href=\"#/portal/signin\" data-portal=\"signin\">Sign in</a>\n {{#unless @site.members_invite_only}}\n {{#if @site.allow_self_signup}}\n <a class=\"ghcn-button\" href=\"#/portal/signup\" data-portal=\"signup\">Subscribe</a>\n {{/if}}\n {{/unless}}\n {{/if}}\n {{/if}}\n </div>\n </div>\n </details>\n </div>\n</header>"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "site-header.css",
|
|
16
16
|
"type": "style",
|
|
17
17
|
"target": "assets/css/components/site-header.css",
|
|
18
|
-
"content": "/* ghostcn: Site Header */\n.ghcn-header { box-sizing: border-box; position: relative; z-index: 30; border-bottom: 1px solid var(--border); color: var(--foreground); background: color-mix(in srgb, var(--background) 92%, transparent); font-family: inherit; font-size: 16px; line-height: 1.5; isolation: isolate; }\n.ghcn-header *, .ghcn-header *::before, .ghcn-header *::after { box-sizing: border-box; }\n.ghcn-header__inner { display: flex; min-height: 4.5em; align-items: center; gap: 1.5em; }\n.ghcn-header__brand { display: inline-flex; flex: 0 0 auto; align-items: center; color: var(--foreground); font-size: 1.125em; font-weight: 800; letter-spacing: -0.025em; text-decoration: none; }\n.ghcn-header__brand img { display: block; width: auto; max-width: 11em; max-height: 2.25em; }\n.ghcn-header__nav { min-width: 0; flex: 1; }\n.ghcn-header .nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25em; margin: 0; padding: 0; list-style: none; }\n.ghcn-header .nav a, .ghcn-header__signin { color: var(--muted-foreground); font-size: 0.875em; font-weight: 600; text-decoration: none; }\n.ghcn-header .nav a:hover, .ghcn-header .nav-current a, .ghcn-header__signin:hover { color: var(--foreground); }\n.ghcn-header__actions { display: flex; align-items: center; gap: 0.75em; }\n.ghcn-
|
|
18
|
+
"content": "/* ghostcn: Site Header */\n.ghcn-header { box-sizing: border-box; position: relative; z-index: 30; border-bottom: 1px solid var(--border); color: var(--foreground); background: color-mix(in srgb, var(--background) 92%, transparent); font-family: inherit; font-size: 16px; line-height: 1.5; isolation: isolate; }\n.ghcn-header *, .ghcn-header *::before, .ghcn-header *::after { box-sizing: border-box; }\n.ghcn-header__inner { display: flex; min-height: 4.5em; align-items: center; gap: 1.5em; }\n.ghcn-header__brand { display: inline-flex; flex: 0 0 auto; align-items: center; color: var(--foreground); font-size: 1.125em; font-weight: 800; letter-spacing: -0.025em; text-decoration: none; }\n.ghcn-header__brand img { display: block; width: auto; max-width: 11em; max-height: 2.25em; }\n.ghcn-header__nav { min-width: 0; flex: 1; }\n.ghcn-header .nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25em; margin: 0; padding: 0; list-style: none; }\n.ghcn-header .nav a, .ghcn-header__signin { color: var(--muted-foreground); font-size: 0.875em; font-weight: 600; text-decoration: none; }\n.ghcn-header .nav a:hover, .ghcn-header .nav-current a, .ghcn-header__signin:hover { color: var(--foreground); }\n.ghcn-header__actions { display: flex; align-items: center; gap: 0.75em; }\n.ghcn-header .gh-search-icon:focus-visible { border-radius: var(--radius); box-shadow: 0 0 0 2px var(--ring); }\n.ghcn-header__mobile { display: none; margin-left: auto; }\n.ghcn-header__mobile summary { list-style: none; }\n.ghcn-header__mobile summary::-webkit-details-marker { display: none; }\n.ghcn-header__panel { position: absolute; top: calc(100% + 0.5em); right: 1em; left: 1em; border: 1px solid var(--border); border-radius: min(var(--radius), 1em); padding: 1em; background: var(--popover); box-shadow: 0 1em 2.5em rgba(0,0,0,.14); }\n.ghcn-header__panel .nav { align-items: stretch; flex-direction: column; gap: 0.25em; }\n.ghcn-header__panel .nav a { display: block; border-radius: var(--radius); padding: 0.625em 0.75em; }\n.ghcn-header__panel .nav a:hover { background: var(--muted); }\n.ghcn-header__mobile-actions { display: grid; grid-template-columns: auto 1fr 1fr; gap: 0.5em; margin-top: 1em; padding-top: 1em; border-top: 1px solid var(--border); }\n@media (max-width: 800px) { .ghcn-header__nav, .ghcn-header__actions { display: none; } .ghcn-header__mobile { display: block; } }\n"
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"gscan": {
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
function inside(root, relative) {
|
|
6
|
+
const target = path.resolve(root, relative);
|
|
7
|
+
if (target === root || !target.startsWith(root + path.sep)) throw new Error(`Path escapes theme: ${relative}`);
|
|
8
|
+
// Never follow links when inspecting or packaging a theme.
|
|
9
|
+
let current = root;
|
|
10
|
+
for (const part of path.relative(root, target).split(path.sep)) {
|
|
11
|
+
current = path.join(current, part);
|
|
12
|
+
if (fs.existsSync(current) && fs.lstatSync(current).isSymbolicLink()) throw new Error(`Symlink is not supported: ${relative}`);
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function inspectTheme(themeRoot) {
|
|
18
|
+
const root = path.resolve(themeRoot);
|
|
19
|
+
const errors = [], warnings = [];
|
|
20
|
+
const exists = relative => fs.existsSync(inside(root, relative));
|
|
21
|
+
const read = relative => fs.readFileSync(inside(root, relative), 'utf8').replace(/^\uFEFF/, '');
|
|
22
|
+
let pkg, config;
|
|
23
|
+
try {
|
|
24
|
+
for (const required of ['package.json', 'default.hbs', 'index.hbs']) {
|
|
25
|
+
if (!exists(required)) errors.push(`Missing ${required}`);
|
|
26
|
+
}
|
|
27
|
+
if (exists('package.json')) {
|
|
28
|
+
pkg = JSON.parse(read('package.json'));
|
|
29
|
+
if (!pkg.engines?.ghost) errors.push('package.json needs engines.ghost');
|
|
30
|
+
if (!pkg.author?.email) errors.push('package.json needs author.email');
|
|
31
|
+
}
|
|
32
|
+
if (exists('components.json')) {
|
|
33
|
+
config = JSON.parse(read('components.json'));
|
|
34
|
+
if (!['tailwind', 'css'].includes(config.style)) errors.push('components.json style must be tailwind or css');
|
|
35
|
+
for (const relative of [config.cssFile, config.aliases?.styles, config.aliases?.partials]) {
|
|
36
|
+
if (typeof relative !== 'string' || !relative.trim()) errors.push('components.json needs cssFile and partials/styles aliases');
|
|
37
|
+
else if (!exists(relative)) errors.push(`Missing configured path: ${relative}`);
|
|
38
|
+
}
|
|
39
|
+
if (config.style === 'tailwind' && !pkg?.devDependencies?.tailwindcss && !pkg?.dependencies?.tailwindcss) {
|
|
40
|
+
warnings.push('Tailwind selected but no local tailwindcss dependency. Configure a build pipeline before using utilities.');
|
|
41
|
+
}
|
|
42
|
+
if (config.style === 'tailwind' && !pkg?.scripts?.build) warnings.push('No build script is configured. Tailwind classes need compiled CSS loaded by your layout.');
|
|
43
|
+
} else warnings.push('No components.json. Run ghostcn init if you want to install components.');
|
|
44
|
+
const scan = (dir, visit) => {
|
|
45
|
+
for (const entry of fs.readdirSync(inside(root, dir), { withFileTypes: true })) {
|
|
46
|
+
const relative = path.posix.join(dir, entry.name);
|
|
47
|
+
inside(root, relative);
|
|
48
|
+
if (entry.isDirectory()) scan(relative, visit);
|
|
49
|
+
else if (entry.isFile()) visit(relative);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const templates = fs.readdirSync(root).filter(name => name.endsWith('.hbs'));
|
|
53
|
+
if (exists('partials')) scan('partials', file => { if (file.endsWith('.hbs')) templates.push(file); });
|
|
54
|
+
for (const file of templates) {
|
|
55
|
+
const source = read(file).replace(/\{\{!--[\s\S]*?--\}\}/g, '');
|
|
56
|
+
for (const match of source.matchAll(/\{\{asset\s+["']([^"']+)["']/g)) {
|
|
57
|
+
if (!exists(`assets/${match[1]}`)) errors.push(`${file}: missing asset ${match[1]} (run your build)`);
|
|
58
|
+
}
|
|
59
|
+
for (const match of source.matchAll(/\{\{>\s*["']([^"']+)["']/g)) {
|
|
60
|
+
if (!exists(`partials/${match[1]}.hbs`)) errors.push(`${file}: missing partial ${match[1]}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (exists('default.hbs')) {
|
|
64
|
+
const layout = read('default.hbs');
|
|
65
|
+
const linked = new Set();
|
|
66
|
+
for (const tag of layout.replace(/\{\{!--[\s\S]*?--\}\}/g, '').matchAll(/<link\b[^>]*>/gi)) {
|
|
67
|
+
if (!/\brel\s*=\s*["']stylesheet["']/i.test(tag[0])) continue;
|
|
68
|
+
const asset = tag[0].match(/\{\{asset\s+["']([^"']+)["']/);
|
|
69
|
+
if (asset) linked.add(asset[1]);
|
|
70
|
+
}
|
|
71
|
+
for (const helper of ['ghost_head', 'ghost_foot']) {
|
|
72
|
+
if (!new RegExp(`\\{\\{\\s*${helper}\\s*\\}\\}`).test(layout)) errors.push(`default.hbs needs {{${helper}}}`);
|
|
73
|
+
}
|
|
74
|
+
if (config && !linked.has(path.relative(path.join(root, 'assets'), inside(root, config.cssFile)).replaceAll('\\', '/'))) {
|
|
75
|
+
errors.push('default.hbs does not link the configured ghostcn stylesheet');
|
|
76
|
+
}
|
|
77
|
+
if (config?.aliases?.styles && exists(config.aliases.styles)) {
|
|
78
|
+
for (const name of fs.readdirSync(inside(root, config.aliases.styles)).filter(name => name.endsWith('.css'))) {
|
|
79
|
+
const asset = path.relative(path.join(root, 'assets'), inside(root, path.join(config.aliases.styles, name))).replaceAll('\\', '/');
|
|
80
|
+
if (!linked.has(asset)) errors.push(`default.hbs does not link component stylesheet ${asset}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} catch (error) { errors.push(error.message); }
|
|
85
|
+
return { errors: [...new Set(errors)], warnings: [...new Set(warnings)] };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function crc32(buffer) {
|
|
89
|
+
let crc = 0xffffffff;
|
|
90
|
+
for (const byte of buffer) {
|
|
91
|
+
crc ^= byte;
|
|
92
|
+
for (let bit = 0; bit < 8; bit++) crc = (crc >>> 1) ^ ((crc & 1) ? 0xedb88320 : 0);
|
|
93
|
+
}
|
|
94
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function packageTheme(themeRoot) {
|
|
98
|
+
const root = path.resolve(themeRoot);
|
|
99
|
+
const result = inspectTheme(root);
|
|
100
|
+
if (result.errors.length) throw new Error(result.errors.join('\n'));
|
|
101
|
+
const pkg = JSON.parse(fs.readFileSync(inside(root, 'package.json'), 'utf8'));
|
|
102
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(pkg.name) || !/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/.test(pkg.version)) {
|
|
103
|
+
throw new Error('Packaging needs a safe lowercase theme name and a semantic version in package.json');
|
|
104
|
+
}
|
|
105
|
+
const files = fs.readdirSync(root).filter(name => name.endsWith('.hbs') || ['package.json', 'LICENSE', 'LICENSE.md'].includes(name));
|
|
106
|
+
// Keep a source stylesheet if an existing theme actually links it at runtime.
|
|
107
|
+
const sourceStyles = new Set(['assets/css/source.css', 'assets/css/ghostcn-tailwind.css']);
|
|
108
|
+
const linkedStyles = new Set();
|
|
109
|
+
const findLinks = dir => {
|
|
110
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
111
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules' || entry.name === 'dist' || entry.name === 'assets') continue;
|
|
112
|
+
const target = path.join(dir, entry.name);
|
|
113
|
+
if (entry.isDirectory() && entry.name === 'partials') {
|
|
114
|
+
inside(root, path.relative(root, target));
|
|
115
|
+
findLinks(target);
|
|
116
|
+
}
|
|
117
|
+
else if (entry.isFile() && entry.name.endsWith('.hbs')) {
|
|
118
|
+
inside(root, path.relative(root, target));
|
|
119
|
+
for (const match of fs.readFileSync(target, 'utf8').matchAll(/\{\{asset\s+["']([^"']+)["']/g)) linkedStyles.add(`assets/${match[1]}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
findLinks(root);
|
|
124
|
+
const collect = dir => {
|
|
125
|
+
for (const entry of fs.readdirSync(inside(root, dir), { withFileTypes: true })) {
|
|
126
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
|
|
127
|
+
const relative = path.posix.join(dir, entry.name);
|
|
128
|
+
inside(root, relative);
|
|
129
|
+
if (entry.isDirectory()) collect(relative);
|
|
130
|
+
else if (entry.isFile() && !relative.endsWith('.map') && (!sourceStyles.has(relative) || linkedStyles.has(relative))) files.push(relative);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
for (const dir of ['partials', 'assets']) if (fs.existsSync(inside(root, dir))) collect(dir);
|
|
134
|
+
const chunks = [], directory = [];
|
|
135
|
+
let offset = 0;
|
|
136
|
+
for (const file of files.sort()) {
|
|
137
|
+
const name = Buffer.from(file.replaceAll('\\', '/'));
|
|
138
|
+
const data = fs.readFileSync(inside(root, file));
|
|
139
|
+
const crc = crc32(data);
|
|
140
|
+
const local = Buffer.alloc(30);
|
|
141
|
+
local.writeUInt32LE(0x04034b50); local.writeUInt16LE(20, 4); local.writeUInt16LE(0x800, 6);
|
|
142
|
+
local.writeUInt16LE(33, 12); // 1980-01-01: deterministic archive timestamps
|
|
143
|
+
local.writeUInt32LE(crc, 14); local.writeUInt32LE(data.length, 18); local.writeUInt32LE(data.length, 22); local.writeUInt16LE(name.length, 26);
|
|
144
|
+
chunks.push(local, name, data);
|
|
145
|
+
const central = Buffer.alloc(46);
|
|
146
|
+
central.writeUInt32LE(0x02014b50); central.writeUInt16LE(20, 4); central.writeUInt16LE(20, 6); central.writeUInt16LE(0x800, 8);
|
|
147
|
+
central.writeUInt16LE(33, 14); central.writeUInt32LE(crc, 16); central.writeUInt32LE(data.length, 20); central.writeUInt32LE(data.length, 24);
|
|
148
|
+
central.writeUInt16LE(name.length, 28); central.writeUInt32LE(offset, 42);
|
|
149
|
+
directory.push(central, name);
|
|
150
|
+
offset += local.length + name.length + data.length;
|
|
151
|
+
}
|
|
152
|
+
if (files.length > 65535 || offset > 0xffffffff) throw new Error('Theme exceeds ZIP32 limits');
|
|
153
|
+
const central = Buffer.concat(directory), end = Buffer.alloc(22);
|
|
154
|
+
end.writeUInt32LE(0x06054b50); end.writeUInt16LE(files.length, 8); end.writeUInt16LE(files.length, 10);
|
|
155
|
+
end.writeUInt32LE(central.length, 12); end.writeUInt32LE(offset, 16);
|
|
156
|
+
const dist = inside(root, 'dist');
|
|
157
|
+
fs.mkdirSync(dist, { recursive: true });
|
|
158
|
+
const output = inside(root, `dist/${pkg.name}-${pkg.version}.zip`);
|
|
159
|
+
fs.writeFileSync(output, Buffer.concat([...chunks, central, end]));
|
|
160
|
+
return { output, files };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function reportTheme(themeRoot) {
|
|
164
|
+
const result = inspectTheme(themeRoot);
|
|
165
|
+
for (const warning of result.warnings) console.warn(`WARN: ${warning}`);
|
|
166
|
+
for (const error of result.errors) console.error(`ERROR: ${error}`);
|
|
167
|
+
if (result.errors.length) return false;
|
|
168
|
+
console.log('Theme checks passed. Run the official gscan validator before publishing.');
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
173
|
+
const root = path.resolve(process.argv[3] || process.cwd());
|
|
174
|
+
try {
|
|
175
|
+
if (process.argv[2] === 'pack') console.log(`Created ${packageTheme(root).output}`);
|
|
176
|
+
else if (!reportTheme(root)) process.exitCode = 1;
|
|
177
|
+
} catch (error) { console.error(error.message); process.exitCode = 1; }
|
|
178
|
+
}
|
|
@@ -8,6 +8,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const registry_1 = require("./registry");
|
|
10
10
|
const theme_files_1 = require("./theme-files");
|
|
11
|
+
const styles_1 = require("./styles");
|
|
11
12
|
function aliasedTarget(config, file) {
|
|
12
13
|
if (file.placement === 'theme') {
|
|
13
14
|
if (!file.target)
|
|
@@ -45,7 +46,7 @@ async function installComponent(options) {
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
fs_1.default.mkdirSync(path_1.default.dirname(targetPath), { recursive: true });
|
|
48
|
-
fs_1.default.writeFileSync(targetPath, file.content, 'utf8');
|
|
49
|
+
fs_1.default.writeFileSync(targetPath, file.type === 'style' ? (0, styles_1.componentCss)(file.content, options.config.style) : file.content, 'utf8');
|
|
49
50
|
result.installed.push(relativeTarget);
|
|
50
51
|
}
|
|
51
52
|
if (manifest.files.some(file => file.type === 'style')) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.componentCss = componentCss;
|
|
4
|
+
exports.tailwindTheme = tailwindTheme;
|
|
5
|
+
/** Tailwind utilities must outrank portable component defaults, regardless of link order. */
|
|
6
|
+
function componentCss(content, style) {
|
|
7
|
+
return style === 'tailwind' ? `@layer theme, base, components, utilities;\n@layer components {\n${content}\n}\n` : content;
|
|
8
|
+
}
|
|
9
|
+
function tailwindTheme() {
|
|
10
|
+
const colors = ['background', 'foreground', 'card', 'card-foreground', 'popover', 'popover-foreground',
|
|
11
|
+
'primary', 'primary-foreground', 'secondary', 'secondary-foreground', 'muted', 'muted-foreground',
|
|
12
|
+
'accent', 'accent-foreground', 'destructive', 'destructive-foreground', 'border', 'input', 'ring'];
|
|
13
|
+
return `@theme inline {\n${colors.map(color => ` --color-${color}: var(--${color});`).join('\n')}\n --radius-ghostcn: var(--radius);\n}\n
|
|
14
|
+
@custom-variant dark {
|
|
15
|
+
&:where(.dark, .dark *, .dark-mode, .dark-mode *, [data-theme="dark"], [data-theme="dark"] *) { @slot; }
|
|
16
|
+
@media (prefers-color-scheme: dark) {
|
|
17
|
+
&:where(.auto-color, .auto-color *) { @slot; }
|
|
18
|
+
}
|
|
19
|
+
}\n`;
|
|
20
|
+
}
|
|
@@ -84,8 +84,12 @@ function syncGhostcnStyles(options) {
|
|
|
84
84
|
const withoutManagedBlock = original.replace(managedBlockPattern, '');
|
|
85
85
|
const withoutOwnedLinks = removeOwnedStylesheetLinks(withoutManagedBlock, assetPaths);
|
|
86
86
|
const ghostHeadPattern = /^([ \t]*)\{\{ghost_head\}\}/m;
|
|
87
|
+
const overrideAnchor = /^([ \t]*)\{\{!-- ghostcn:theme-styles --\}\}/m;
|
|
87
88
|
let updated;
|
|
88
|
-
if (
|
|
89
|
+
if (overrideAnchor.test(withoutOwnedLinks)) {
|
|
90
|
+
updated = withoutOwnedLinks.replace(overrideAnchor, (match, indent) => `${indentBlock(block, indent, newline)}${newline}${match}`);
|
|
91
|
+
}
|
|
92
|
+
else if (ghostHeadPattern.test(withoutOwnedLinks)) {
|
|
89
93
|
updated = withoutOwnedLinks.replace(ghostHeadPattern, (_match, indent) => {
|
|
90
94
|
return `${indentBlock(block, indent, newline)}${newline}${indent}{{ghost_head}}`;
|
|
91
95
|
});
|
|
@@ -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
|
|
23
|
-
styles: paths.styles
|
|
24
|
-
js: paths.js
|
|
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
|
|
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,36 @@ ${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
|
-
|
|
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
|
+
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.
|
|
242
|
+
|
|
243
|
+
## Package for upload
|
|
244
|
+
|
|
245
|
+
\`\`\`bash
|
|
246
|
+
${run} test
|
|
247
|
+
${run} validate
|
|
248
|
+
${run} zip
|
|
249
|
+
\`\`\`
|
|
250
|
+
|
|
251
|
+
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
252
|
`;
|
|
214
253
|
}
|
|
215
254
|
const vanillaBuildScript = `import { copyFileSync, mkdirSync } from 'node:fs';
|
|
@@ -227,25 +266,6 @@ watch(source, () => {
|
|
|
227
266
|
timer = setTimeout(() => import('./build.mjs?' + Date.now()), 50);
|
|
228
267
|
});
|
|
229
268
|
`;
|
|
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
269
|
function scaffoldTheme(options) {
|
|
250
270
|
const themeName = sanitizeThemeName(options.themeName);
|
|
251
271
|
const parent = path_1.default.resolve(options.parentDirectory);
|
|
@@ -259,19 +279,22 @@ function scaffoldTheme(options) {
|
|
|
259
279
|
fs_1.default.mkdirSync(themeRoot, { recursive: true });
|
|
260
280
|
const css = baseThemeCss();
|
|
261
281
|
const sourceCss = options.style === 'tailwind'
|
|
262
|
-
? `@import "tailwindcss";\n@source "../../**/*.hbs";\n\n${css}`
|
|
282
|
+
? `@import "tailwindcss";\n@source "../../**/*.hbs";\n@import "./ghostcn-tailwind.css";\n\n@layer base {\n${css}}\n`
|
|
263
283
|
: css;
|
|
264
284
|
const files = {
|
|
265
285
|
'package.json': packageJson({ ...options, themeName }),
|
|
266
286
|
'default.hbs': defaultTemplate(options.colorScheme),
|
|
267
287
|
'index.hbs': indexTemplate(options),
|
|
268
288
|
'post.hbs': postTemplate(options),
|
|
289
|
+
'partials/content-cta.hbs': '{{{html}}}\n{{> "components/member-cta"}}\n',
|
|
269
290
|
'page.hbs': pageTemplate(),
|
|
270
291
|
'tag.hbs': archiveTemplate('tag'),
|
|
271
292
|
'author.hbs': archiveTemplate('author'),
|
|
272
293
|
'assets/css/source.css': sourceCss,
|
|
273
294
|
'assets/built/screen.css': css,
|
|
274
|
-
'scripts/check.mjs':
|
|
295
|
+
'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",
|
|
296
|
+
'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",
|
|
297
|
+
'scripts/theme-tools.mjs': fs_1.default.readFileSync((0, theme_tooling_1.themeToolPath)(), 'utf8'),
|
|
275
298
|
'.gitignore': 'node_modules\n*.zip\n.DS_Store\n',
|
|
276
299
|
'README.md': readme(options)
|
|
277
300
|
};
|
|
@@ -279,6 +302,8 @@ function scaffoldTheme(options) {
|
|
|
279
302
|
files['scripts/build.mjs'] = vanillaBuildScript;
|
|
280
303
|
files['scripts/dev.mjs'] = vanillaDevScript;
|
|
281
304
|
}
|
|
305
|
+
if (options.style === 'tailwind')
|
|
306
|
+
files['assets/css/ghostcn-tailwind.css'] = (0, styles_1.tailwindTheme)();
|
|
282
307
|
for (const [relativePath, content] of Object.entries(files)) {
|
|
283
308
|
const target = (0, theme_files_1.resolveWithinTheme)(themeRoot, relativePath);
|
|
284
309
|
fs_1.default.mkdirSync(path_1.default.dirname(target), { recursive: true });
|
|
@@ -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
|
+
}
|
package/dist/utils/theme.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
/*
|
|
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.
|
|
3
|
+
"version": "1.2.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');
|
|
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",
|
|
@@ -44,12 +44,14 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"chalk": "^4.1.2",
|
|
46
46
|
"commander": "^12.0.0",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"ora": "^5.4.1",
|
|
48
|
+
"prompts": "^2.4.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
+
"@tailwindcss/cli": "^4.3.3",
|
|
51
52
|
"@types/node": "^20.11.24",
|
|
52
53
|
"@types/prompts": "^2.4.9",
|
|
54
|
+
"handlebars": "^4.7.9",
|
|
53
55
|
"ts-node": "^10.9.2",
|
|
54
56
|
"typescript": "^5.3.3"
|
|
55
57
|
}
|