mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-22 15:15:19 +00:00
treat foo.html and foo/index.html the same when generating manifest
This commit is contained in:
@@ -142,29 +142,26 @@ export default function create_manifest_data(cwd: string): ManifestData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (item.is_page) {
|
else if (item.is_page) {
|
||||||
|
const is_index = item.basename === 'index.html';
|
||||||
|
|
||||||
const component = {
|
const component = {
|
||||||
name: get_slug(item.file),
|
name: get_slug(item.file),
|
||||||
file: item.file,
|
file: item.file,
|
||||||
has_preload: has_preload(item.file)
|
has_preload: has_preload(item.file)
|
||||||
};
|
};
|
||||||
|
|
||||||
const parts = stack.concat({
|
|
||||||
component,
|
|
||||||
params
|
|
||||||
});
|
|
||||||
|
|
||||||
components.push(component);
|
components.push(component);
|
||||||
if (item.basename === 'index.html') {
|
|
||||||
pages.push({
|
const parts = (is_index && stack[stack.length - 1] === null)
|
||||||
pattern: get_pattern(parent_segments, true),
|
? stack.slice(0, -1).concat({ component, params })
|
||||||
parts
|
: stack.concat({ component, params })
|
||||||
});
|
|
||||||
} else {
|
const page = {
|
||||||
pages.push({
|
pattern: get_pattern(is_index ? parent_segments : segments, true),
|
||||||
pattern: get_pattern(segments, true),
|
parts
|
||||||
parts
|
};
|
||||||
});
|
|
||||||
}
|
pages.push(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|||||||
1
test/apps/basics/src/routes/dirs/bar/index.html
Normal file
1
test/apps/basics/src/routes/dirs/bar/index.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<h1>bar</h1>
|
||||||
2
test/apps/basics/src/routes/dirs/foo/index.html
Normal file
2
test/apps/basics/src/routes/dirs/foo/index.html
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<h1>foo</h1>
|
||||||
|
<a href="dirs/bar">bar</a>
|
||||||
@@ -264,4 +264,15 @@ describe('basics', function() {
|
|||||||
const html = String(await page.evaluate(() => document.body.innerHTML));
|
const html = String(await page.evaluate(() => document.body.innerHTML));
|
||||||
assert.equal(html.indexOf('%sapper'), -1);
|
assert.equal(html.indexOf('%sapper'), -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('navigates between routes with empty parts', async () => {
|
||||||
|
await page.goto(`${base}/dirs/foo`);
|
||||||
|
await start();
|
||||||
|
|
||||||
|
assert.equal(await title(), 'foo');
|
||||||
|
|
||||||
|
await page.click('[href="dirs/bar"]');
|
||||||
|
await wait(50);
|
||||||
|
assert.equal(await title(), 'bar');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user