From a796facdb12625c0ca55b5a3df00a52cb747ea2e Mon Sep 17 00:00:00 2001 From: Khinshan Khan Date: Sat, 25 Jan 2020 15:49:53 -0500 Subject: [PATCH] feat(404): allow for suffix of matching to be passed in to make archive matches more accurate --- src/components/404LinkCorrection/index.tsx | 4 ++-- src/pages/resources/404.tsx | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/404LinkCorrection/index.tsx b/src/components/404LinkCorrection/index.tsx index f54a637..2d00eb0 100644 --- a/src/components/404LinkCorrection/index.tsx +++ b/src/components/404LinkCorrection/index.tsx @@ -74,7 +74,7 @@ export const getPossibleCorrections = ( // location.pathname is link after protocol and hostname // by replacing `"/resources/"`, // we are left with only the relative path to `resources` - const search = location.pathname.replace(`/${basepath}/`, "") + const search = location.pathname.replace(`/${basepath}`, "") // filter based on distance // levenshtein distance of x means how 'off' it was @@ -96,7 +96,7 @@ export const getPossibleCorrections = ( {displayArray.map((value, index) => { return (
  • - + {value.node.relativePath}
  • diff --git a/src/pages/resources/404.tsx b/src/pages/resources/404.tsx index ebb1cd0..c1267af 100644 --- a/src/pages/resources/404.tsx +++ b/src/pages/resources/404.tsx @@ -13,7 +13,9 @@ export default ({ data }: ComponentQuery<{ allFile: FileConnection }>) => (

    RESOURCE NOT FOUND

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

    - {({ location }) => getPossibleCorrections("resources", location, data, 8)} + {({ location }) => + getPossibleCorrections("resources/", location, data, 8) + } )