xplorajs-react 0.0.1 → 0.1.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/README.md +22 -20
- package/dist/render.js +0 -2
- package/package.json +28 -31
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# XploraJS React 🔄
|
|
2
2
|
|
|
3
|
-
Package React untuk XploraJS yang menyediakan integrasi React dan static site
|
|
3
|
+
Package React untuk XploraJS yang menyediakan integrasi React dan static site
|
|
4
|
+
generation.
|
|
4
5
|
|
|
5
6
|
## 🚀 Fitur
|
|
6
7
|
|
|
@@ -22,31 +23,31 @@ bun add xplora-react
|
|
|
22
23
|
### Basic Setup
|
|
23
24
|
|
|
24
25
|
```typescript
|
|
25
|
-
import { generateStaticPage } from
|
|
26
|
+
import { generateStaticPage } from "xplora-react";
|
|
26
27
|
|
|
27
28
|
// Generate static page
|
|
28
29
|
await generateStaticPage({
|
|
29
30
|
component: <App />,
|
|
30
|
-
outputPath:
|
|
31
|
-
})
|
|
31
|
+
outputPath: "./dist/index.html",
|
|
32
|
+
});
|
|
32
33
|
```
|
|
33
34
|
|
|
34
35
|
### Static Data Generation
|
|
35
36
|
|
|
36
37
|
```typescript
|
|
37
|
-
import { getStaticProps } from
|
|
38
|
+
import { getStaticProps } from "xplora-react";
|
|
38
39
|
|
|
39
40
|
export async function getStaticProps() {
|
|
40
41
|
// Fetch data at build time
|
|
41
|
-
const data = await fetchData()
|
|
42
|
-
|
|
42
|
+
const data = await fetchData();
|
|
43
|
+
|
|
43
44
|
return {
|
|
44
45
|
props: {
|
|
45
|
-
data
|
|
46
|
+
data,
|
|
46
47
|
},
|
|
47
48
|
// Revalidate every hour
|
|
48
|
-
revalidate: 3600
|
|
49
|
-
}
|
|
49
|
+
revalidate: 3600,
|
|
50
|
+
};
|
|
50
51
|
}
|
|
51
52
|
```
|
|
52
53
|
|
|
@@ -59,7 +60,7 @@ function generateStaticPage(options: {
|
|
|
59
60
|
component: React.ReactElement;
|
|
60
61
|
outputPath: string;
|
|
61
62
|
props?: Record<string, any>;
|
|
62
|
-
}): Promise<void
|
|
63
|
+
}): Promise<void>;
|
|
63
64
|
```
|
|
64
65
|
|
|
65
66
|
### `getStaticProps`
|
|
@@ -68,7 +69,7 @@ function generateStaticPage(options: {
|
|
|
68
69
|
function getStaticProps(): Promise<{
|
|
69
70
|
props: Record<string, any>;
|
|
70
71
|
revalidate?: number;
|
|
71
|
-
}
|
|
72
|
+
}>;
|
|
72
73
|
```
|
|
73
74
|
|
|
74
75
|
## 🔧 Konfigurasi
|
|
@@ -76,24 +77,25 @@ function getStaticProps(): Promise<{
|
|
|
76
77
|
Konfigurasi React dapat dilakukan melalui `xplora.config.ts`:
|
|
77
78
|
|
|
78
79
|
```typescript
|
|
79
|
-
import { defineConfig } from
|
|
80
|
+
import { defineConfig } from "xplora";
|
|
80
81
|
|
|
81
82
|
export default defineConfig({
|
|
82
83
|
react: {
|
|
83
84
|
// Static generation options
|
|
84
85
|
static: {
|
|
85
|
-
outputDir:
|
|
86
|
+
outputDir: "./dist",
|
|
86
87
|
revalidate: 3600, // ISR interval in seconds
|
|
87
|
-
fallback: false
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
})
|
|
88
|
+
fallback: false,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
91
92
|
```
|
|
92
93
|
|
|
93
94
|
## 🤝 Kontribusi
|
|
94
95
|
|
|
95
|
-
Kami menyambut kontribusi! Silakan baca [CONTRIBUTING.md](../../CONTRIBUTING.md)
|
|
96
|
+
Kami menyambut kontribusi! Silakan baca [CONTRIBUTING.md](../../CONTRIBUTING.md)
|
|
97
|
+
untuk panduan kontribusi.
|
|
96
98
|
|
|
97
99
|
## 📝 Lisensi
|
|
98
100
|
|
|
99
|
-
MIT License - lihat [LICENSE](../../LICENSE) untuk detail lebih lanjut.
|
|
101
|
+
MIT License - lihat [LICENSE](../../LICENSE) untuk detail lebih lanjut.
|
package/dist/render.js
CHANGED
|
@@ -155,7 +155,6 @@ import { renderToReadableStream, renderToString } from "react-dom/server";
|
|
|
155
155
|
];
|
|
156
156
|
case 1:
|
|
157
157
|
html = _state.sent();
|
|
158
|
-
// Buat directory jika belum ada
|
|
159
158
|
return [
|
|
160
159
|
4,
|
|
161
160
|
fs.mkdir(path.dirname(outputPath), {
|
|
@@ -164,7 +163,6 @@ import { renderToReadableStream, renderToString } from "react-dom/server";
|
|
|
164
163
|
];
|
|
165
164
|
case 2:
|
|
166
165
|
_state.sent();
|
|
167
|
-
// Tulis file HTML
|
|
168
166
|
return [
|
|
169
167
|
4,
|
|
170
168
|
fs.writeFile(outputPath, html)
|
package/package.json
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"publishConfig": {
|
|
31
|
-
"access": "public"
|
|
32
|
-
}
|
|
2
|
+
"name": "xplorajs-react",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "swc src -d dist",
|
|
14
|
+
"dev": "swc src -d dist --watch",
|
|
15
|
+
"prepublishOnly": "bun run build"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@swc/cli": "^0.1.65",
|
|
19
|
+
"@swc/core": "^1.11.24"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@types/react": "^18.3.21",
|
|
23
|
+
"@types/react-dom": "^18.3.7",
|
|
24
|
+
"react": "^19.1.0",
|
|
25
|
+
"react-dom": "^19.1.0"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
}
|
|
33
30
|
}
|