@forgewp/compiler 0.1.2 → 0.1.8
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 +29 -2
- package/bin/add.js +14 -2
- package/bin/clean.js +37 -0
- package/bin/cli.js +87 -0
- package/bin/doctor.js +99 -0
- package/bin/export.js +0 -0
- package/bin/make-block.js +130 -0
- package/bin/make-component.js +200 -0
- package/bin/make-post-type.js +129 -0
- package/bin/repair.js +62 -0
- package/lib/add-component.js +5 -2
- package/lib/blueprints.js +497 -0
- package/lib/export-theme.js +11 -0
- package/lib/generate-theme.js +531 -17
- package/lib/index.d.ts +61 -0
- package/lib/index.js +1 -0
- package/lib/render-static.js +20 -0
- package/lib/render-theme.mts +200 -48
- package/lib/validate.js +54 -0
- package/package.json +11 -5
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System File Blueprints — ForgeWP Compiler
|
|
3
|
+
*
|
|
4
|
+
* These are fallback templates used by the compiler's self-healing preflight check.
|
|
5
|
+
* If a developer accidentally deletes a system-critical library file,
|
|
6
|
+
* the compiler will automatically recreate it to prevent compilation and runtime errors.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const SYSTEM_BLUEPRINTS = {
|
|
10
|
+
"wordpress/mock-data.json": `{
|
|
11
|
+
"post": [
|
|
12
|
+
{
|
|
13
|
+
"id": 1,
|
|
14
|
+
"title": "Welcome to ForgeWP: The Headless Revolution",
|
|
15
|
+
"excerpt": "Discover how ForgeWP bridges standard WordPress themes with blistering fast React architectures.",
|
|
16
|
+
"content": "<p>This is the first mock post. In local dev, you can modify <code>wordpress/mock-data.json</code> to test layout content changes.</p>",
|
|
17
|
+
"date": "May 10, 2026",
|
|
18
|
+
"author": "Antigravity",
|
|
19
|
+
"featuredImage": "https://picsum.photos/seed/forgewp/1200/630",
|
|
20
|
+
"customFields": {}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": 2,
|
|
24
|
+
"title": "Unlocking Brutalist Web Design Aesthetics",
|
|
25
|
+
"excerpt": "A deep dive into high-contrast grids, sharp corners, and premium flat shadows in modern interfaces.",
|
|
26
|
+
"content": "<p>This is the second mock post. Style these grids using beautiful Tailwind utilities.</p>",
|
|
27
|
+
"date": "May 12, 2026",
|
|
28
|
+
"author": "DeepMind Partner",
|
|
29
|
+
"featuredImage": "https://picsum.photos/seed/brutalist/1200/630",
|
|
30
|
+
"customFields": {}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"project": [
|
|
34
|
+
{
|
|
35
|
+
"id": 1,
|
|
36
|
+
"title": "ForgeWP Scaffolding Platform",
|
|
37
|
+
"excerpt": "Building a custom compiler framework to transpile React elements into standard PHP themes.",
|
|
38
|
+
"content": "<p>Detailed description of the ForgeWP compiler pipeline project.</p>",
|
|
39
|
+
"date": "May 15, 2026",
|
|
40
|
+
"author": "Lead Architect",
|
|
41
|
+
"featuredImage": "https://picsum.photos/seed/platform/1200/630",
|
|
42
|
+
"customFields": {
|
|
43
|
+
"client_name": "El Dorado",
|
|
44
|
+
"project_budget": "$45,000"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": 2,
|
|
49
|
+
"title": "Brutalist Starter Theme",
|
|
50
|
+
"excerpt": "A clean, responsive, and robust high-contrast interface leveraging Tailwind CSS v4.",
|
|
51
|
+
"content": "<p>A brutalist theme showcasing raw black borders and vivid accent colors.</p>",
|
|
52
|
+
"date": "May 16, 2026",
|
|
53
|
+
"author": "Theme Engineer",
|
|
54
|
+
"featuredImage": "https://picsum.photos/seed/starter/1200/630",
|
|
55
|
+
"customFields": {
|
|
56
|
+
"client_name": "ForgeWP Community",
|
|
57
|
+
"project_budget": "Open Source"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}`,
|
|
62
|
+
|
|
63
|
+
"src/lib/wordpress.tsx": `/**
|
|
64
|
+
* ForgeWP WordPress Data Hooks
|
|
65
|
+
*
|
|
66
|
+
* These hooks provide mock data during local development (Vite dev server).
|
|
67
|
+
* When the theme is exported, the ForgeWP compiler replaces every token
|
|
68
|
+
* with the equivalent WordPress PHP function call.
|
|
69
|
+
*/
|
|
70
|
+
import React, { createContext, useContext } from "react";
|
|
71
|
+
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
import mockData from "../../wordpress/mock-data.json";
|
|
74
|
+
|
|
75
|
+
const IS_DEV =
|
|
76
|
+
typeof import.meta !== "undefined" &&
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
import.meta.env?.DEV === true;
|
|
79
|
+
|
|
80
|
+
// React context to support database-like query loops during local development
|
|
81
|
+
const WpPostContext = createContext<any>(null);
|
|
82
|
+
|
|
83
|
+
// ── Post content ─────────────────────────────────────────────────────────────
|
|
84
|
+
|
|
85
|
+
export function useWpTitle() {
|
|
86
|
+
if (IS_DEV) {
|
|
87
|
+
const post = useContext(WpPostContext);
|
|
88
|
+
return post?.title || "Sample WordPress Post Title";
|
|
89
|
+
}
|
|
90
|
+
return "__FORGEWP_THE_TITLE__";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function useWpContent() {
|
|
94
|
+
if (IS_DEV) {
|
|
95
|
+
const post = useContext(WpPostContext);
|
|
96
|
+
return post?.content || "<p>This is sample post content rendered locally so you can design your theme. In WordPress, this is replaced by the actual content from the Gutenberg editor — including blocks, shortcodes, and embeds.</p>";
|
|
97
|
+
}
|
|
98
|
+
return "__FORGEWP_THE_CONTENT__";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function useWpExcerpt() {
|
|
102
|
+
if (IS_DEV) {
|
|
103
|
+
const post = useContext(WpPostContext);
|
|
104
|
+
return post?.excerpt || "A short excerpt that gives readers a quick preview of what to expect in the full post.";
|
|
105
|
+
}
|
|
106
|
+
return "__FORGEWP_THE_EXCERPT__";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function useWpPermalink() {
|
|
110
|
+
if (IS_DEV) {
|
|
111
|
+
const post = useContext(WpPostContext);
|
|
112
|
+
return post ? \`/post/\${post.id}\` : "/post";
|
|
113
|
+
}
|
|
114
|
+
return "__FORGEWP_THE_PERMALINK__";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ── Post meta ─────────────────────────────────────────────────────────────────
|
|
118
|
+
|
|
119
|
+
export function useWpDate() {
|
|
120
|
+
if (IS_DEV) {
|
|
121
|
+
const post = useContext(WpPostContext);
|
|
122
|
+
return post?.date || new Date().toLocaleDateString("en-US", {
|
|
123
|
+
year: "numeric",
|
|
124
|
+
month: "long",
|
|
125
|
+
day: "numeric",
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return "__FORGEWP_THE_DATE__";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function useWpAuthor() {
|
|
132
|
+
if (IS_DEV) {
|
|
133
|
+
const post = useContext(WpPostContext);
|
|
134
|
+
return post?.author || "Jane Doe";
|
|
135
|
+
}
|
|
136
|
+
return "__FORGEWP_THE_AUTHOR__";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function useWpFeaturedImage() {
|
|
140
|
+
if (IS_DEV) {
|
|
141
|
+
const post = useContext(WpPostContext);
|
|
142
|
+
return post?.featuredImage || "https://picsum.photos/seed/forgewp/1200/630";
|
|
143
|
+
}
|
|
144
|
+
return "__FORGEWP_THE_POST_THUMBNAIL_URL__";
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function useWpCategories() {
|
|
148
|
+
if (IS_DEV) {
|
|
149
|
+
return '<a href="#">Technology</a>, <a href="#">Design</a>';
|
|
150
|
+
}
|
|
151
|
+
return "__FORGEWP_THE_CATEGORY_LIST__";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function useWpArchiveTitle() {
|
|
155
|
+
if (IS_DEV) return "Category: Technology";
|
|
156
|
+
return "__FORGEWP_THE_ARCHIVE_TITLE__";
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// ── Loop ──────────────────────────────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
export function WpLoop({ children }: { children: React.ReactNode }) {
|
|
162
|
+
if (IS_DEV) {
|
|
163
|
+
const posts = mockData?.post || [
|
|
164
|
+
{ id: 1, title: "Mock Post 1" },
|
|
165
|
+
{ id: 2, title: "Mock Post 2" },
|
|
166
|
+
{ id: 3, title: "Mock Post 3" }
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<>
|
|
171
|
+
{posts.map((post: any) => (
|
|
172
|
+
<WpPostContext.Provider key={post.id} value={post}>
|
|
173
|
+
{children}
|
|
174
|
+
</WpPostContext.Provider>
|
|
175
|
+
))}
|
|
176
|
+
</>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<>
|
|
182
|
+
{/* @ts-ignore */}
|
|
183
|
+
<forgewp-loop-start />
|
|
184
|
+
{children}
|
|
185
|
+
{/* @ts-ignore */}
|
|
186
|
+
<forgewp-loop-end />
|
|
187
|
+
</>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ── Custom Field Mapping (ACF / Meta Fields) ──────────────────────────────────
|
|
192
|
+
|
|
193
|
+
export function useWpCustomField(fieldName: string, defaultValue: string = ""): string {
|
|
194
|
+
if (IS_DEV) {
|
|
195
|
+
const post = useContext(WpPostContext);
|
|
196
|
+
if (post && post.customFields && typeof post.customFields[fieldName] !== "undefined") {
|
|
197
|
+
return post.customFields[fieldName];
|
|
198
|
+
}
|
|
199
|
+
return defaultValue || "[Mock custom field: " + fieldName + "]";
|
|
200
|
+
}
|
|
201
|
+
return "__FORGEWP_CUSTOM_FIELD__" + fieldName + "__";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// ── Navigation Menu Component ──────────────────────────────────────────────────
|
|
205
|
+
|
|
206
|
+
export interface WpMenuProps {
|
|
207
|
+
location?: string;
|
|
208
|
+
className?: string;
|
|
209
|
+
linkClassName?: string;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function WpMenu({ location = "primary", className = "", linkClassName = "" }: WpMenuProps) {
|
|
213
|
+
if (IS_DEV) {
|
|
214
|
+
const mockItems = [
|
|
215
|
+
{ title: "Home", url: "/" },
|
|
216
|
+
{ title: "Blog", url: "/post" },
|
|
217
|
+
{ title: "Archive", url: "/archive" },
|
|
218
|
+
];
|
|
219
|
+
return (
|
|
220
|
+
<nav className={className}>
|
|
221
|
+
{mockItems.map((item, idx) => (
|
|
222
|
+
<a key={idx} href={item.url} className={linkClassName}>
|
|
223
|
+
{item.title}
|
|
224
|
+
</a>
|
|
225
|
+
))}
|
|
226
|
+
</nav>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
// @ts-ignore
|
|
232
|
+
<forgewp-menu location={location} className={className} linkClassName={linkClassName} />
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ── Custom Query Loop Component ───────────────────────────────────────────────
|
|
237
|
+
|
|
238
|
+
export interface WpQueryLoopProps {
|
|
239
|
+
postType?: string;
|
|
240
|
+
postsPerPage?: number;
|
|
241
|
+
categoryName?: string;
|
|
242
|
+
children: React.ReactNode;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function WpQueryLoop({
|
|
246
|
+
postType = "post",
|
|
247
|
+
postsPerPage = 3,
|
|
248
|
+
categoryName = "",
|
|
249
|
+
children
|
|
250
|
+
}: WpQueryLoopProps) {
|
|
251
|
+
if (IS_DEV) {
|
|
252
|
+
const allPosts = (mockData as any)?.[postType] || [];
|
|
253
|
+
const posts = allPosts.slice(0, postsPerPage);
|
|
254
|
+
|
|
255
|
+
if (posts.length === 0) {
|
|
256
|
+
const fallbacks = Array.from({ length: postsPerPage }).map((_, i) => ({
|
|
257
|
+
id: i + 1,
|
|
258
|
+
title: \`Mock \${postType} \${i + 1}\`,
|
|
259
|
+
}));
|
|
260
|
+
return (
|
|
261
|
+
<>
|
|
262
|
+
{fallbacks.map((post: any) => (
|
|
263
|
+
<WpPostContext.Provider key={post.id} value={post}>
|
|
264
|
+
{children}
|
|
265
|
+
</WpPostContext.Provider>
|
|
266
|
+
))}
|
|
267
|
+
</>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return (
|
|
272
|
+
<>
|
|
273
|
+
{posts.map((post: any) => (
|
|
274
|
+
<WpPostContext.Provider key={post.id} value={post}>
|
|
275
|
+
{children}
|
|
276
|
+
</WpPostContext.Provider>
|
|
277
|
+
))}
|
|
278
|
+
</>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<>
|
|
284
|
+
{/* @ts-ignore */}
|
|
285
|
+
<forgewp-query-loop-start postType={postType} postsPerPage={postsPerPage} categoryName={categoryName} />
|
|
286
|
+
{children}
|
|
287
|
+
{/* @ts-ignore */}
|
|
288
|
+
<forgewp-query-loop-end />
|
|
289
|
+
</>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// ── Shortcodes Component ────────────────────────────────────────────────────────
|
|
294
|
+
|
|
295
|
+
export interface WpShortcodeProps {
|
|
296
|
+
code: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export function WpShortcode({ code }: WpShortcodeProps) {
|
|
300
|
+
if (IS_DEV) {
|
|
301
|
+
return (
|
|
302
|
+
<div className="p-4 bg-zinc-100 border-2 border-dashed border-zinc-400 font-mono text-xs text-zinc-600 rounded-none my-4">
|
|
303
|
+
<span className="font-bold text-zinc-800">WordPress Shortcode Preview:</span> {code}
|
|
304
|
+
</div>
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
// @ts-ignore
|
|
310
|
+
<forgewp-shortcode code={code} />
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
`,
|
|
314
|
+
|
|
315
|
+
"src/lib/SEO.tsx": `import * as ReactHelmetAsync from "react-helmet-async";
|
|
316
|
+
import { useWpTitle } from "./wordpress";
|
|
317
|
+
|
|
318
|
+
// Support both ESM and CommonJS exports of react-helmet-async across Vite and TSX compiler
|
|
319
|
+
const Helmet = (ReactHelmetAsync.Helmet || (ReactHelmetAsync as any)["default"]?.Helmet || ReactHelmetAsync) as any;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* ForgeWP SEO — Internal system file. Do not delete.
|
|
323
|
+
*
|
|
324
|
+
* Use this component in \`src/app/layout.tsx\` to set global SEO defaults,
|
|
325
|
+
* and in individual page files to override them per-page.
|
|
326
|
+
*
|
|
327
|
+
* The ForgeWP compiler reads the props you pass here and injects them
|
|
328
|
+
* directly into the WordPress theme's <head> as native meta tags.
|
|
329
|
+
*
|
|
330
|
+
* @see https://forgewp.dev/docs/seo
|
|
331
|
+
*/
|
|
332
|
+
|
|
333
|
+
export interface SEOProps {
|
|
334
|
+
/** Page title — defaults to the WordPress post title via useWpTitle() */
|
|
335
|
+
title?: string;
|
|
336
|
+
/** Meta description for search engines and social cards */
|
|
337
|
+
description?: string;
|
|
338
|
+
/** Comma-separated keywords */
|
|
339
|
+
keywords?: string;
|
|
340
|
+
/** Open Graph title (falls back to title if omitted) */
|
|
341
|
+
ogTitle?: string;
|
|
342
|
+
/** Open Graph description (falls back to description if omitted) */
|
|
343
|
+
ogDescription?: string;
|
|
344
|
+
/** Absolute URL to the Open Graph image */
|
|
345
|
+
ogImage?: string;
|
|
346
|
+
/** Open Graph type — "website" for homepages, "article" for posts */
|
|
347
|
+
ogType?: string;
|
|
348
|
+
/** Twitter card type */
|
|
349
|
+
twitterCard?: string;
|
|
350
|
+
/** Twitter creator handle, e.g. "@username" */
|
|
351
|
+
twitterCreator?: string;
|
|
352
|
+
/** Canonical URL — tells search engines the preferred version of this page */
|
|
353
|
+
canonical?: string;
|
|
354
|
+
/** Set to true to prevent this page from being indexed by search engines */
|
|
355
|
+
noIndex?: boolean;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* \`<SEO>\` — ForgeWP SEO manager.
|
|
360
|
+
*
|
|
361
|
+
* Drop this into your **layout.tsx** to set site-wide defaults.
|
|
362
|
+
* Then drop it into any **page file** to override for that specific template.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* // layout.tsx — global defaults (the compiler reads these for all pages)
|
|
366
|
+
* <SEO
|
|
367
|
+
* description="Your site tagline or description."
|
|
368
|
+
* keywords="WordPress, React, Tailwind"
|
|
369
|
+
* ogImage="https://yoursite.com/og-default.png"
|
|
370
|
+
* />
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* // single.tsx — per-page override (article-specific metadata)
|
|
374
|
+
* <SEO
|
|
375
|
+
* ogType="article"
|
|
376
|
+
* ogImage="https://yoursite.com/og-post.png"
|
|
377
|
+
* twitterCreator="@yourhandle"
|
|
378
|
+
* />
|
|
379
|
+
*/
|
|
380
|
+
export function SEO({
|
|
381
|
+
title,
|
|
382
|
+
description = "A WordPress theme built with ForgeWP — React & Tailwind CSS.",
|
|
383
|
+
keywords = "WordPress, React, Tailwind CSS, ForgeWP",
|
|
384
|
+
ogTitle,
|
|
385
|
+
ogDescription,
|
|
386
|
+
ogImage,
|
|
387
|
+
ogType = "website",
|
|
388
|
+
twitterCard = "summary_large_image",
|
|
389
|
+
twitterCreator,
|
|
390
|
+
canonical,
|
|
391
|
+
noIndex = false,
|
|
392
|
+
}: SEOProps) {
|
|
393
|
+
const wpTitle = useWpTitle();
|
|
394
|
+
const resolvedTitle = title ?? wpTitle;
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
<Helmet>
|
|
398
|
+
{/* ── Primary ── */}
|
|
399
|
+
<title>{resolvedTitle}</title>
|
|
400
|
+
<meta name="description" content={description} />
|
|
401
|
+
{keywords && <meta name="keywords" content={keywords} />}
|
|
402
|
+
{noIndex && <meta name="robots" content="noindex, nofollow" />}
|
|
403
|
+
{canonical && <link rel="canonical" href={canonical} />}
|
|
404
|
+
|
|
405
|
+
{/* ── Open Graph ── */}
|
|
406
|
+
<meta property="og:type" content={ogType} />
|
|
407
|
+
<meta property="og:title" content={ogTitle ?? resolvedTitle} />
|
|
408
|
+
<meta property="og:description" content={ogDescription ?? description} />
|
|
409
|
+
{ogImage && <meta property="og:image" content={ogImage} />}
|
|
410
|
+
|
|
411
|
+
{/* ── Twitter ── */}
|
|
412
|
+
<meta name="twitter:card" content={twitterCard} />
|
|
413
|
+
<meta name="twitter:title" content={ogTitle ?? resolvedTitle} />
|
|
414
|
+
<meta name="twitter:description" content={ogDescription ?? description} />
|
|
415
|
+
{ogImage && <meta name="twitter:image" content={ogImage} />}
|
|
416
|
+
{twitterCreator && <meta name="twitter:creator" content={twitterCreator} />}
|
|
417
|
+
</Helmet>
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
`,
|
|
421
|
+
|
|
422
|
+
"src/lib/PresetsStyle.tsx": `import wpConfig from "../../wp.config";
|
|
423
|
+
|
|
424
|
+
const IS_DEV =
|
|
425
|
+
typeof import.meta !== "undefined" &&
|
|
426
|
+
// @ts-ignore
|
|
427
|
+
import.meta.env?.DEV === true;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* PresetsStyle component — Internal system component.
|
|
431
|
+
*
|
|
432
|
+
* Dynamically injects WordPress-preset CSS Custom Properties and enqueues Google Fonts
|
|
433
|
+
* during local Vite development, keeping your styles perfectly in sync with WordPress.
|
|
434
|
+
* In production builds, this returns only the registry-aesthetic design tokens (like --radius)
|
|
435
|
+
* to keep shadcn components and theme variables responsive to your config.
|
|
436
|
+
*/
|
|
437
|
+
export function PresetsStyle() {
|
|
438
|
+
const themeStyle = wpConfig.style || "forgewp";
|
|
439
|
+
|
|
440
|
+
// Production build: only inject custom registry-aesthetic design properties
|
|
441
|
+
if (!IS_DEV) {
|
|
442
|
+
const prodCss = \`
|
|
443
|
+
:root {
|
|
444
|
+
--radius: \${themeStyle === "forgewp" ? "0px" : "0.5rem"};
|
|
445
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
446
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
447
|
+
--radius-lg: var(--radius);
|
|
448
|
+
--border-width: \${themeStyle === "forgewp" ? "2px" : "1px"};
|
|
449
|
+
--border-color: \${themeStyle === "forgewp" ? "#09090b" : "#e4e4e7"};
|
|
450
|
+
--shadow-offset: \${themeStyle === "forgewp" ? "4px" : "0px"};
|
|
451
|
+
}
|
|
452
|
+
\`;
|
|
453
|
+
return <style dangerouslySetInnerHTML={{ __html: prodCss }} />;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Local development fallbacks for WordPress CSS presets
|
|
457
|
+
const colors = wpConfig.settings?.color?.palette || [];
|
|
458
|
+
const fontSizes = wpConfig.settings?.typography?.fontSizes || [];
|
|
459
|
+
const fontFamilies = wpConfig.settings?.typography?.fontFamilies || [];
|
|
460
|
+
const layout = wpConfig.settings?.layout || {};
|
|
461
|
+
const googleFonts = wpConfig.settings?.typography?.googleFonts || [];
|
|
462
|
+
|
|
463
|
+
// Parse and build Google Fonts href for dev injection
|
|
464
|
+
const fontsHtml = googleFonts.length > 0
|
|
465
|
+
? \`<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
466
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
467
|
+
<link href="https://fonts.googleapis.com/css2?family=\&{googleFonts.map(f => encodeURIComponent(f)).join("&family=")}&display=swap" rel="stylesheet">\`
|
|
468
|
+
: "";
|
|
469
|
+
|
|
470
|
+
const devCss = \`
|
|
471
|
+
:root {
|
|
472
|
+
\${colors.map((c) => "--wp--preset--color--" + c.slug + ": " + c.color + ";").join("\\n ")}
|
|
473
|
+
\${fontSizes.map((f) => "--wp--preset--font-size--" + f.slug + ": " + f.size + ";").join("\\n ")}
|
|
474
|
+
\${fontFamilies.map((f) => "--wp--preset--font-family--" + f.slug + ": " + f.fontFamily + ";").join("\\n ")}
|
|
475
|
+
\${layout.contentSize ? "--wp--style--global--content-size: " + layout.contentSize + ";" : ""}
|
|
476
|
+
\${layout.wideSize ? "--wp--style--global--wide-size: " + layout.wideSize + ";" : ""}
|
|
477
|
+
|
|
478
|
+
/* Registry Aesthetic Mode Custom Properties */
|
|
479
|
+
--radius: \${themeStyle === "forgewp" ? "0px" : "0.5rem"};
|
|
480
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
481
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
482
|
+
--radius-lg: var(--radius);
|
|
483
|
+
--border-width: \${themeStyle === "forgewp" ? "2px" : "1px"};
|
|
484
|
+
--border-color: \${themeStyle === "forgewp" ? "#09090b" : "#e4e4e7"};
|
|
485
|
+
--shadow-offset: \${themeStyle === "forgewp" ? "4px" : "0px"};
|
|
486
|
+
}
|
|
487
|
+
\`;
|
|
488
|
+
|
|
489
|
+
return (
|
|
490
|
+
<>
|
|
491
|
+
{fontsHtml && <span dangerouslySetInnerHTML={{ __html: fontsHtml }} />}
|
|
492
|
+
<style dangerouslySetInnerHTML={{ __html: devCss }} />
|
|
493
|
+
</>
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
`
|
|
497
|
+
};
|
package/lib/export-theme.js
CHANGED
|
@@ -6,6 +6,8 @@ import { loadConfig } from "./load-config.js";
|
|
|
6
6
|
import { renderStaticMarkup } from "./render-static.js";
|
|
7
7
|
import { assertZipCreated, zipTheme } from "./zip-theme.js";
|
|
8
8
|
|
|
9
|
+
import { validateCriticalFiles } from "./validate.js";
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* @param {Object} options
|
|
11
13
|
* @param {string} options.themeRoot
|
|
@@ -15,6 +17,10 @@ import { assertZipCreated, zipTheme } from "./zip-theme.js";
|
|
|
15
17
|
*/
|
|
16
18
|
export async function exportTheme(options) {
|
|
17
19
|
const themeRoot = path.resolve(options.themeRoot);
|
|
20
|
+
|
|
21
|
+
// Run Preflight Safeguards and Self-Healing checks
|
|
22
|
+
validateCriticalFiles(themeRoot);
|
|
23
|
+
|
|
18
24
|
const config = await loadConfig(themeRoot);
|
|
19
25
|
|
|
20
26
|
console.log(pc.cyan(`\n ForgeWP export — ${config.name}\n`));
|
|
@@ -37,6 +43,11 @@ export async function exportTheme(options) {
|
|
|
37
43
|
appHtml: markup.appHtml,
|
|
38
44
|
headerHtml: markup.headerHtml,
|
|
39
45
|
footerHtml: markup.footerHtml,
|
|
46
|
+
headHtml: markup.headHtml,
|
|
47
|
+
singleHeadHtml: markup.singleHeadHtml,
|
|
48
|
+
singleHtml: markup.singleHtml,
|
|
49
|
+
notFoundHtml: markup.notFoundHtml,
|
|
50
|
+
archiveHtml: markup.archiveHtml,
|
|
40
51
|
assets,
|
|
41
52
|
});
|
|
42
53
|
|