mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 20:14:39 +00:00
replace 4xx.html and 5xx.html with _error.html
This commit is contained in:
@@ -52,8 +52,8 @@ function generate_client(routes: Route[], path_to_routes: string, dev_port?: num
|
||||
|
||||
const file = posixify(`${path_to_routes}/${page.file}`);
|
||||
|
||||
if (route.id === '_4xx' || route.id === '_5xx') {
|
||||
return `{ error: '${route.id.slice(1)}', load: () => import(/* webpackChunkName: "${route.id}" */ '${file}') }`;
|
||||
if (route.id === '_error') {
|
||||
return `{ error: true, load: () => import(/* webpackChunkName: "${route.id}" */ '${file}') }`;
|
||||
}
|
||||
|
||||
const params = route.params.length === 0
|
||||
@@ -107,8 +107,8 @@ function generate_server(routes: Route[], path_to_routes: string) {
|
||||
`{ type: '${type}', module: ${route.id}${index} }`)
|
||||
.join(', ');
|
||||
|
||||
if (route.id === '_4xx' || route.id === '_5xx') {
|
||||
return `{ error: '${route.id.slice(1)}', handlers: [${handlers}] }`;
|
||||
if (route.id === '_error') {
|
||||
return `{ error: true, handlers: [${handlers}] }`;
|
||||
}
|
||||
|
||||
const params = route.params.length === 0
|
||||
|
||||
@@ -5,10 +5,8 @@ import { Route } from '../interfaces';
|
||||
|
||||
export default function create_routes({ files } = { files: glob.sync('**/*.*', { cwd: locations.routes(), dot: true, nodir: true }) }) {
|
||||
const routes: Route[] = files
|
||||
.filter((file: string) => !/(^|\/|\\)_/.test(file))
|
||||
.filter((file: string) => !/(^|\/|\\)(_(?!error\.html)|\.(?!well-known))/.test(file))
|
||||
.map((file: string) => {
|
||||
if (/(^|\/|\\)(_|\.(?!well-known))/.test(file)) return;
|
||||
|
||||
if (/]\[/.test(file)) {
|
||||
throw new Error(`Invalid route ${file} — parameters must be separated`);
|
||||
}
|
||||
@@ -30,8 +28,8 @@ export default function create_routes({ files } = { files: glob.sync('**/*.*', {
|
||||
return !found;
|
||||
})
|
||||
.sort((a, b) => {
|
||||
if (a.parts[0] === '4xx' || a.parts[0] === '5xx') return -1;
|
||||
if (b.parts[0] === '4xx' || b.parts[0] === '5xx') return 1;
|
||||
if (a.parts[0] === '_error') return -1;
|
||||
if (b.parts[0] === '_error') return 1;
|
||||
|
||||
const max = Math.max(a.parts.length, b.parts.length);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user