React-static: Implement basePath, and devUsesBasePath options

Created on 28 Feb 2018  路  3Comments  路  Source: react-static/react-static

Preface

Currently, siteRoot does not handle basePaths as part of the URL. We need to add a basePath option that can handle a site hosted at a sub-directory. There are also circumstances where a user may want the local server to also use this basePath (eg. http://localhost:8080/my-blog/ being the root), so we should add an option to handle that as well, possibly called devUsesBasePath

Implementation

  • [ ] Add basePath as an option in the default config and optionally use it in the Router component via react-router's basepath prop and also the <base> html tag (I think). basePath will also need to be considered in most (not all) places that siteRoot is used. The one that comes to mind is sitemap.xml generation. basePath should also be normalized to include the leading slash and not a trailing slash.
  • [ ] Add devUsesBasePath as an option in the default config. When true it should use the basePath option above in dev mode to support use cases like viewing the dev site from a url like http://localhost:8080/my-blog/.
  • [ ] Make sure all instances of siteRoot do not contain any sub routes and that trailing slashes are normalized where they need to be. With this change, the siteRoot should only be a protocol://sub.domain.suffix
  • [ ] Add and update documentation for the api.

Helpful Links

RFI

If you would like to implement this feature or fix, please comment below with your estimated timeline for completion and wait for a 馃憤to get started. This is mainly so we don't have multiple people workin on the same thing. 馃槃 Thanks!

Most helpful comment

Working on it right now!

All 3 comments

Working on it right now!

Thanks! This will allow react-static to be used with github pages.

Done!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pbgms picture pbgms  路  3Comments

bkniffler picture bkniffler  路  3Comments

lottamus picture lottamus  路  3Comments

getDanArias picture getDanArias  路  4Comments

thupi picture thupi  路  3Comments