rafgraph / spa-github-pages

Host single page apps with GitHub Pages
https://spa-github-pages.rafgraph.dev
MIT License
3.81k stars 561 forks source link

Project and User/Organization Pages #8

Closed websemantics closed 8 years ago

websemantics commented 8 years ago

Hi and thank you for this project,

I had an issue with running the code on a Project Pages type Github repository, I also thought it would be easier for people to import from Bower / Node,

So here's an Npm/Bower package of your code slightly modified to support Project and User Org Pages

https://github.com/websemantics/gh-pages-spa

rafgraph commented 8 years ago

If it's a project pages site, then you have to use a custom domain in order for GitHub Pages to serve a custom 404 page. I talk a bit about how to set this up in the instructions with links to GitHub docs.

websemantics commented 8 years ago

Thanks for your reply,

When I first used the code, I had all the url after the main domain, for example, https://username.github.io/repo/foo turned into query-string >> https://username.github.io?p=repo/foo, this didn't work well for Project Pages where the repo name should stay, .. I might be missing on something here,

rafgraph commented 8 years ago

You're right, but it's a moot point because you must use a custom domain for GitHub Pages to serve a custom 404 page for a Project Pages site, see here, and the custom domain won't have /repo at the beginning of the path.

I did a few tests this morning and it appears that GitHub Pages now serves a custom 404 page for Project Pages sites without using a custom domain (despite the docs still indicating the opposite). I'll reopen the issue and update the redirect scripts. Thanks for the heads up @websemantics.

Also, don't forget to include author cred along with my code in ghspa.js.

rafgraph commented 8 years ago

Fixed. Just set pathPrefix to true here and it will work with Project Pages sites not using a custom domain. Also updated the readme, so check that out for more info.

Let me know if you have any issues with this.

rafgraph commented 8 years ago

Just got confirmation from GitHub support that GitHub Pages now serves a custom 404 page for Project Pages sites without using a custom domain (GitHub docs are outdated and will be updated).

websemantics commented 8 years ago

I never read the docs, ignorance -sometimes- is a bless hh

I already had a link to your repo in the original README.md and now clearly in ghspa.js,

The only added contribution I had was the switch between Project Pages and User/Org pages which your library now supports too,

I also had it packaged as Bower/Node package, and the setup/steps are slightly easier to follow (maybe),

If you could probably make it as such, I really don't need that repo,

Thanks @rafrex for the original contribution,

websemantics commented 8 years ago

Oh, and a really fancy demo page which took way longer to build than writing code hhh