plentico / plenti

Static Site Generator with Go backend and Svelte frontend
https://plenti.co
Apache License 2.0
985 stars 50 forks source link

Local baseurls #246

Closed jimafisk closed 1 year ago

jimafisk commented 1 year ago

Baseurls (e.g. https://mysite.com/subsite/) make resolving links fairly complicated, you need everything to be relative (e.g. path/to/whatever) vs root relative (e.g. /path/to/whatever). This is fine in a deployed environment, but currently we convert everything to root relative if running a local webserver, even if you're using a baseurl in your deployed app. That creates challenges for things like media assets, because locally you want to load them using root relative paths, but if you want to change a reference to them in a JSON content source, then you want to use a relative path so it works in a deployed environment that has a baseurl.

Proposal: If a site is using a baseurl (as specified in plenti.json), the local webserver should serve the site from that baseurl (e.g. http://localhost:3000/subsite/). That would avoid having to introduce a whole new workflow for local and would be more similar to the deployed environment.

We could potentially add forward slashes to items in the allAssets array in /spa/ejected/cms/assets.js during the build process as well to avoid having to check the env.baseurl to create assetPrefix in the client.

jimafisk commented 1 year ago

Implemented in v0.5.24.