Skip to content

Commit

Permalink
Fix custom error page on catchall (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
aralroca authored May 27, 2020
1 parent d3bfb62 commit 7d05a0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion cli/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,22 @@ export default function DefaultLanguageCatchAll() {
`
}

function getErrorImport() {
const pages = fs.readdirSync(currentPagesDir)

if (pages.some((page) => page.startsWith('404.'))) {
return "import Error from '../pages/404';"
}

if (pages.some((page) => page.startsWith('_error.'))) {
return "import Error from '../pages/_error';"
}

return "import Error from 'next/error';"
}

function getCatchAllTemplate() {
return `import Error from 'next/error';
return `${getErrorImport()}
import { useRouter } from 'next/router';
export default function CatchAll() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-translate",
"version": "0.17.0-canary.1",
"version": "0.17.0-canary.2",
"description": "Next.js utility to translate pages without the need of a server (static i18n pages generator).",
"license": "MIT",
"keywords": [
Expand Down

0 comments on commit 7d05a0e

Please sign in to comment.