From 9300acb384f5dc12e37cbd72c3f0acc6ab7ef407 Mon Sep 17 00:00:00 2001 From: David E Disch Date: Fri, 5 Aug 2022 09:36:51 +1000 Subject: [PATCH 1/3] chore(gatsby): Update Routing docs to reflect that pre-encoded unicode characters can't be used in paths --- docs/docs/reference/routing/creating-routes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/docs/reference/routing/creating-routes.md b/docs/docs/reference/routing/creating-routes.md index d628f9faa937b..091f8f783aa32 100644 --- a/docs/docs/reference/routing/creating-routes.md +++ b/docs/docs/reference/routing/creating-routes.md @@ -83,6 +83,8 @@ exports.createPages = async function ({ actions, graphql }) { The data for creating these pages doesn't necessarily have to come from Gatsby's internal GraphQL data layer. For example, you can source local files or make async calls to remote APIs. For more information, please see [Creating and Modifying Pages](/docs/creating-and-modifying-pages/). +`path` must not be pre-encoded (ie. using `encodeURI`) however unicode characters are supported. So for a path like `/exámple` just pass the string directly. Do not pass `encodeURI('/exámple')` or `/ex%C3%A1mple`. If you receive pre-encoded paths from your CMS you may want to run them through `decodeURI` first to ensure the special characters (eg. `%C3%A1`) are turned back into unicode. + ## Conflicting Routes Since there are multiple ways to create a page, different plugins, themes, or sections of code in your `gatsby-node` file may accidentally create multiple pages that are meant to be accessed by the same path. When this happens, Gatsby will show a warning at build time, but the site will still build successfully. In this situation, the page that was built last will be accessible and any other conflicting pages will not be. Changing any conflicting paths to produce unique URLs should clear up the problem. From 8c85a5be6d569c1b1d615050bc03c55da9b547a9 Mon Sep 17 00:00:00 2001 From: David E Disch Date: Fri, 5 Aug 2022 09:47:53 +1000 Subject: [PATCH 2/3] docs(gatsby): Update createPage API description to mention that unicode paths should not be encoded --- packages/gatsby/src/redux/actions/public.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby/src/redux/actions/public.js b/packages/gatsby/src/redux/actions/public.js index 79feb63e3e470..9089d35a8357b 100644 --- a/packages/gatsby/src/redux/actions/public.js +++ b/packages/gatsby/src/redux/actions/public.js @@ -155,7 +155,7 @@ const reservedFields = [ * Create a page. See [the guide on creating and modifying pages](/docs/creating-and-modifying-pages/) * for detailed documentation about creating pages. * @param {Object} page a page object - * @param {string} page.path Any valid URL. Must start with a forward slash + * @param {string} page.path Any valid URL. Must start with a forward slash. Unicode characters should be passed directly and not encoded (eg. `á` not `%C3%A1`). * @param {string} page.matchPath Path that Reach Router uses to match the page on the client side. * Also see docs on [matchPath](/docs/gatsby-internals-terminology/#matchpath) * @param {string} page.ownerNodeId The id of the node that owns this page. This is used for routing users to previews via the unstable_createNodeManifest public action. Since multiple nodes can be queried on a single page, this allows the user to tell us which node is the main node for the page. Note that the ownerNodeId must be for a node which is queried on this page via a GraphQL query. From d317a9f66549403c99c7e72343e94e1e32d98b00 Mon Sep 17 00:00:00 2001 From: David E Disch Date: Fri, 5 Aug 2022 09:54:52 +1000 Subject: [PATCH 3/3] docs(gatsby): Reword documentation --- docs/docs/reference/routing/creating-routes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference/routing/creating-routes.md b/docs/docs/reference/routing/creating-routes.md index 091f8f783aa32..ec8adba72cb11 100644 --- a/docs/docs/reference/routing/creating-routes.md +++ b/docs/docs/reference/routing/creating-routes.md @@ -83,7 +83,7 @@ exports.createPages = async function ({ actions, graphql }) { The data for creating these pages doesn't necessarily have to come from Gatsby's internal GraphQL data layer. For example, you can source local files or make async calls to remote APIs. For more information, please see [Creating and Modifying Pages](/docs/creating-and-modifying-pages/). -`path` must not be pre-encoded (ie. using `encodeURI`) however unicode characters are supported. So for a path like `/exámple` just pass the string directly. Do not pass `encodeURI('/exámple')` or `/ex%C3%A1mple`. If you receive pre-encoded paths from your CMS you may want to run them through `decodeURI` first to ensure the special characters (eg. `%C3%A1`) are turned back into unicode. +`path` must not be pre-encoded (ie. using `encodeURI`) however unicode characters are supported. So for a path like `/exámple` pass the string directly. Do not pass `encodeURI('/exámple')` or `/ex%C3%A1mple`. If you receive pre-encoded paths from your CMS you may want to run them through `decodeURI` first to ensure the special characters (eg. `%C3%A1`) are turned back into unicode. ## Conflicting Routes