react-layout-sdk 1.1.1 → 1.1.3
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/bin/init.js +21 -2
- package/package.json +2 -2
package/bin/init.js
CHANGED
|
@@ -88,6 +88,15 @@ if (!fs.existsSync(footerPath)) {
|
|
|
88
88
|
// 4. Generate Page routing
|
|
89
89
|
if (hasAppRouter) {
|
|
90
90
|
console.log('🔍 Detected Next.js App Router');
|
|
91
|
+
|
|
92
|
+
// Prevent Next.js route conflict by renaming existing app/page.tsx
|
|
93
|
+
const existingAppPage = path.join(basePath, 'app', 'page.tsx');
|
|
94
|
+
if (fs.existsSync(existingAppPage)) {
|
|
95
|
+
const backupPath = path.join(basePath, 'app', 'page.tsx.bak');
|
|
96
|
+
fs.renameSync(existingAppPage, backupPath);
|
|
97
|
+
console.log('⚠️ Renamed existing app/page.tsx to app/page.tsx.bak to avoid catch-all route conflict.');
|
|
98
|
+
}
|
|
99
|
+
|
|
91
100
|
const pageDir = path.join(basePath, 'app', '[[...slug]]');
|
|
92
101
|
ensureDirSync(pageDir);
|
|
93
102
|
|
|
@@ -96,8 +105,9 @@ if (hasAppRouter) {
|
|
|
96
105
|
import { fetchVeloxLayout, Placeholder } from 'react-layout-sdk';
|
|
97
106
|
import { componentMap } from '@/components/factory';
|
|
98
107
|
|
|
99
|
-
export default async function Page({ params }: { params: { slug?: string[] } }) {
|
|
100
|
-
const
|
|
108
|
+
export default async function Page({ params }: { params: Promise<{ slug?: string[] }> }) {
|
|
109
|
+
const resolvedParams = await params;
|
|
110
|
+
const slugArray = resolvedParams?.slug || [];
|
|
101
111
|
const path = slugArray.join('/') || '/';
|
|
102
112
|
const STRAPI_URL = process.env.NEXT_PUBLIC_STRAPI_URL || 'http://localhost:1337';
|
|
103
113
|
|
|
@@ -127,6 +137,15 @@ export default async function Page({ params }: { params: { slug?: string[] } })
|
|
|
127
137
|
}
|
|
128
138
|
} else if (hasPagesRouter) {
|
|
129
139
|
console.log('🔍 Detected Next.js Pages Router');
|
|
140
|
+
|
|
141
|
+
// Prevent Next.js route conflict by renaming existing pages/index.tsx
|
|
142
|
+
const existingPagesIndex = path.join(basePath, 'pages', 'index.tsx');
|
|
143
|
+
if (fs.existsSync(existingPagesIndex)) {
|
|
144
|
+
const backupPath = path.join(basePath, 'pages', 'index.tsx.bak');
|
|
145
|
+
fs.renameSync(existingPagesIndex, backupPath);
|
|
146
|
+
console.log('⚠️ Renamed existing pages/index.tsx to pages/index.tsx.bak to avoid catch-all route conflict.');
|
|
147
|
+
}
|
|
148
|
+
|
|
130
149
|
const pagePath = path.join(basePath, 'pages', '[[...slug]].tsx');
|
|
131
150
|
const pagesContent = `import React from 'react';
|
|
132
151
|
import { fetchVeloxLayout, Placeholder } from 'react-layout-sdk';
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-layout-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "React components for Velox SDK (Sitecore-like routing)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"react-layout-sdk": "
|
|
9
|
+
"react-layout-sdk": "bin/init.js"
|
|
10
10
|
},
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"react": ">=18.0.0",
|