Skip to content

Commit c87b72d

Browse files
committed
feat: auto connect for layouts
1 parent 2baab8a commit c87b72d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pri",
3-
"version": "0.0.46",
3+
"version": "0.0.47",
44
"types": "src/index.ts",
55
"main": "built/index.js",
66
"scripts": {
@@ -79,4 +79,4 @@
7979
"walk": "^2.3.9",
8080
"yargs": "^11.0.0"
8181
}
82-
}
82+
}

src/utils/create-entry.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,19 @@ export async function createEntry(info: IProjectInfo, projectRootPath: string, e
184184
// Set layout
185185
if (info.layout) {
186186
const layoutPath = path.parse(info.layout.filePath)
187+
let layoutImportCode = ""
188+
189+
if (info.stores.length === 0) {
190+
layoutImportCode = `import LayoutComponent from "${path.join(layoutPath.dir, layoutPath.name)}"`
191+
} else {
192+
layoutImportCode = `
193+
import LayoutComponentOrigin from "${path.join(layoutPath.dir, layoutPath.name)}"
194+
const LayoutComponent = Connect()(LayoutComponentOrigin)
195+
`
196+
}
197+
187198
entryText.layoutImporter = `
188-
import LayoutComponent from "${path.join(layoutPath.dir, layoutPath.name)}"
199+
${layoutImportCode}
189200
190201
const LayoutRoute = ({ component: Component, ...rest }) => {
191202
return (

0 commit comments

Comments
 (0)