We know that Gatsby builds pages in the directory src/pages/ automatically with the path of the same name as the .js file. For example, I have a file src/pages/example.js, when I run the command gatsby develop
in the terminal, the webpage will be available on the site “localhost:8000/example”.
However, given that I am not allowed to build the webpage with the path “/example”, is there a way to blacklist the path “/example”, stop the build/develop process whenever we try to build using a blacklisted path and report an error like “You are not allowed to build the page with the blacklist path: /example” in the terminal?
To give you more context, I now have some website built in Docusaurus running on the url “www.example-domain.com/example”. I want Gatsby to report an error when building the site on “www.example-domain.com/example” and tell the developer that this path is already in use so that the developer can change the name of example.js to other names like another-example.js.