diff --git a/gatsby-node.js b/gatsby-node.js index a62e9b8..f53c260 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -170,6 +170,10 @@ exports.onCreatePage = async ({ page, actions }) => { const oldPage = { ...page } page.matchPath = `/resources/*` deletePage(oldPage) + } else if (page.path.match(/^\/archives\/404/)) { + const oldPage = { ...page } + page.matchPath = `/archives/*` + deletePage(oldPage) } else { page.context.layout = resolveLayout(page.path) } diff --git a/src/pages/archives/404.tsx b/src/pages/archives/404.tsx new file mode 100644 index 0000000..3d31219 --- /dev/null +++ b/src/pages/archives/404.tsx @@ -0,0 +1,32 @@ +import { Location } from "@reach/router" +import { graphql } from "gatsby" +import React, { Fragment } from "react" + +import { FileConnection } from "../../../generated/graphql" +import { ComponentQuery } from "../../../typings" +import { SEO } from "../../components/SEO" + +import { getPossibleCorrections } from "../../components/404LinkCorrection" + +export default ({ data }: ComponentQuery<{ allFile: FileConnection }>) => ( + + +

RESOURCE NOT FOUND

+

You just hit a route that doesn't exist... the sadness.

+ + {({ location }) => getPossibleCorrections("archives/", location, data, 8)} + +
+) + +export const query = graphql` + query { + allFile(filter: { sourceInstanceName: { eq: "what-is-archive" } }) { + edges { + node { + relativePath + } + } + } + } +` diff --git a/src/pages/archives.tsx b/src/pages/archives/index.tsx similarity index 85% rename from src/pages/archives.tsx rename to src/pages/archives/index.tsx index f7c89b4..a419c56 100644 --- a/src/pages/archives.tsx +++ b/src/pages/archives/index.tsx @@ -1,7 +1,7 @@ import React, { Fragment } from "react" -import { Link } from "../components/Link" -import { SEO } from "../components/SEO" +import { Link } from "../../components/Link" +import { SEO } from "../../components/SEO" function ArchivesPage() { return (