@c-time/frelio-data-json 1.3.14 → 1.4.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 +78 -0
- package/package.json +5 -2
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @c-time/frelio-data-json
|
|
2
|
+
|
|
3
|
+
Frelio SSG の中間データフォーマット(data-json)の型定義とバリデーション。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 概要
|
|
8
|
+
|
|
9
|
+
Frelio の静的サイト生成(SSG)は2段階で処理される:
|
|
10
|
+
|
|
11
|
+
1. **data-json 生成** (`@c-time/frelio-data-json-generator`) — コンテンツから中間 JSON を生成
|
|
12
|
+
2. **HTML 生成** (`@c-time/frelio-gentl`) — 中間 JSON + テンプレートから HTML を生成
|
|
13
|
+
|
|
14
|
+
このパッケージは、その中間データのフォーマットを定義する型定義ライブラリ。ランタイム依存なし。
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## インストール
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @c-time/frelio-data-json
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 使用例
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { isFrelioDataJson, isFrelioDataJsonArray } from '@c-time/frelio-data-json'
|
|
30
|
+
import type { FrelioDataJson } from '@c-time/frelio-data-json'
|
|
31
|
+
|
|
32
|
+
const entry: FrelioDataJson = {
|
|
33
|
+
type: 'create',
|
|
34
|
+
template: 'news/detail/index.html',
|
|
35
|
+
outputFile: 'news/2024/hello-world.html',
|
|
36
|
+
data: {
|
|
37
|
+
title: 'Hello World',
|
|
38
|
+
body: '<p>記事本文</p>',
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 型ガードでバリデーション
|
|
43
|
+
if (isFrelioDataJson(entry)) {
|
|
44
|
+
console.log(entry.outputFile)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (isFrelioDataJsonArray([entry])) {
|
|
48
|
+
console.log('有効な data-json 配列')
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## API
|
|
55
|
+
|
|
56
|
+
### 型
|
|
57
|
+
|
|
58
|
+
#### `FrelioDataJson`
|
|
59
|
+
|
|
60
|
+
| プロパティ | 型 | 説明 |
|
|
61
|
+
|-----------|-----|------|
|
|
62
|
+
| `type` | `'create' \| 'update' \| 'delete'` | 操作タイプ |
|
|
63
|
+
| `template` | `string` | テンプレートファイルのパス |
|
|
64
|
+
| `outputFile` | `string` | 出力ファイルのパス |
|
|
65
|
+
| `data` | `Record<string, unknown>` | テンプレートに渡すデータ |
|
|
66
|
+
|
|
67
|
+
### 関数
|
|
68
|
+
|
|
69
|
+
| 関数 | 説明 |
|
|
70
|
+
|------|------|
|
|
71
|
+
| `isFrelioDataJson(value)` | 値が有効な `FrelioDataJson` か判定する型ガード |
|
|
72
|
+
| `isFrelioDataJsonArray(value)` | 値が有効な `FrelioDataJson[]` か判定する型ガード |
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## ライセンス
|
|
77
|
+
|
|
78
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c-time/frelio-data-json",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Type definitions for frelio data JSON output",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "tsup",
|
|
21
21
|
"dev": "tsup --watch",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
22
24
|
"prepublishOnly": "npm run build"
|
|
23
25
|
},
|
|
24
26
|
"publishConfig": {
|
|
@@ -39,7 +41,8 @@
|
|
|
39
41
|
"license": "MIT",
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"tsup": "^8.5.0",
|
|
42
|
-
"typescript": "^5.7.0"
|
|
44
|
+
"typescript": "^5.7.0",
|
|
45
|
+
"vitest": "^4.0.18"
|
|
43
46
|
},
|
|
44
47
|
"engines": {
|
|
45
48
|
"node": ">=18"
|