react-layout-sdk 1.1.10 → 1.1.11
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 +2 -2
- package/package.json +1 -1
package/bin/init.js
CHANGED
|
@@ -157,7 +157,7 @@ if (command === 'init') {
|
|
|
157
157
|
ensureDirSync(pageDir);
|
|
158
158
|
|
|
159
159
|
const appPagePath = path.join(pageDir, 'page.tsx');
|
|
160
|
-
const appPageContent = `import React from 'react';\nimport {
|
|
160
|
+
const appPageContent = `import React from 'react';\nimport { JDPage, generateJDMetadata } from 'react-layout-sdk';\nimport { componentMap } from '@/components/factory';\n\nconst STRAPI_URL = process.env.NEXT_PUBLIC_STRAPI_URL || 'http://localhost:1337';\n\nexport const generateMetadata = ({ params }: { params: Promise<{ slug?: string[] }> }) => {\n return generateJDMetadata(params, STRAPI_URL);\n}\n\nexport default function Page({ params }: { params: Promise<{ slug?: string[] }> }) {\n return <JDPage params={params} apiUrl={STRAPI_URL} componentMap={componentMap} />;\n}\n`;
|
|
161
161
|
if (!fs.existsSync(appPagePath)) {
|
|
162
162
|
fs.writeFileSync(appPagePath, appPageContent);
|
|
163
163
|
console.log('✅ Created app/[[...slug]]/page.tsx');
|
|
@@ -173,7 +173,7 @@ if (command === 'init') {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
const pagePath = path.join(basePath, 'pages', '[[...slug]].tsx');
|
|
176
|
-
const pagesContent = `import React from 'react';\nimport { fetchJDLayout, Placeholder } from 'react-layout-sdk';\nimport { componentMap } from '@/components/factory';\n\nexport default function LayoutPage({ layoutData, error }: any) {\n if (error || !layoutData?.strapi) return <h1>404 - Layout Not Found</h1>;\n\n const
|
|
176
|
+
const pagesContent = `import React from 'react';\nimport { fetchJDLayout, JDLayout, Placeholder } from 'react-layout-sdk';\nimport { componentMap } from '@/components/factory';\n\nexport default function LayoutPage({ layoutData, error }: any) {\n if (error || !layoutData?.strapi) return <h1>404 - Layout Not Found</h1>;\n\n const CustomPlaceholder = (props: any) => <Placeholder {...props} componentMap={componentMap} />;\n\n return <JDLayout layoutData={layoutData} placeholderComponent={CustomPlaceholder} />;\n}\n\nexport async function getServerSideProps(context: any) {\n const slugArray = context.params?.slug || [];\n const path = slugArray.join('/') || '/';\n const STRAPI_URL = process.env.NEXT_PUBLIC_STRAPI_URL || 'http://localhost:1337';\n\n try {\n const layoutData = await fetchJDLayout(STRAPI_URL, path, 'en');\n if (!layoutData) return { notFound: true };\n\n return { props: { layoutData } };\n } catch (error) {\n return { props: { error: true } };\n }\n}\n`;
|
|
177
177
|
if (!fs.existsSync(pagePath)) {
|
|
178
178
|
fs.writeFileSync(pagePath, pagesContent);
|
|
179
179
|
console.log('✅ Created pages/[[...slug]].tsx');
|