kizlo 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/_setup.js +2 -2
- package/dist/cli/commands/_wiring.js +13 -11
- package/dist/cli/commands/create.js +3 -3
- package/dist/cli/commands/init.js +2 -2
- package/dist/cli/daemon/config.js +11 -3
- package/dist/cli/presets/patch.js +38 -0
- package/dist/cli/presets/template.js +1 -35
- package/dist/cli/wp/stack.js +2 -2
- package/dist/config.d.ts +1 -1
- package/dist/context.js +9 -3
- package/dist/integrations/nextjs/metadata.d.ts +7 -1
- package/dist/integrations/nextjs/metadata.js +12 -1
- package/dist/nextjs/server.d.ts +2 -2
- package/dist/nextjs/server.js +2 -2
- package/dist/package.js +1 -1
- package/dist/router.d.ts +5 -5
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LOCAL_DIR_REL } from "../wp/constants.js";
|
|
2
2
|
import { composeStop, createStack, dockerHint, dockerStatus } from "../wp/docker.js";
|
|
3
3
|
import { DEFAULT_ENV_KEYS, ensureGitignored, envGroups, envKeysPresent, mergeEnv, pickStackPort, writeFileIfAbsent } from "../utils.js";
|
|
4
|
-
import { DEFAULT_DEV_DB_PORT, DEFAULT_DEV_PORT, resolveStackName } from "../daemon/config.js";
|
|
4
|
+
import { DEFAULT_DEV_DB_PORT, DEFAULT_DEV_PORT, resolveStackName, stackProject } from "../daemon/config.js";
|
|
5
5
|
import { createAdminAppPassword } from "../wp/bootstrap.js";
|
|
6
6
|
import { bootstrapDev } from "../wp/dev.js";
|
|
7
7
|
import { removeProjectContainers } from "../wp/session.js";
|
|
@@ -238,7 +238,7 @@ function collectConnectionFromEnv(envKeys) {
|
|
|
238
238
|
function devConfigFor(cwd) {
|
|
239
239
|
return {
|
|
240
240
|
configDir: cwd,
|
|
241
|
-
project:
|
|
241
|
+
project: stackProject(resolveStackName(cwd), "dev"),
|
|
242
242
|
port: DEFAULT_DEV_PORT,
|
|
243
243
|
portExplicit: false,
|
|
244
244
|
dbPort: DEFAULT_DEV_DB_PORT,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { resolveModuleImport, writeFileIfAbsent } from "../utils.js";
|
|
2
|
-
import {
|
|
3
|
-
import { findRootLayout, resolvePatch } from "../presets/template.js";
|
|
2
|
+
import { resolvePatch } from "../presets/template.js";
|
|
4
3
|
import { orCancel } from "./_setup.js";
|
|
5
4
|
import { CONTRACT_BARREL } from "../daemon/generate.js";
|
|
5
|
+
import { applyPatchToSource, patchChanged, renderPatchCode, resolvePatchTargetPath } from "../presets/patch.js";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import * as p from "@clack/prompts";
|
|
@@ -73,17 +73,19 @@ function writeGeneratedContract(cwd, serverDirRel) {
|
|
|
73
73
|
writeFileIfAbsent(path.join(cwd, generatedDirRel, "index.ts"), CONTRACT_BARREL);
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
76
|
+
* Apply every patch a template declares, merging Kizlo wiring into files the project already owns
|
|
77
|
+
* (today: the root layout and home page SEO exports — but the loop is role-agnostic, so a new patch
|
|
78
|
+
* needs no change here). Never aborts: the target is the exact path the template declares (extension-
|
|
79
|
+
* probed so a JS project's `.js`/`.jsx` is found), and on any doubt — the file isn't at that path, or
|
|
80
|
+
* won't parse — the resolved payload is printed at the end with placement instructions rather than
|
|
81
|
+
* written to a guessed-at file. We never scan the tree to find a stand-in. A confident apply is an
|
|
82
|
+
* idempotent upsert: it replaces our exports if present, adds them if not.
|
|
81
83
|
*/
|
|
82
|
-
function
|
|
84
|
+
function applyProjectPatches(cwd, patches, conventions, scaffold) {
|
|
83
85
|
const manualSteps = [];
|
|
84
86
|
for (const entry of patches) {
|
|
85
87
|
const resolved = resolvePatch(entry, conventions, scaffold);
|
|
86
|
-
const target =
|
|
88
|
+
const target = resolvePatchTargetPath(cwd, resolved.relPath);
|
|
87
89
|
if (!target) {
|
|
88
90
|
manualSteps.push(resolved);
|
|
89
91
|
p.log.info(`Couldn't find your ${resolved.label} to wire Kizlo into — see the code to add below`);
|
|
@@ -105,8 +107,8 @@ function applyLayoutPatches(cwd, patches, conventions, scaffold) {
|
|
|
105
107
|
p.log.success(`Wired Kizlo into your ${resolved.label} (${relTarget})`);
|
|
106
108
|
} else p.log.info(`Your ${resolved.label} is already wired (${relTarget})`);
|
|
107
109
|
}
|
|
108
|
-
for (const resolved of manualSteps) p.note(renderPatchCode(resolved), `Add these to your ${resolved.label} (
|
|
110
|
+
for (const resolved of manualSteps) p.note(renderPatchCode(resolved), `Add these to your ${resolved.label} (${resolved.relPath})`);
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
//#endregion
|
|
112
|
-
export {
|
|
114
|
+
export { applyProjectPatches, buildScaffoldContext, kizloConfigTemplate, reportScaffold, scaffoldFile, writeGeneratedContract };
|
|
@@ -2,7 +2,7 @@ import { availablePackageManagers, detectInvokingPackageManager, ensureGitignore
|
|
|
2
2
|
import { fetchRegistry, listTemplates, resolveRegistry } from "../presets/source.js";
|
|
3
3
|
import { adaptFile, changesFor, fileEntries, minCliError, patchEntries, readManifest, resolveDependencies } from "../presets/template.js";
|
|
4
4
|
import { collectConnectionInteractively, nextStepsLines, orCancel, pickAppPort, readEnvExample, resolveEnvKeys, setupLocalWordPress, syncRemote, validate, withApiPath, writeEnv } from "./_setup.js";
|
|
5
|
-
import {
|
|
5
|
+
import { applyProjectPatches, buildScaffoldContext, kizloConfigTemplate, reportScaffold, scaffoldFile, writeGeneratedContract } from "./_wiring.js";
|
|
6
6
|
import z from "zod/v4";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import fs from "node:fs";
|
|
@@ -88,7 +88,7 @@ function bootstrapArgs(manifest, pm, name) {
|
|
|
88
88
|
* `kizlo` dependency, write `kizlo.config.ts`, scaffold the manifest's files (core wiring from `base`
|
|
89
89
|
* and `create` always, the `example`-flagged demo pages only when `includeExamples`),
|
|
90
90
|
* seed the generated contract, and ignore `.env` and the `.kizlo/` working dir (which holds the local WordPress install). On a fresh app Kizlo owns the layout, so `create`
|
|
91
|
-
* writes it whole (already SEO-wired) rather than patching — `
|
|
91
|
+
* writes it whole (already SEO-wired) rather than patching — `applyProjectPatches` runs over `create`'s
|
|
92
92
|
* patches, which are none today. The target directory layout comes straight from the manifest's
|
|
93
93
|
* conventions, which the bootstrap flags are chosen to match, so files land where they expect. Fresh
|
|
94
94
|
* files are written with `force`, silently replacing the framework defaults.
|
|
@@ -115,7 +115,7 @@ async function applyManifestWiring(dir, templateDir, manifest, opts) {
|
|
|
115
115
|
writeGeneratedContract(dir, path.join(kizloDir, "server"));
|
|
116
116
|
ensureGitignored(dir, ".env");
|
|
117
117
|
ensureGitignored(dir, ".kizlo/");
|
|
118
|
-
|
|
118
|
+
applyProjectPatches(dir, patchEntries(changes), manifest.conventions, scaffold);
|
|
119
119
|
}
|
|
120
120
|
const create = defineCommand({
|
|
121
121
|
meta: {
|
|
@@ -2,7 +2,7 @@ import { addDependencyArgs, detectImportAlias, detectPackageManager, ensureGitig
|
|
|
2
2
|
import { DEFAULT_REGISTRY, detectTemplates, fetchRegistry, isSingleTemplate, listTemplates, resolveRegistry } from "../presets/source.js";
|
|
3
3
|
import { adaptFile, changesFor, fileEntries, isOlderVersion, minCliError, patchEntries, readManifest, renderNote, resolveDependencies } from "../presets/template.js";
|
|
4
4
|
import { collectConnectionFromEnv, collectConnectionInteractively, dirPath, nextStepsNote, orCancel, readEnvExample, resolveEnvKeys, setupLocalWordPress, syncRemote, validate, withApiPath, writeEnv } from "./_setup.js";
|
|
5
|
-
import {
|
|
5
|
+
import { applyProjectPatches, buildScaffoldContext, kizloConfigTemplate, reportScaffold, scaffoldFile, writeGeneratedContract } from "./_wiring.js";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import { defineCommand } from "citty";
|
|
@@ -281,7 +281,7 @@ const init = defineCommand({
|
|
|
281
281
|
const gitignore = ensureGitignored(cwd, ".env");
|
|
282
282
|
ensureGitignored(cwd, ".kizlo/");
|
|
283
283
|
for (const { file, result } of scaffolded) reportScaffold(file, result, yes);
|
|
284
|
-
|
|
284
|
+
applyProjectPatches(cwd, patchEntries(changesFor(manifest, "init")), manifest.conventions, scaffold);
|
|
285
285
|
for (const note of manifest.notes ?? []) {
|
|
286
286
|
const rendered = renderNote(note, setup.alias);
|
|
287
287
|
p.note(rendered.body, rendered.title);
|
|
@@ -105,6 +105,14 @@ function resolveStackName(configDir, configName) {
|
|
|
105
105
|
return sanitizeProjectName(pkgName ?? path.basename(configDir));
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
+
* Compose project id for a stack: `kizlo-<name>-<kind>`. The leading `kizlo-` is what
|
|
109
|
+
* lets every stack this tool starts be filtered together in Docker (e.g.
|
|
110
|
+
* `docker ps --filter name=kizlo-`), independent of each project's own name.
|
|
111
|
+
*/
|
|
112
|
+
function stackProject(baseName, kind) {
|
|
113
|
+
return `kizlo-${baseName}-${kind}`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
108
116
|
* Resolve the `test` block from `kizlo.config.*` into concrete values for the
|
|
109
117
|
* `test` command, applying defaults (port 8889, auto-detected package manager)
|
|
110
118
|
* and anchoring the credentials artifact to the config directory.
|
|
@@ -116,7 +124,7 @@ async function resolveTestConfig(cwd) {
|
|
|
116
124
|
return {
|
|
117
125
|
configDir,
|
|
118
126
|
local: Boolean(test.local),
|
|
119
|
-
project:
|
|
127
|
+
project: stackProject(resolveStackName(configDir, fileConfig?.name), "test"),
|
|
120
128
|
command: test.command,
|
|
121
129
|
port: test.port ?? DEFAULT_TEST_PORT,
|
|
122
130
|
portExplicit: test.port !== void 0,
|
|
@@ -148,7 +156,7 @@ async function resolveDevConfig(cwd) {
|
|
|
148
156
|
const dev = fileConfig?.dev ?? {};
|
|
149
157
|
return {
|
|
150
158
|
configDir,
|
|
151
|
-
project:
|
|
159
|
+
project: stackProject(resolveStackName(configDir, fileConfig?.name), "dev"),
|
|
152
160
|
port: dev.port ?? DEFAULT_DEV_PORT,
|
|
153
161
|
portExplicit: dev.port !== void 0,
|
|
154
162
|
dbPort: dev.dbPort ?? DEFAULT_DEV_DB_PORT,
|
|
@@ -160,4 +168,4 @@ async function resolveDevConfig(cwd) {
|
|
|
160
168
|
}
|
|
161
169
|
|
|
162
170
|
//#endregion
|
|
163
|
-
export { CONFIG_FILES, DEFAULT_DEV_DB_PORT, DEFAULT_DEV_PORT, resolveConfig, resolveDevConfig, resolveStackName, resolveTestConfig, usesLocalWordPress };
|
|
171
|
+
export { CONFIG_FILES, DEFAULT_DEV_DB_PORT, DEFAULT_DEV_PORT, resolveConfig, resolveDevConfig, resolveStackName, resolveTestConfig, stackProject, usesLocalWordPress };
|
|
@@ -47,6 +47,36 @@ function staticCounterpart(name) {
|
|
|
47
47
|
function sameExpr(a, b) {
|
|
48
48
|
return a.replace(/\s+/g, "") === b.replace(/\s+/g, "");
|
|
49
49
|
}
|
|
50
|
+
/** The module's statement list (magicast's `$ast` is a `Program`, but tolerate a `File` wrapper too). */
|
|
51
|
+
function programBody(mod) {
|
|
52
|
+
const ast = mod.$ast;
|
|
53
|
+
return (ast.type === "File" ? ast.program : ast).body;
|
|
54
|
+
}
|
|
55
|
+
/** The name of an `export const <name> = …` statement, or undefined for any other node. */
|
|
56
|
+
function exportedConstName(node) {
|
|
57
|
+
if (node.type !== "ExportNamedDeclaration") return void 0;
|
|
58
|
+
const decl = node.declaration;
|
|
59
|
+
if (decl?.type !== "VariableDeclaration") return void 0;
|
|
60
|
+
const id = decl.declarations?.[0]?.id;
|
|
61
|
+
return id?.type === "Identifier" ? id.name : void 0;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Move the just-inserted exports (named in `names`) up to sit right after the import block, so wiring
|
|
65
|
+
* lands near the top of the file instead of appended below the component. magicast always appends a new
|
|
66
|
+
* export to the end of the program; this re-splices those nodes in after the last import, preserving
|
|
67
|
+
* their declared order. Exports we replaced in place are untouched — only nodes we added this run move.
|
|
68
|
+
*/
|
|
69
|
+
function hoistExportsAfterImports(mod, names) {
|
|
70
|
+
const body = programBody(mod);
|
|
71
|
+
const moved = [];
|
|
72
|
+
for (const name of names) {
|
|
73
|
+
const idx = body.findIndex((node) => exportedConstName(node) === name);
|
|
74
|
+
if (idx !== -1) moved.push(body.splice(idx, 1)[0]);
|
|
75
|
+
}
|
|
76
|
+
let insertAt = 0;
|
|
77
|
+
for (let i = 0; i < body.length; i++) if (body[i]?.type === "ImportDeclaration") insertAt = i + 1;
|
|
78
|
+
body.splice(insertAt, 0, ...moved);
|
|
79
|
+
}
|
|
50
80
|
/**
|
|
51
81
|
* Merge a resolved patch into `source` by parsing it with magicast (a real TS/JS/JSX parser via Babel,
|
|
52
82
|
* so declarations are bounded exactly — never by a text heuristic). Missing imports are added; each
|
|
@@ -57,6 +87,10 @@ function sameExpr(a, b) {
|
|
|
57
87
|
* export body isn't meant to be hand-customized. Idempotent: an export already equal to ours is left
|
|
58
88
|
* untouched, so re-running never churns the file.
|
|
59
89
|
*
|
|
90
|
+
* magicast appends new exports to the end of the file; we then hoist the ones we added this run up to
|
|
91
|
+
* sit right after the import block, so wiring reads near the top instead of below the component. Exports
|
|
92
|
+
* replaced in place keep their position — only nodes newly inserted this run move.
|
|
93
|
+
*
|
|
60
94
|
* Throws if the target cannot be parsed or regenerated. Callers must NOT swallow that — a file we
|
|
61
95
|
* can't parse is one we must not guess at, so wiring falls back to a printed instruction instead.
|
|
62
96
|
*/
|
|
@@ -71,6 +105,7 @@ function applyPatchToSource(source, patch) {
|
|
|
71
105
|
addedExports: [],
|
|
72
106
|
replacedExports: []
|
|
73
107
|
};
|
|
108
|
+
const insertedNames = [];
|
|
74
109
|
for (const imp of patch.imports) for (const name of imp.names) {
|
|
75
110
|
if (mod.imports.$items.some((item) => item.from === imp.module && item.imported === name)) continue;
|
|
76
111
|
mod.imports.$append({
|
|
@@ -92,11 +127,14 @@ function applyPatchToSource(source, patch) {
|
|
|
92
127
|
delete mod.exports[counterpart];
|
|
93
128
|
mod.exports[exp.name] = builders.raw(exp.value);
|
|
94
129
|
changes.replacedExports.push(exp.name);
|
|
130
|
+
insertedNames.push(exp.name);
|
|
95
131
|
continue;
|
|
96
132
|
}
|
|
97
133
|
mod.exports[exp.name] = builders.raw(exp.value);
|
|
98
134
|
changes.addedExports.push(exp.name);
|
|
135
|
+
insertedNames.push(exp.name);
|
|
99
136
|
}
|
|
137
|
+
if (insertedNames.length) hoistExportsAfterImports(mod, insertedNames);
|
|
100
138
|
return {
|
|
101
139
|
text: generateCode(mod, { format }).code,
|
|
102
140
|
changes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getVersion } from "../utils.js";
|
|
2
|
-
import { resolvePatchTargetPath } from "./patch.js";
|
|
3
2
|
import z from "zod/v4";
|
|
4
3
|
import path from "node:path";
|
|
5
4
|
import fs from "node:fs";
|
|
@@ -290,39 +289,6 @@ function resolvePatch(entry, conventions, ctx) {
|
|
|
290
289
|
exports: entry.exports
|
|
291
290
|
};
|
|
292
291
|
}
|
|
293
|
-
const LAYOUT_FILE = /^layout\.(tsx|jsx|ts|js|mjs|cjs)$/;
|
|
294
|
-
/** A root layout is the one that renders `<html>` — its identity, not its path. */
|
|
295
|
-
const RENDERS_HTML = /<html[\s/>]/;
|
|
296
|
-
/** Every file under `dir`, recursively (files only). Missing dir yields nothing. */
|
|
297
|
-
function walk(dir) {
|
|
298
|
-
if (!fs.existsSync(dir)) return [];
|
|
299
|
-
const out = [];
|
|
300
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
301
|
-
const full = path.join(dir, entry.name);
|
|
302
|
-
if (entry.isDirectory()) out.push(...walk(full));
|
|
303
|
-
else out.push(full);
|
|
304
|
-
}
|
|
305
|
-
return out;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Resolve the root layout by identity, not path. Try the manifest hint first; if it exists and
|
|
309
|
-
* renders `<html>`, use it. Otherwise scan the App Router directory for a layout that renders `<html>`
|
|
310
|
-
* and use it only when there is exactly one. On zero, many, or an unreadable file, return undefined so
|
|
311
|
-
* the caller prints the wiring for the user to place. Never guesses.
|
|
312
|
-
*/
|
|
313
|
-
function findRootLayout(cwd, appDir, hintRelPath) {
|
|
314
|
-
const hint = resolvePatchTargetPath(cwd, hintRelPath);
|
|
315
|
-
if (hint && rendersHtml(hint)) return hint;
|
|
316
|
-
const matches = walk(path.join(cwd, appDir)).filter((file) => LAYOUT_FILE.test(path.basename(file)) && rendersHtml(file));
|
|
317
|
-
return matches.length === 1 ? matches[0] : void 0;
|
|
318
|
-
}
|
|
319
|
-
function rendersHtml(file) {
|
|
320
|
-
try {
|
|
321
|
-
return RENDERS_HTML.test(fs.readFileSync(file, "utf8"));
|
|
322
|
-
} catch {
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
292
|
|
|
327
293
|
//#endregion
|
|
328
|
-
export { adaptFile, changesFor, fileEntries,
|
|
294
|
+
export { adaptFile, changesFor, fileEntries, isOlderVersion, minCliError, patchEntries, readManifest, renderNote, resolveDependencies, resolvePatch };
|
package/dist/cli/wp/stack.js
CHANGED
|
@@ -8,7 +8,7 @@ function localMounts(fixtures) {
|
|
|
8
8
|
return fixtures.flatMap((fixture) => fixture.plugins ?? []).filter(isLocalPlugin).map((plugin) => plugin.path);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* The test stack: the base compose file under a
|
|
11
|
+
* The test stack: the base compose file under a `kizlo-<name>-test` project, plus a generated
|
|
12
12
|
* mount override when any fixture carries a local (`{ path }`) plugin — so the same
|
|
13
13
|
* fixtures bind-mount their live plugin source here exactly as in local WordPress.
|
|
14
14
|
*/
|
|
@@ -37,7 +37,7 @@ function detectHostUser() {
|
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Local WordPress: the base compose file plus the generated mount override, under a
|
|
40
|
-
*
|
|
40
|
+
* `kizlo-<name>-dev` project. Building it (re)writes the override so it always matches the
|
|
41
41
|
* install folder (`.kizlo/local`) and the `dev.fixtures` local plugins.
|
|
42
42
|
*/
|
|
43
43
|
function devStack(cfg) {
|
package/dist/config.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ interface KizloGlobalConfig {
|
|
|
68
68
|
*/
|
|
69
69
|
alias?: string;
|
|
70
70
|
/**
|
|
71
|
-
* Base name for the local Docker stacks (
|
|
71
|
+
* Base name for the local Docker stacks (`kizlo-<name>-dev`, `kizlo-<name>-test`). Defaults
|
|
72
72
|
* to the sanitized `package.json` name, falling back to the config dir basename.
|
|
73
73
|
*/
|
|
74
74
|
name?: string;
|
package/dist/context.js
CHANGED
|
@@ -6,7 +6,7 @@ import { WordPressService } from "./wordpress/service.js";
|
|
|
6
6
|
import { EmailService } from "./email/service.js";
|
|
7
7
|
import { SettingsService } from "./settings/service.js";
|
|
8
8
|
import { PLUGIN_VERSION_HEADER, base64Decode, isPluginVersionSupported, pluginUpdateMessage, tryCatchSync } from "@kizlo/shared";
|
|
9
|
-
import {
|
|
9
|
+
import { stringifySetCookie } from "cookie";
|
|
10
10
|
|
|
11
11
|
//#region src/context.ts
|
|
12
12
|
var Context = class {
|
|
@@ -93,13 +93,19 @@ var Context = class {
|
|
|
93
93
|
},
|
|
94
94
|
setAll: async (cookies) => {
|
|
95
95
|
cookies.forEach((cookie) => {
|
|
96
|
-
headers.append("Set-Cookie",
|
|
96
|
+
headers.append("Set-Cookie", stringifySetCookie({
|
|
97
|
+
...cookie.options,
|
|
98
|
+
name: cookie.name,
|
|
99
|
+
value: cookie.value
|
|
100
|
+
}));
|
|
97
101
|
});
|
|
98
102
|
},
|
|
99
103
|
deleteAll: async (cookies) => {
|
|
100
104
|
cookies.forEach((cookie) => {
|
|
101
|
-
headers.append("Set-Cookie",
|
|
105
|
+
headers.append("Set-Cookie", stringifySetCookie({
|
|
102
106
|
...cookie.options,
|
|
107
|
+
name: cookie.name,
|
|
108
|
+
value: "",
|
|
103
109
|
maxAge: 0,
|
|
104
110
|
expires: /* @__PURE__ */ new Date(0)
|
|
105
111
|
}));
|
|
@@ -13,6 +13,12 @@ declare function createRootMetadata(client: S2SClient<[]>): () => Promise<Metada
|
|
|
13
13
|
* is set, both are emitted with `prefers-color-scheme` media queries.
|
|
14
14
|
*/
|
|
15
15
|
declare function createRootViewport(client: S2SClient<[]>): () => Promise<Viewport>;
|
|
16
|
+
/**
|
|
17
|
+
* Home `generateMetadata` for `app/page.tsx`, resolving the homepage SEO head from WordPress.
|
|
18
|
+
* A factory (rather than the inline call the `create` template shows) so `init` can wire it into
|
|
19
|
+
* an existing home page as a single `export const generateMetadata = createHomeMetadata(client)`.
|
|
20
|
+
*/
|
|
21
|
+
declare function createHomeMetadata(client: S2SClient<[]>): () => Promise<Metadata>;
|
|
16
22
|
declare function createPageMetadata(head: SeoHead): Metadata;
|
|
17
23
|
//#endregion
|
|
18
|
-
export { createPageMetadata, createRootMetadata, createRootViewport };
|
|
24
|
+
export { createHomeMetadata, createPageMetadata, createRootMetadata, createRootViewport };
|
|
@@ -49,6 +49,17 @@ function toNextIcon(icon) {
|
|
|
49
49
|
sizes: icon.sizes
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Home `generateMetadata` for `app/page.tsx`, resolving the homepage SEO head from WordPress.
|
|
54
|
+
* A factory (rather than the inline call the `create` template shows) so `init` can wire it into
|
|
55
|
+
* an existing home page as a single `export const generateMetadata = createHomeMetadata(client)`.
|
|
56
|
+
*/
|
|
57
|
+
function createHomeMetadata(client) {
|
|
58
|
+
return async function generateMetadata() {
|
|
59
|
+
const { head } = await client.seo.homepage.call();
|
|
60
|
+
return createPageMetadata(head);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
52
63
|
function createPageMetadata(head) {
|
|
53
64
|
return {
|
|
54
65
|
title: { absolute: head.title },
|
|
@@ -90,4 +101,4 @@ function createPageMetadata(head) {
|
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
//#endregion
|
|
93
|
-
export { createPageMetadata, createRootMetadata, createRootViewport };
|
|
104
|
+
export { createHomeMetadata, createPageMetadata, createRootMetadata, createRootViewport };
|
package/dist/nextjs/server.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { createSitemapRedirectRoute } from "../seo/sitemap.js";
|
|
|
4
4
|
import { NextRevalidateOptions, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, nextRevalidation } from "../integrations/nextjs/revalidate.js";
|
|
5
5
|
import { KizloServerOptions, createKizlo } from "../integrations/nextjs/kizlo.server.js";
|
|
6
6
|
import { MANIFEST_CACHE_TAG, createManifestRoute } from "../integrations/nextjs/manifest.js";
|
|
7
|
-
import { createPageMetadata, createRootMetadata, createRootViewport } from "../integrations/nextjs/metadata.js";
|
|
7
|
+
import { createHomeMetadata, createPageMetadata, createRootMetadata, createRootViewport } from "../integrations/nextjs/metadata.js";
|
|
8
8
|
import { ROBOTS_CACHE_TAG, createRobotsRoute } from "../integrations/nextjs/robots.js";
|
|
9
9
|
import { SITEMAP_CACHE_TAG, SITEMAP_ROUTE, createSitemapRoute } from "../integrations/nextjs/sitemap.js";
|
|
10
10
|
import { createCachedTextRoute, createNextCookiesInterface, getServerBaseUrl } from "../integrations/nextjs/utils.js";
|
|
11
|
-
export { KizloServerOptions, MANIFEST_CACHE_TAG, NextRevalidateOptions, ROBOTS_CACHE_TAG, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createKizlo, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, renderJsonLd };
|
|
11
|
+
export { KizloServerOptions, MANIFEST_CACHE_TAG, NextRevalidateOptions, ROBOTS_CACHE_TAG, RevalidatePathFn, RevalidateTagFn, RevalidateTarget, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata, createKizlo, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, renderJsonLd };
|
package/dist/nextjs/server.js
CHANGED
|
@@ -7,6 +7,6 @@ import { SITEMAP_CACHE_TAG, SITEMAP_ROUTE, createSitemapRoute } from "../integra
|
|
|
7
7
|
import { nextRevalidation } from "../integrations/nextjs/revalidate.js";
|
|
8
8
|
import { createKizlo } from "../integrations/nextjs/kizlo.server.js";
|
|
9
9
|
import { MANIFEST_CACHE_TAG, createManifestRoute } from "../integrations/nextjs/manifest.js";
|
|
10
|
-
import { createPageMetadata, createRootMetadata, createRootViewport } from "../integrations/nextjs/metadata.js";
|
|
10
|
+
import { createHomeMetadata, createPageMetadata, createRootMetadata, createRootViewport } from "../integrations/nextjs/metadata.js";
|
|
11
11
|
|
|
12
|
-
export { MANIFEST_CACHE_TAG, ROBOTS_CACHE_TAG, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createKizlo, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, renderJsonLd };
|
|
12
|
+
export { MANIFEST_CACHE_TAG, ROBOTS_CACHE_TAG, SITEMAP_CACHE_TAG, SITEMAP_ROUTE, WEB_MANIFEST_ROUTE, createCachedTextRoute, createHomeMetadata, createKizlo, createManifestRoute, createNextCookiesInterface, createPageMetadata, createRobotsRoute, createRootMetadata, createRootViewport, createSitemapRedirectRoute, createSitemapRoute, getServerBaseUrl, nextRevalidation, renderJsonLd };
|
package/dist/package.js
CHANGED
package/dist/router.d.ts
CHANGED
|
@@ -179,7 +179,7 @@ declare const ROUTER_MAP: {
|
|
|
179
179
|
include?: string | number | (string | number)[] | undefined;
|
|
180
180
|
offset?: string | number | undefined;
|
|
181
181
|
order?: "asc" | "desc" | undefined;
|
|
182
|
-
orderby?: "
|
|
182
|
+
orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | undefined;
|
|
183
183
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
184
184
|
slug?: string | string[] | undefined;
|
|
185
185
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -507,7 +507,7 @@ declare const ROUTER_MAP: {
|
|
|
507
507
|
include?: string | number | (string | number)[] | undefined;
|
|
508
508
|
offset?: string | number | undefined;
|
|
509
509
|
order?: "asc" | "desc" | undefined;
|
|
510
|
-
orderby?: "
|
|
510
|
+
orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
511
511
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
512
512
|
slug?: string | string[] | undefined;
|
|
513
513
|
parent?: string | number | (string | number)[] | undefined;
|
|
@@ -1186,7 +1186,7 @@ declare const ROUTER_MAP: {
|
|
|
1186
1186
|
include?: string | number | (string | number)[] | undefined;
|
|
1187
1187
|
offset?: string | number | undefined;
|
|
1188
1188
|
order?: "asc" | "desc" | undefined;
|
|
1189
|
-
orderby?: "
|
|
1189
|
+
orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
1190
1190
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
1191
1191
|
slug?: string | string[] | undefined;
|
|
1192
1192
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -1265,7 +1265,7 @@ declare const ROUTER_MAP: {
|
|
|
1265
1265
|
include?: string | number | (string | number)[] | undefined;
|
|
1266
1266
|
offset?: string | number | undefined;
|
|
1267
1267
|
order?: "asc" | "desc" | undefined;
|
|
1268
|
-
orderby?: "
|
|
1268
|
+
orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
|
|
1269
1269
|
searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
|
|
1270
1270
|
slug?: string | string[] | undefined;
|
|
1271
1271
|
taxRelation?: "AND" | "OR" | undefined;
|
|
@@ -1414,7 +1414,7 @@ declare const ROUTER_MAP: {
|
|
|
1414
1414
|
include?: string | number | (string | number)[] | undefined;
|
|
1415
1415
|
offset?: string | number | undefined;
|
|
1416
1416
|
order?: "asc" | "desc" | undefined;
|
|
1417
|
-
orderby?: "
|
|
1417
|
+
orderby?: "id" | "date" | "parent" | "post" | "include" | undefined;
|
|
1418
1418
|
parent?: string | number | (string | number)[] | undefined;
|
|
1419
1419
|
parentExclude?: string | number | (string | number)[] | undefined;
|
|
1420
1420
|
post?: string | number | (string | number)[] | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kizlo",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A headless WordPress framework for TypeScript.",
|
|
6
6
|
"keywords": [
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"chokidar": "^5.0.0",
|
|
98
98
|
"citty": "^0.1.6",
|
|
99
99
|
"consola": "^3.2.3",
|
|
100
|
-
"cookie": "^
|
|
100
|
+
"cookie": "^2.0.1",
|
|
101
101
|
"get-port": "^7.2.0",
|
|
102
102
|
"giget": "^3.0.0",
|
|
103
103
|
"jiti": "^2.7.0",
|