@valbuild/next 0.53.0 → 0.54.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
CHANGED
|
@@ -146,89 +146,21 @@ Check out this README or the [examples](./examples) directory for examples.
|
|
|
146
146
|
## Installation
|
|
147
147
|
|
|
148
148
|
- Make sure you have TypeScript 5+, Next 13.4+ (other meta frameworks will come), React 18.20.+ (other frontend frameworks will come)
|
|
149
|
-
- Install the
|
|
149
|
+
- Install the packages (@valbuild/eslint-plugin is recommended but not required):
|
|
150
150
|
|
|
151
151
|
```sh
|
|
152
|
-
npm install @valbuild/next@latest
|
|
152
|
+
npm install @valbuild/next@latest @valbuild/eslint-plugin@latest
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
-
|
|
155
|
+
- Run the init script:
|
|
156
156
|
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
import { initVal } from "@valbuild/next";
|
|
161
|
-
|
|
162
|
-
const { s, val, config } = initVal();
|
|
163
|
-
|
|
164
|
-
export { s, val, config };
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
- Create the endpoints file:
|
|
168
|
-
|
|
169
|
-
```ts
|
|
170
|
-
// ./src/pages/api/val/[...val].ts
|
|
171
|
-
|
|
172
|
-
import { createRequestListener } from "@valbuild/server";
|
|
173
|
-
import { NextApiHandler } from "next";
|
|
174
|
-
|
|
175
|
-
const handler: NextApiHandler = createRequestListener("/api/val", {
|
|
176
|
-
valConfigPath: "./val.config",
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
export default handler;
|
|
180
|
-
|
|
181
|
-
export const config = {
|
|
182
|
-
api: {
|
|
183
|
-
responseLimit: false,
|
|
184
|
-
bodyParser: false,
|
|
185
|
-
externalResolver: true,
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
- Use the Val provider in the root layout file:
|
|
191
|
-
|
|
192
|
-
```tsx
|
|
193
|
-
// ./app/layout.tsx
|
|
194
|
-
|
|
195
|
-
import { ValProvider } from "@valbuild/next";
|
|
196
|
-
|
|
197
|
-
export default function RootLayout({
|
|
198
|
-
children,
|
|
199
|
-
}: {
|
|
200
|
-
children: React.ReactNode;
|
|
201
|
-
}) {
|
|
202
|
-
return (
|
|
203
|
-
<html lang="en">
|
|
204
|
-
<body className={inter.className}>
|
|
205
|
-
<ValProvider> {children}</ValProvider>
|
|
206
|
-
</body>
|
|
207
|
-
</html>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### [OPTIONAL]: Setup eslint
|
|
213
|
-
|
|
214
|
-
Install the eslint package:
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
npm install @valbuild/eslint-plugin@latest
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Add the following to your `.eslintrc.json`:
|
|
221
|
-
|
|
222
|
-
```json
|
|
223
|
-
"plugins": ["@valbuild"],
|
|
224
|
-
"rules": {
|
|
225
|
-
"@valbuild/no-illegal-module-ids": "error"
|
|
226
|
-
}
|
|
157
|
+
```sh
|
|
158
|
+
npx @valbuild/init
|
|
227
159
|
```
|
|
228
160
|
|
|
229
161
|
### Add editor support
|
|
230
162
|
|
|
231
|
-
To make it possible to do non-local edits, head over to [val.build](https://val.build) and import your repository.
|
|
163
|
+
To make it possible to do non-local edits, head over to [val.build](https://val.build), sign up and import your repository.
|
|
232
164
|
|
|
233
165
|
**NOTE**: your content is yours. No subscription (or similar) is required to host content from your repository.
|
|
234
166
|
|
|
@@ -244,11 +176,11 @@ Content in Val is always defined in `.val.ts` files.
|
|
|
244
176
|
|
|
245
177
|
**NOTE**: Val also works with `.js` files.
|
|
246
178
|
|
|
247
|
-
They must export a default `
|
|
179
|
+
They must export a default content definition (`c.define`) where the first argument equals the path of the file relative to the `val.config.ts` file.
|
|
248
180
|
|
|
249
181
|
**NOTE**: `val.ts` files are _evaluated_ by Val, therefore they have a specific set of requirements:
|
|
250
182
|
|
|
251
|
-
- They must have a default export that is `
|
|
183
|
+
- They must have a default export that is `c.define`, they must have a `export const schema` with the Schema; and
|
|
252
184
|
- they CANNOT import anything other than `val.config` and `@valbuild/core`
|
|
253
185
|
|
|
254
186
|
### Example of a `.val.ts` file
|
|
@@ -256,7 +188,7 @@ They must export a default `val.content` where the first argument equals the pat
|
|
|
256
188
|
```ts
|
|
257
189
|
// ./src/app/content.val.ts
|
|
258
190
|
|
|
259
|
-
import { s,
|
|
191
|
+
import { s, c } from "../../../val.config";
|
|
260
192
|
|
|
261
193
|
export const schema = s.object({
|
|
262
194
|
title: s.string().optional(), // <- NOTE: optional()
|
|
@@ -270,7 +202,7 @@ export const schema = s.object({
|
|
|
270
202
|
),
|
|
271
203
|
});
|
|
272
204
|
|
|
273
|
-
export default
|
|
205
|
+
export default c.define(
|
|
274
206
|
"/src/app/content", // <- NOTE: this must be the same path as the file
|
|
275
207
|
schema,
|
|
276
208
|
{
|
|
@@ -278,7 +210,7 @@ export default val.content(
|
|
|
278
210
|
sections: [
|
|
279
211
|
{
|
|
280
212
|
title: "Section 1",
|
|
281
|
-
text:
|
|
213
|
+
text: c.richtext`
|
|
282
214
|
RichText is **awesome**`,
|
|
283
215
|
},
|
|
284
216
|
],
|
|
@@ -413,7 +345,7 @@ s.richtext({
|
|
|
413
345
|
To initialize some text content using a RichText schema, you can use follow the example below:
|
|
414
346
|
|
|
415
347
|
```ts
|
|
416
|
-
import { s,
|
|
348
|
+
import { s, c } from "./val.config";
|
|
417
349
|
|
|
418
350
|
export const schema = s.richtext({
|
|
419
351
|
// styling:
|
|
@@ -428,10 +360,10 @@ export const schema = s.richtext({
|
|
|
428
360
|
//ol: true, // enables ordered lists
|
|
429
361
|
});
|
|
430
362
|
|
|
431
|
-
export default
|
|
363
|
+
export default c.define(
|
|
432
364
|
"/src/app/content",
|
|
433
365
|
schema,
|
|
434
|
-
|
|
366
|
+
c.richtext`
|
|
435
367
|
NOTE: this is markdown.
|
|
436
368
|
|
|
437
369
|
**Bold** text.
|
|
@@ -479,11 +411,11 @@ s.image();
|
|
|
479
411
|
Local images must be stored under the `.public` folder.
|
|
480
412
|
|
|
481
413
|
```ts
|
|
482
|
-
import { s,
|
|
414
|
+
import { s, c } from "../val.config";
|
|
483
415
|
|
|
484
416
|
export const schema = s.image();
|
|
485
417
|
|
|
486
|
-
export default
|
|
418
|
+
export default c.define("/image", schema, c.file("/public/myfile.jpg"));
|
|
487
419
|
```
|
|
488
420
|
|
|
489
421
|
**NOTE**: This will not validate, since images requires `width`, `height` and a `sha256` checksum. You can fix this validation in the UI by opening the image and clicking the Fix button.
|
|
@@ -18,7 +18,4 @@ export { ValProvider } from "./ValProvider.js";
|
|
|
18
18
|
export { ValImage, type ValImageProps } from "./ValImage.js";
|
|
19
19
|
export { ValApp } from "./ValApp.js";
|
|
20
20
|
export { initVal } from "./initVal.js";
|
|
21
|
-
|
|
22
|
-
import { Schema, SelectorSource } from "@valbuild/core";
|
|
23
|
-
import { SelectorOfSchema } from "@valbuild/core";
|
|
24
|
-
export type InferSchemaType<S extends Schema<SelectorSource>> = UseValType<SelectorOfSchema<S>>;
|
|
21
|
+
export type * as t from "./types.js";
|
|
@@ -168,6 +168,7 @@ function ValImage(props) {
|
|
|
168
168
|
var initVal = function initVal(config) {
|
|
169
169
|
var _createValSystem = core.initVal(),
|
|
170
170
|
s = _createValSystem.s,
|
|
171
|
+
c = _createValSystem.c,
|
|
171
172
|
val = _createValSystem.val,
|
|
172
173
|
systemConfig = _createValSystem.config;
|
|
173
174
|
var currentConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, systemConfig), config), {}, {
|
|
@@ -175,6 +176,7 @@ var initVal = function initVal(config) {
|
|
|
175
176
|
});
|
|
176
177
|
return {
|
|
177
178
|
s: s,
|
|
179
|
+
c: c,
|
|
178
180
|
val: _objectSpread2(_objectSpread2({}, val), {}, {
|
|
179
181
|
decodeValPathOfString: decodeValPathOfString,
|
|
180
182
|
raw: raw
|
|
@@ -168,6 +168,7 @@ function ValImage(props) {
|
|
|
168
168
|
var initVal = function initVal(config) {
|
|
169
169
|
var _createValSystem = core.initVal(),
|
|
170
170
|
s = _createValSystem.s,
|
|
171
|
+
c = _createValSystem.c,
|
|
171
172
|
val = _createValSystem.val,
|
|
172
173
|
systemConfig = _createValSystem.config;
|
|
173
174
|
var currentConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, systemConfig), config), {}, {
|
|
@@ -175,6 +176,7 @@ var initVal = function initVal(config) {
|
|
|
175
176
|
});
|
|
176
177
|
return {
|
|
177
178
|
s: s,
|
|
179
|
+
c: c,
|
|
178
180
|
val: _objectSpread2(_objectSpread2({}, val), {}, {
|
|
179
181
|
decodeValPathOfString: decodeValPathOfString,
|
|
180
182
|
raw: raw
|
|
@@ -144,6 +144,7 @@ function ValImage(props) {
|
|
|
144
144
|
var initVal = function initVal(config) {
|
|
145
145
|
var _createValSystem = initVal$1(),
|
|
146
146
|
s = _createValSystem.s,
|
|
147
|
+
c = _createValSystem.c,
|
|
147
148
|
val = _createValSystem.val,
|
|
148
149
|
systemConfig = _createValSystem.config;
|
|
149
150
|
var currentConfig = _objectSpread2(_objectSpread2(_objectSpread2({}, systemConfig), config), {}, {
|
|
@@ -151,6 +152,7 @@ var initVal = function initVal(config) {
|
|
|
151
152
|
});
|
|
152
153
|
return {
|
|
153
154
|
s: s,
|
|
155
|
+
c: c,
|
|
154
156
|
val: _objectSpread2(_objectSpread2({}, val), {}, {
|
|
155
157
|
decodeValPathOfString: decodeValPathOfString,
|
|
156
158
|
raw: raw
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"next",
|
|
9
9
|
"react"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.54.0",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"typecheck": "tsc --noEmit",
|
|
14
14
|
"test": "jest"
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"exports": true
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@valbuild/core": "~0.
|
|
49
|
-
"@valbuild/react": "~0.
|
|
50
|
-
"@valbuild/server": "~0.
|
|
51
|
-
"@valbuild/ui": "~0.
|
|
48
|
+
"@valbuild/core": "~0.54.0",
|
|
49
|
+
"@valbuild/react": "~0.54.0",
|
|
50
|
+
"@valbuild/server": "~0.54.0",
|
|
51
|
+
"@valbuild/ui": "~0.54.0",
|
|
52
52
|
"client-only": "^0.0.1",
|
|
53
53
|
"server-only": "^0.0.1"
|
|
54
54
|
},
|