Comparing version 0.0.7 to 0.0.8
{ | ||
"name": "neogarden", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -16,2 +16,7 @@ import { getClient } from "./getClient"; | ||
const config = getConfig(); | ||
if (!config?.prismic?.routes) { | ||
return { | ||
error: `Prismic routes in configuration not found, please add them!`, | ||
}; | ||
} | ||
const options = { | ||
@@ -27,5 +32,7 @@ fetchLinks, | ||
if (route === undefined) { | ||
return { error: "Route match in configuration not found" }; | ||
return { | ||
error: `Prismic routes in configuration did not match with current route!`, | ||
}; | ||
} | ||
return getPage(route, client, parsed, options); | ||
} |
@@ -8,3 +8,9 @@ import { redirect } from "remix"; | ||
// Redirect the user to first language from configuration | ||
return redirect(`/${Object.keys(config.prismic.locales)[0]}`); | ||
if (config?.prismic?.locales && config.prismic.locales.length > 0) { | ||
return redirect(`/${Object.keys(config.prismic.locales)[0]}`); | ||
} | ||
// Return error as a fallback | ||
return { | ||
error: `Automatic redirect failed because no locale was found in configuration, please add at least one!`, | ||
}; | ||
} |
4701
130