refactor(nuxt)!: remove support for 404.vue shorthand (#8809)

This commit is contained in:
Daniel Roe 2022-11-09 10:05:22 +01:00 committed by GitHub
parent 0cf0f59bc5
commit 10c2272f4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 38 deletions

View File

@ -177,8 +177,6 @@ export default defineNuxtPlugin(async (nuxtApp) => {
fatal: false, fatal: false,
statusMessage: `Page not found: ${to.fullPath}` statusMessage: `Page not found: ${to.fullPath}`
})]) })])
} else if (process.server && to.matched[0].name === '404' && nuxtApp.ssrContext) {
nuxtApp.ssrContext.event.res.statusCode = 404
} else if (process.server) { } else if (process.server) {
const currentURL = to.fullPath || '/' const currentURL = to.fullPath || '/'
if (!isEqual(currentURL, initialURL)) { if (!isEqual(currentURL, initialURL)) {

View File

@ -68,7 +68,6 @@ export function generateRoutesFromFiles (files: string[], pagesDir: string): Nux
const tokens = parseSegment(segment) const tokens = parseSegment(segment)
const segmentName = tokens.map(({ value }) => value).join('') const segmentName = tokens.map(({ value }) => value).join('')
const isSingleSegment = segments.length === 1
// ex: parent/[slug].vue -> parent-slug // ex: parent/[slug].vue -> parent-slug
route.name += (route.name && '-') + segmentName route.name += (route.name && '-') + segmentName
@ -79,8 +78,6 @@ export function generateRoutesFromFiles (files: string[], pagesDir: string): Nux
if (child && child.children) { if (child && child.children) {
parent = child.children parent = child.children
route.path = '' route.path = ''
} else if (segmentName === '404' && isSingleSegment) {
route.path += '/:catchAll(.*)*'
} else if (segmentName === 'index' && !route.path) { } else if (segmentName === 'index' && !route.path) {
route.path += '/' route.path += '/'
} else if (segmentName !== 'index') { } else if (segmentName !== 'index') {

View File

@ -5,18 +5,6 @@ import { generateRouteKey } from '../src/pages/runtime/utils'
describe('pages:generateRoutesFromFiles', () => { describe('pages:generateRoutesFromFiles', () => {
const pagesDir = 'pages' const pagesDir = 'pages'
const tests = [ const tests = [
{
description: 'should generate correct route for 404',
files: [`${pagesDir}/404.vue`],
output: [
{
name: '404',
path: '/:catchAll(.*)*',
file: `${pagesDir}/404.vue`,
children: []
}
]
},
{ {
description: 'should generate correct routes for index pages', description: 'should generate correct routes for index pages',
files: [ files: [