mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 09:15:58 +02:00
feat(404): allow for suffix of matching to be passed in to make archive matches more accurate
This commit is contained in:
committed by
Jean-Philippe Sirois
parent
56df4abeb6
commit
a796facdb1
@@ -74,7 +74,7 @@ export const getPossibleCorrections = (
|
|||||||
// location.pathname is link after protocol and hostname
|
// location.pathname is link after protocol and hostname
|
||||||
// by replacing `"/resources/"`,
|
// by replacing `"/resources/"`,
|
||||||
// we are left with only the relative path to `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
|
// filter based on distance
|
||||||
// levenshtein distance of x means how 'off' it was
|
// levenshtein distance of x means how 'off' it was
|
||||||
@@ -96,7 +96,7 @@ export const getPossibleCorrections = (
|
|||||||
{displayArray.map((value, index) => {
|
{displayArray.map((value, index) => {
|
||||||
return (
|
return (
|
||||||
<li key={index}>
|
<li key={index}>
|
||||||
<Link to={`${basepath}/${value.node.relativePath}`}>
|
<Link to={`${basepath}${value.node.relativePath}`}>
|
||||||
{value.node.relativePath}
|
{value.node.relativePath}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ export default ({ data }: ComponentQuery<{ allFile: FileConnection }>) => (
|
|||||||
<h1>RESOURCE NOT FOUND</h1>
|
<h1>RESOURCE NOT FOUND</h1>
|
||||||
<p>You just hit a route that doesn't exist... the sadness.</p>
|
<p>You just hit a route that doesn't exist... the sadness.</p>
|
||||||
<Location>
|
<Location>
|
||||||
{({ location }) => getPossibleCorrections("resources", location, data, 8)}
|
{({ location }) =>
|
||||||
|
getPossibleCorrections("resources/", location, data, 8)
|
||||||
|
}
|
||||||
</Location>
|
</Location>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user