Skip to content

Commit f2e754c

Browse files
committed
feat: 新增对filename的支持 close #11
1 parent 86ce30f commit f2e754c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/HomepageDataCreator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ function getPageSpecialConfig(name, pageOptions, projectPages) {
1919
if (_.isString(projectPages[name].title)) {
2020
data.title = projectPages[name].title;
2121
}
22+
if (_.isString(projectPages[name].filename)) {
23+
data.path = `/${projectPages[name].filename}`;
24+
}
2225
return data;
2326
}
2427

tests/homepage-data.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,30 @@ describe('projectOptions.pages配置为对象时', () => {
167167
});
168168
});
169169
});
170+
171+
describe('projectOptions.pages指定了filename时', () => {
172+
const packageJSON = {
173+
name: 'app'
174+
};
175+
const projectOptions = {
176+
pages: {
177+
page1: {
178+
entry: './src/page1.js',
179+
title: 'page1 title',
180+
filename: 'changedPage1Name'
181+
},
182+
page2: {
183+
entry: './src/page2.js',
184+
title: 'page2 title'
185+
}
186+
}
187+
};
188+
pluginOptions = OptionsDefaulter(projectOptions, packageJSON, null);
189+
const data = Encryptor.decoding(DataCreator(projectOptions, pluginOptions));
190+
it('page1的path为/changedPage1Name', () => {
191+
expect(data.pages[0].path === '/changedPage1Name').toBe(true);
192+
});
193+
it('page2的path为/page2.html', () => {
194+
expect(data.pages[1].path === '/page2.html').toBe(true);
195+
});
196+
});

0 commit comments

Comments
 (0)