@forgewp/compiler 0.3.0 → 0.4.2
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 +24 -5
- package/bin/analyze.js +158 -0
- package/bin/cli.js +33 -4
- package/bin/doctor.js +125 -11
- package/bin/export.js +20 -0
- package/bin/fresh.js +32 -343
- package/bin/i18n-extract.js +121 -0
- package/bin/i18n-translate.js +112 -0
- package/bin/make-block.js +27 -60
- package/bin/make-island.js +72 -0
- package/bin/make-post-type.js +6 -6
- package/bin/make-template.js +145 -0
- package/bin/repair.js +2 -2
- package/bin/sync-hooks.js +221 -0
- package/bin/sync-routes.js +28 -158
- package/define-config.d.ts +1 -0
- package/define-config.js +1 -0
- package/lib/adapters/html-adapter.js +65 -0
- package/lib/adapters/stub-adapter.js +49 -0
- package/lib/add-component.js +282 -183
- package/lib/asset-loader.js +27 -0
- package/lib/block-compiler.js +552 -0
- package/lib/blueprints.js +15 -501
- package/lib/define-config.d.ts +3 -0
- package/lib/define-config.js +8 -0
- package/lib/diagnostics.js +798 -0
- package/lib/export-theme.js +81 -18
- package/lib/framework-adapter.js +34 -0
- package/lib/functions-builder.js +2044 -0
- package/lib/generate-theme.js +1140 -1352
- package/lib/hydration-scanner.js +663 -21
- package/lib/i18n/extractor.js +60 -0
- package/lib/i18n/providers.js +165 -0
- package/lib/index.d.ts +115 -3
- package/lib/index.js +19 -5
- package/lib/load-config.js +122 -6
- package/lib/markup-processor.js +589 -0
- package/lib/php-builders.js +381 -0
- package/lib/react-adapter.js +1336 -0
- package/lib/render-static.js +9 -82
- package/lib/render-theme.mts +543 -232
- package/lib/screenshot-fallback.png +0 -0
- package/lib/types.js +1 -0
- package/lib/validate-export.js +183 -0
- package/package.json +15 -3
- package/templates/PresetsStyle.tsx +74 -0
- package/templates/SEO.tsx +109 -0
- package/templates/forgewp-config.ts +43 -0
- package/templates/menus.json +11 -0
- package/templates/mock-data.json +434 -0
- package/templates/wordpress.tsx +1297 -0
- package/bin/make-component.js +0 -200
|
Binary file
|
package/lib/types.js
CHANGED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { scanForHydrationIslands } from './hydration-scanner.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Validate exported theme package output.
|
|
7
|
+
* @param {{ themeRoot: string, outDir: string, assets: any, config: any, strict?: boolean }} opts
|
|
8
|
+
*/
|
|
9
|
+
export async function validateExport({ themeRoot, outDir, assets, config, strict = false }) {
|
|
10
|
+
const summary = { missing: [], warnings: [] };
|
|
11
|
+
const staticDir = path.join(outDir, 'forgewp-static');
|
|
12
|
+
|
|
13
|
+
const requiredThemeFiles = [
|
|
14
|
+
path.join(outDir, 'functions.php'),
|
|
15
|
+
path.join(outDir, 'style.css'),
|
|
16
|
+
path.join(outDir, 'header.php'),
|
|
17
|
+
path.join(outDir, 'footer.php'),
|
|
18
|
+
path.join(outDir, 'index.php'),
|
|
19
|
+
path.join(outDir, 'single.php'),
|
|
20
|
+
path.join(outDir, '404.php'),
|
|
21
|
+
path.join(outDir, 'front-page.php'),
|
|
22
|
+
path.join(outDir, 'archive.php'),
|
|
23
|
+
path.join(outDir, 'page.php'),
|
|
24
|
+
path.join(outDir, 'theme.json'),
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
for (const p of requiredThemeFiles) {
|
|
28
|
+
if (!fs.existsSync(p)) summary.missing.push(p.replace(process.cwd() + path.sep, ''));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const staticFiles = [
|
|
32
|
+
path.join(staticDir, 'content.html'),
|
|
33
|
+
path.join(staticDir, 'header.html'),
|
|
34
|
+
path.join(staticDir, 'footer.html'),
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
for (const p of staticFiles) {
|
|
38
|
+
if (!fs.existsSync(p)) {
|
|
39
|
+
summary.missing.push(p.replace(process.cwd() + path.sep, ''));
|
|
40
|
+
} else if (fs.readFileSync(p, 'utf8').trim().length === 0) {
|
|
41
|
+
const relative = p.replace(process.cwd() + path.sep, '');
|
|
42
|
+
if (p.endsWith('content.html')) summary.missing.push(relative);
|
|
43
|
+
else summary.warnings.push(relative);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const assetsDir = path.join(outDir, 'assets');
|
|
48
|
+
if (!fs.existsSync(assetsDir) || fs.readdirSync(assetsDir).length === 0) {
|
|
49
|
+
summary.missing.push(assetsDir.replace(process.cwd() + path.sep, ''));
|
|
50
|
+
} else {
|
|
51
|
+
const expectedAssets = [path.join(assetsDir, 'forgewp-editor.js')];
|
|
52
|
+
if (assets?.cssFile) expectedAssets.push(path.join(assetsDir, path.basename(assets.cssFile)));
|
|
53
|
+
|
|
54
|
+
// Hydration-related expectations
|
|
55
|
+
const islands = scanForHydrationIslands(themeRoot);
|
|
56
|
+
|
|
57
|
+
if (islands.length > 0 && assets?.jsFile) {
|
|
58
|
+
expectedAssets.push(path.join(assetsDir, path.basename(assets.jsFile)));
|
|
59
|
+
expectedAssets.push(path.join(assetsDir, 'forgewp-hydrator.js'));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
for (const assetPath of expectedAssets) {
|
|
63
|
+
if (!fs.existsSync(assetPath)) summary.missing.push(assetPath.replace(process.cwd() + path.sep, ''));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const hydrationManifestCandidates = [
|
|
67
|
+
path.join(themeRoot, 'dist', '.vite', 'manifest.json'),
|
|
68
|
+
path.join(themeRoot, 'dist', 'manifest.json'),
|
|
69
|
+
];
|
|
70
|
+
const hydrationManifestPath = hydrationManifestCandidates.find((candidate) => fs.existsSync(candidate));
|
|
71
|
+
let viteManifest = null;
|
|
72
|
+
|
|
73
|
+
if (islands.length > 0) {
|
|
74
|
+
if (!hydrationManifestPath) {
|
|
75
|
+
summary.missing.push('dist/.vite/manifest.json');
|
|
76
|
+
} else {
|
|
77
|
+
try {
|
|
78
|
+
viteManifest = JSON.parse(fs.readFileSync(hydrationManifestPath, 'utf8'));
|
|
79
|
+
} catch (err) {
|
|
80
|
+
summary.missing.push(`${hydrationManifestPath.replace(process.cwd() + path.sep, '')} (invalid JSON)`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (viteManifest && islands.length > 0) {
|
|
86
|
+
for (const island of islands) {
|
|
87
|
+
const pascalName = island
|
|
88
|
+
.split('-')
|
|
89
|
+
.map((w) => w.charAt(0).toUpperCase() + w.slice(1))
|
|
90
|
+
.join('');
|
|
91
|
+
|
|
92
|
+
let resolvedChunk = null;
|
|
93
|
+
for (const [key, value] of Object.entries(viteManifest)) {
|
|
94
|
+
const fileBasename = path.basename(value.file || '');
|
|
95
|
+
const cleanName = fileBasename.replace(/-[A-Za-z0-9_-]+\.js$/, '');
|
|
96
|
+
if (
|
|
97
|
+
key.endsWith(`/${pascalName}.tsx`) ||
|
|
98
|
+
key.endsWith(`/${pascalName}.ts`) ||
|
|
99
|
+
key.endsWith(`/${island}.tsx`) ||
|
|
100
|
+
key.endsWith(`/${island}.ts`) ||
|
|
101
|
+
cleanName === island ||
|
|
102
|
+
cleanName === pascalName.toLowerCase()
|
|
103
|
+
) {
|
|
104
|
+
resolvedChunk = value.file;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!resolvedChunk) {
|
|
110
|
+
summary.missing.push(`hydration asset for ${island}`);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const assetFile = path.join(assetsDir, path.basename(resolvedChunk));
|
|
115
|
+
if (!fs.existsSync(assetFile)) {
|
|
116
|
+
summary.missing.push(assetFile.replace(process.cwd() + path.sep, ''));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// functions.php should reference compiled assets when present
|
|
122
|
+
const functionsPhpPath = path.join(outDir, 'functions.php');
|
|
123
|
+
if (fs.existsSync(functionsPhpPath)) {
|
|
124
|
+
const functionsPhp = fs.readFileSync(functionsPhpPath, 'utf8');
|
|
125
|
+
if (assets?.cssFile && !functionsPhp.includes(path.basename(assets.cssFile))) summary.warnings.push(`${functionsPhpPath.replace(process.cwd() + path.sep, '')} (missing CSS asset reference)`);
|
|
126
|
+
if (islands.length > 0 && assets?.jsFile && !functionsPhp.includes(path.basename(assets.jsFile))) summary.warnings.push(`${functionsPhpPath.replace(process.cwd() + path.sep, '')} (missing JS asset reference)`);
|
|
127
|
+
if (islands.length > 0 && !functionsPhp.includes('forgewp-hydrator.js')) summary.warnings.push(`${functionsPhpPath.replace(process.cwd() + path.sep, '')} (missing forgewp-hydrator enqueue)`);
|
|
128
|
+
if (islands.length > 0 && !functionsPhp.includes('forgeWpHydration')) summary.warnings.push(`${functionsPhpPath.replace(process.cwd() + path.sep, '')} (missing hydration manifest localization)`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Validate style.css metadata
|
|
133
|
+
const styleCssPath = path.join(outDir, 'style.css');
|
|
134
|
+
if (fs.existsSync(styleCssPath)) {
|
|
135
|
+
const styleCss = fs.readFileSync(styleCssPath, 'utf8');
|
|
136
|
+
if (!/Theme Name:/i.test(styleCss)) summary.warnings.push(styleCssPath.replace(process.cwd() + path.sep, ''));
|
|
137
|
+
if (!/Text Domain:/i.test(styleCss)) summary.warnings.push(`${styleCssPath.replace(process.cwd() + path.sep, '')} (missing Text Domain)`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Validate theme.json
|
|
141
|
+
try {
|
|
142
|
+
const themeJsonPath = path.join(outDir, 'theme.json');
|
|
143
|
+
if (fs.existsSync(themeJsonPath)) {
|
|
144
|
+
const json = JSON.parse(fs.readFileSync(themeJsonPath, 'utf8'));
|
|
145
|
+
if (!json.version) summary.warnings.push('theme.json (missing version)');
|
|
146
|
+
}
|
|
147
|
+
} catch (err) {
|
|
148
|
+
summary.missing.push('theme.json');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Validate generated page templates from .forgewp/template-*.html
|
|
152
|
+
const templateDir = path.join(themeRoot, '.forgewp');
|
|
153
|
+
if (fs.existsSync(templateDir)) {
|
|
154
|
+
const templateFiles = fs.readdirSync(templateDir).filter((file) => /^template-.*\.html$/.test(file));
|
|
155
|
+
for (const templateFile of templateFiles) {
|
|
156
|
+
const slug = templateFile.replace(/^template-(.*)\.html$/, '$1');
|
|
157
|
+
const templatePhp = path.join(outDir, `page-${slug}.php`);
|
|
158
|
+
if (!fs.existsSync(templatePhp)) summary.missing.push(templatePhp.replace(process.cwd() + path.sep, ''));
|
|
159
|
+
|
|
160
|
+
const expectedStaticTemplate = path.join(staticDir, templateFile);
|
|
161
|
+
if (!fs.existsSync(expectedStaticTemplate)) summary.missing.push(expectedStaticTemplate.replace(process.cwd() + path.sep, ''));
|
|
162
|
+
|
|
163
|
+
const headSource = path.join(templateDir, `template-${slug}-head.html`);
|
|
164
|
+
const headOutput = path.join(staticDir, `template-${slug}-head.html`);
|
|
165
|
+
if (fs.existsSync(headSource) && !fs.existsSync(headOutput)) summary.missing.push(headOutput.replace(process.cwd() + path.sep, ''));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Screenshot copy
|
|
170
|
+
const screenshotSrc = path.join(themeRoot, 'cms', 'screenshot.png');
|
|
171
|
+
if (fs.existsSync(screenshotSrc)) {
|
|
172
|
+
const screenshotOut = path.join(outDir, 'screenshot.png');
|
|
173
|
+
if (!fs.existsSync(screenshotOut)) summary.missing.push(screenshotOut.replace(process.cwd() + path.sep, ''));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// If strict, treat warnings as missing
|
|
177
|
+
if (strict && summary.warnings.length > 0) {
|
|
178
|
+
summary.missing.push(...summary.warnings);
|
|
179
|
+
summary.warnings = [];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return summary;
|
|
183
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgewp/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Compile ForgeWP React themes into installable WordPress themes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,11 +11,18 @@
|
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./lib/index.d.ts",
|
|
13
13
|
"default": "./lib/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./define-config": {
|
|
16
|
+
"types": "./define-config.d.ts",
|
|
17
|
+
"default": "./define-config.js"
|
|
14
18
|
}
|
|
15
19
|
},
|
|
16
20
|
"files": [
|
|
17
21
|
"bin",
|
|
18
|
-
"lib"
|
|
22
|
+
"lib",
|
|
23
|
+
"templates",
|
|
24
|
+
"define-config.js",
|
|
25
|
+
"define-config.d.ts"
|
|
19
26
|
],
|
|
20
27
|
"engines": {
|
|
21
28
|
"node": ">=18"
|
|
@@ -25,9 +32,14 @@
|
|
|
25
32
|
"jiti": "^2.6.1",
|
|
26
33
|
"picocolors": "^1.1.1",
|
|
27
34
|
"react-helmet-async": "^3.0.0",
|
|
28
|
-
"@forgewp/ui": "0.
|
|
35
|
+
"@forgewp/ui": "0.4.2"
|
|
29
36
|
},
|
|
30
37
|
"devDependencies": {
|
|
31
38
|
"@types/node": "^22.19.19"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test:export-fixture": "node test/export-fixture/run-export-fixture.js",
|
|
42
|
+
"test:adapter-runtime": "node test/adapter-loader.js",
|
|
43
|
+
"test:adapter-types": "pnpm exec tsc --noEmit -p tsconfig.test.json"
|
|
32
44
|
}
|
|
33
45
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import wpConfig from "../../wp.config";
|
|
2
|
+
|
|
3
|
+
const IS_DEV =
|
|
4
|
+
typeof import.meta !== "undefined" &&
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import.meta.env?.DEV === true;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* PresetsStyle component — Internal system component.
|
|
10
|
+
*
|
|
11
|
+
* Dynamically injects WordPress-preset CSS Custom Properties and enqueues Google Fonts
|
|
12
|
+
* during local Vite development, keeping your styles perfectly in sync with WordPress.
|
|
13
|
+
* In production builds, this returns only the registry-aesthetic design tokens (like --radius)
|
|
14
|
+
* to keep shadcn components and theme variables responsive to your config.
|
|
15
|
+
*/
|
|
16
|
+
export function PresetsStyle() {
|
|
17
|
+
const themeStyle = wpConfig.style || "forgewp";
|
|
18
|
+
|
|
19
|
+
// Production build: only inject custom registry-aesthetic design properties
|
|
20
|
+
if (!IS_DEV) {
|
|
21
|
+
const prodCss = `
|
|
22
|
+
:root {
|
|
23
|
+
--radius: ${themeStyle === "forgewp" ? "0px" : "0.5rem"};
|
|
24
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
25
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
26
|
+
--radius-lg: var(--radius);
|
|
27
|
+
--border-width: ${themeStyle === "forgewp" ? "2px" : "1px"};
|
|
28
|
+
--border-color: ${themeStyle === "forgewp" ? "#09090b" : "#e4e4e7"};
|
|
29
|
+
--shadow-offset: ${themeStyle === "forgewp" ? "4px" : "0px"};
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
return <style dangerouslySetInnerHTML={{ __html: prodCss }} />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Local development fallbacks for WordPress CSS presets
|
|
36
|
+
const colors = wpConfig.settings?.color?.palette || [];
|
|
37
|
+
const fontSizes = wpConfig.settings?.typography?.fontSizes || [];
|
|
38
|
+
const fontFamilies = wpConfig.settings?.typography?.fontFamilies || [];
|
|
39
|
+
const layout = wpConfig.settings?.layout || {};
|
|
40
|
+
const googleFonts = wpConfig.settings?.typography?.googleFonts || [];
|
|
41
|
+
|
|
42
|
+
// Parse and build Google Fonts href for dev injection
|
|
43
|
+
const fontsHtml = googleFonts.length > 0
|
|
44
|
+
? `<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
45
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
46
|
+
<link href="https://fonts.googleapis.com/css2?family=&{googleFonts.map(f => encodeURIComponent(f)).join("&family=")}&display=swap" rel="stylesheet">`
|
|
47
|
+
: "";
|
|
48
|
+
|
|
49
|
+
const devCss = `
|
|
50
|
+
:root {
|
|
51
|
+
${colors.map((c) => "--wp--preset--color--" + c.slug + ": " + c.color + ";").join("\n ")}
|
|
52
|
+
${fontSizes.map((f) => "--wp--preset--font-size--" + f.slug + ": " + f.size + ";").join("\n ")}
|
|
53
|
+
${fontFamilies.map((f) => "--wp--preset--font-family--" + f.slug + ": " + f.fontFamily + ";").join("\n ")}
|
|
54
|
+
${layout.contentSize ? "--wp--style--global--content-size: " + layout.contentSize + ";" : ""}
|
|
55
|
+
${layout.wideSize ? "--wp--style--global--wide-size: " + layout.wideSize + ";" : ""}
|
|
56
|
+
|
|
57
|
+
/* Registry Aesthetic Mode Custom Properties */
|
|
58
|
+
--radius: ${themeStyle === "forgewp" ? "0px" : "0.5rem"};
|
|
59
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
60
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
61
|
+
--radius-lg: var(--radius);
|
|
62
|
+
--border-width: ${themeStyle === "forgewp" ? "2px" : "1px"};
|
|
63
|
+
--border-color: ${themeStyle === "forgewp" ? "#09090b" : "#e4e4e7"};
|
|
64
|
+
--shadow-offset: ${themeStyle === "forgewp" ? "4px" : "0px"};
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
{fontsHtml && <span dangerouslySetInnerHTML={{ __html: fontsHtml }} />}
|
|
71
|
+
<style dangerouslySetInnerHTML={{ __html: devCss }} />
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as ReactHelmetAsync from "react-helmet-async";
|
|
3
|
+
import { useWpTitle } from "./wordpress";
|
|
4
|
+
|
|
5
|
+
const defaultKey = "default";
|
|
6
|
+
const ReactHelmetLib = (ReactHelmetAsync as any).Helmet
|
|
7
|
+
? ReactHelmetAsync
|
|
8
|
+
: (ReactHelmetAsync as any)[defaultKey] ?? ReactHelmetAsync;
|
|
9
|
+
const Helmet = (ReactHelmetLib as any).Helmet || React.Fragment;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* ForgeWP SEO — Internal system file. Do not delete.
|
|
13
|
+
*
|
|
14
|
+
* Use this component in `src/app/layout.tsx` to set global SEO defaults,
|
|
15
|
+
* and in individual page files to override them per-page.
|
|
16
|
+
*
|
|
17
|
+
* The ForgeWP compiler reads the props you pass here and injects them
|
|
18
|
+
* directly into the WordPress theme's <head> as native meta tags.
|
|
19
|
+
*
|
|
20
|
+
* @see https://forgewp.dev/docs/seo
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
export interface SEOProps {
|
|
24
|
+
/** Page title — defaults to the WordPress post title via useWpTitle() */
|
|
25
|
+
title?: string;
|
|
26
|
+
/** Meta description for search engines and social cards */
|
|
27
|
+
description?: string;
|
|
28
|
+
/** Comma-separated keywords */
|
|
29
|
+
keywords?: string;
|
|
30
|
+
/** Open Graph title (falls back to title if omitted) */
|
|
31
|
+
ogTitle?: string;
|
|
32
|
+
/** Open Graph description (falls back to description if omitted) */
|
|
33
|
+
ogDescription?: string;
|
|
34
|
+
/** Absolute URL to the Open Graph image */
|
|
35
|
+
ogImage?: string;
|
|
36
|
+
/** Open Graph type — "website" for homepages, "article" for posts */
|
|
37
|
+
ogType?: string;
|
|
38
|
+
/** Twitter card type */
|
|
39
|
+
twitterCard?: string;
|
|
40
|
+
/** Twitter creator handle, e.g. "@username" */
|
|
41
|
+
twitterCreator?: string;
|
|
42
|
+
/** Canonical URL — tells search engines the preferred version of this page */
|
|
43
|
+
canonical?: string;
|
|
44
|
+
/** Set to true to prevent this page from being indexed by search engines */
|
|
45
|
+
noIndex?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `<SEO>` — ForgeWP SEO manager.
|
|
50
|
+
*
|
|
51
|
+
* Drop this into your **layout.tsx** to set site-wide defaults.
|
|
52
|
+
* Then drop it into any **page file** to override for that specific template.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // layout.tsx — global defaults (the compiler reads these for all pages)
|
|
56
|
+
* <SEO
|
|
57
|
+
* description="Your site tagline or description."
|
|
58
|
+
* keywords="WordPress, React, Tailwind"
|
|
59
|
+
* ogImage="https://yoursite.com/og-default.png"
|
|
60
|
+
* />
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // single.tsx — per-page override (article-specific metadata)
|
|
64
|
+
* <SEO
|
|
65
|
+
* ogType="article"
|
|
66
|
+
* ogImage="https://yoursite.com/og-post.png"
|
|
67
|
+
* twitterCreator="@yourhandle"
|
|
68
|
+
* />
|
|
69
|
+
*/
|
|
70
|
+
export function SEO({
|
|
71
|
+
title,
|
|
72
|
+
description = "A WordPress theme built with ForgeWP — React & Tailwind CSS.",
|
|
73
|
+
keywords = "WordPress, React, Tailwind CSS, ForgeWP",
|
|
74
|
+
ogTitle,
|
|
75
|
+
ogDescription,
|
|
76
|
+
ogImage,
|
|
77
|
+
ogType = "website",
|
|
78
|
+
twitterCard = "summary_large_image",
|
|
79
|
+
twitterCreator,
|
|
80
|
+
canonical,
|
|
81
|
+
noIndex = false,
|
|
82
|
+
}: SEOProps) {
|
|
83
|
+
const wpTitle = useWpTitle();
|
|
84
|
+
const resolvedTitle = title ?? wpTitle;
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Helmet>
|
|
88
|
+
{/* ── Primary ── */}
|
|
89
|
+
<title>{resolvedTitle}</title>
|
|
90
|
+
<meta name="description" content={description} />
|
|
91
|
+
{keywords && <meta name="keywords" content={keywords} />}
|
|
92
|
+
{noIndex && <meta name="robots" content="noindex, nofollow" />}
|
|
93
|
+
{canonical && <link rel="canonical" href={canonical} />}
|
|
94
|
+
|
|
95
|
+
{/* ── Open Graph ── */}
|
|
96
|
+
<meta property="og:type" content={ogType} />
|
|
97
|
+
<meta property="og:title" content={ogTitle ?? resolvedTitle} />
|
|
98
|
+
<meta property="og:description" content={ogDescription ?? description} />
|
|
99
|
+
{ogImage && <meta property="og:image" content={ogImage} />}
|
|
100
|
+
|
|
101
|
+
{/* ── Twitter ── */}
|
|
102
|
+
<meta name="twitter:card" content={twitterCard} />
|
|
103
|
+
<meta name="twitter:title" content={ogTitle ?? resolvedTitle} />
|
|
104
|
+
<meta name="twitter:description" content={ogDescription ?? description} />
|
|
105
|
+
{ogImage && <meta name="twitter:image" content={ogImage} />}
|
|
106
|
+
{twitterCreator && <meta name="twitter:creator" content={twitterCreator} />}
|
|
107
|
+
</Helmet>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface ColorPreset {
|
|
2
|
+
name: string;
|
|
3
|
+
slug: string;
|
|
4
|
+
color: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface FontSizePreset {
|
|
8
|
+
name: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
size: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FontFamilyPreset {
|
|
14
|
+
name: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
fontFamily: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ForgeWPThemeConfig {
|
|
20
|
+
name: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
version: string;
|
|
23
|
+
description: string;
|
|
24
|
+
textDomain: string;
|
|
25
|
+
/** Design aesthetic style — "forgewp" (sharp edges, high-contrast) or "shadcn" (smooth rounded modern) */
|
|
26
|
+
style?: "forgewp" | "shadcn";
|
|
27
|
+
// Design Tokens (Phase 5)
|
|
28
|
+
settings?: {
|
|
29
|
+
layout?: {
|
|
30
|
+
contentSize?: string;
|
|
31
|
+
wideSize?: string;
|
|
32
|
+
};
|
|
33
|
+
color?: {
|
|
34
|
+
palette?: ColorPreset[];
|
|
35
|
+
custom?: boolean;
|
|
36
|
+
};
|
|
37
|
+
typography?: {
|
|
38
|
+
fontSizes?: FontSizePreset[];
|
|
39
|
+
fontFamilies?: FontFamilyPreset[];
|
|
40
|
+
googleFonts?: string[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "⚡ ForgeWP Navigation Menus — Edit this file to add/remove links in local dev.",
|
|
3
|
+
"primary": [
|
|
4
|
+
{ "title": "Hotelvergleiche", "url": "/hotelvergleiche" },
|
|
5
|
+
{ "title": "Hotels", "url": "/hotels" },
|
|
6
|
+
{ "title": "Über uns", "url": "/about" }
|
|
7
|
+
],
|
|
8
|
+
"utility": [
|
|
9
|
+
{ "title": "Kontakt", "url": "/contact" }
|
|
10
|
+
]
|
|
11
|
+
}
|