-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make paths relative #73
Conversation
I will have a look later today, thanks por mentioning me. |
@icidasset I checked Travis, and I can try to help you get the tests passing, but not sure if you want/need help. @dillonkearns sorry for acting like a maintainer here. |
@cyberglot I would love that 👍 There's still a few things broken here, trying to figure it out as I go along here 🤷♂ (Keeping track of every issue in the main post above under "Issues") Sidenote: I'm currently keeping another branch based on this one, which I use in projects for work. Basically the same as this, but has the compiled # Using it in package.json like so:
"elm-pages": "icidasset/elm-pages#fdf09810a6e9e321763058d4b7c14996707fd2a5", And then using elm-git-install for the elm code. You can use that code too if you want. |
Ok, I definitely messed up something with the StaticHttp stuff, I'm not sure what's going on. Any ideas @dillonkearns ? |
e00e9db
to
b724504
Compare
Fairly confident I fixed most of the issues with this PR. If someone else has time to test this, please do 🙏 |
Hello @icidasset and @cyberglot, sorry for the slow response. It's awesome to see you two collaborating and coordinating on this. Thanks so much for working on this feature! 🙏 I tried it out locally, and it's mostly looking like a good design and like it's working properly. The one thing I'm noticing is the note about See the note about OpenGraph tags in the MDN docs you linked to: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
Any ideas on what to do about that? Is there a way to make OpenGraph tags happy using the |
@dillonkearns Awesome Should I make those changes or do you want to tackle that? |
@icidasset that makes sense. Actually, canonical URLs are a special thing when it comes to SEO. There needs to be exactly one. From what I've read, Google can easily flag your site as spam, or seriously penalize your site ranking, if it sees that you have duplicate content. So it's important for a page to have exactly one canonical URL, not one canonical URL for each place you can access it. So it's a feature, not a bug, to have the canonical URL be hardcoded and be exactly one URL. In production, you can see that the For reference, here are the current elm-pages/examples/docs/src/Main.elm Lines 636 to 638 in bb8bb38
Also, you can see how I'm doing that in the head tags here. I'm automatically grabbing the canonical URL when I render the https://github.com/dillonkearns/elm-pages/blob/master/src/Head.elm#L211-L212 So again, I think that all we need to do as have users include their base path in the canonical URL, and then restore that functionality and we should be good. |
Aye sounds good! I'll take a look at fixing that asap. |
@dillonkearns The canonical urls should be back for the seo/head tags. Any other changes I should make? |
Hey @icidasset, I'm still seeing errors on the Netlify build, and my local build is stalling at 98%. Any idea what might be going on? Here's an example netlify build. I cleared the cache and ran this one, so this is a clean build and still getting an error: https://app.netlify.com/sites/elm-pages/deploys/5e6873cfd9b8f78594a17401 |
Ok, sorry about that. Everything should be good now 😅 |
🎉 That's awesome, can't thank you enough for the hard work! Thanks for sticking with it even though it got tricky! 😁 I'll take a look today 👍 |
@dillonkearns Could it be that the Netlify stuff is cached and therefor showing errors? Travis build has passed, so 🤷♂ Also, have you had a chance to look at this? 🙏 |
Hello @icidasset! I tried a clear cache and rebuild on Netlify, and it's still getting this error 🤔 https://app.netlify.com/teams/dillonkearns/builds/5e7e4ffbbbc75201c0ce2c58 12:13:00 PM: Compiling ...
12:13:00 PM: -- NAMING ERROR
12:13:00 PM: --------------------------------------------------- src/Main.elm
12:13:00 PM: I cannot find a `String.chop` variable:
12:13:00 PM: 64|
12:13:00 PM: |> String.chop "/"
12:13:00 PM: ^^^^^^^^^^^
12:13:00 PM: The
12:13:00 PM: `String` module does not expose a `chop` variable. These names seem close
12:13:00 PM: though:
12:13:00 PM: String.cons
12:13:00 PM: String.map
12:13:00 PM: String.all
12:13:00 PM: String.any
12:13:00 PM: Hint: Rea
12:13:00 PM: d <https://elm-lang.org/0.19.1/imports> to see how `import`
12:13:00 PM: declarations work in Elm.
12:13:00 PM: -- NAMING ERROR ------------------------------
12:13:00 PM: --------------------- src/Main.elm
12:13:00 PM: I cannot find a `String.chop` vari
12:13:00 PM: able:
12:13:00 PM: 39| |> String.chop "/"
12:13:00 PM: ^^^^^^^^^^^
12:13:00 PM: The
12:13:00 PM: `String` module d
12:13:00 PM: oes not ex
12:13:00 PM: pose a `chop` variable. These names seem close
12:13:00 PM: though:
12:13:00 PM: String.co
12:13:00 PM: ns
12:13:00 PM: String.map
12:13:00 PM: String.all
12:13:00 PM: String.any
12:13:00 PM: Hint: Read <https://elm-lang.org/0.19.1/imports> to see how `import`
12:13:00 PM: declarations work in Elm.
12:13:00 PM:
Detected problems in 1 module.
12:13:00 PM: npm
12:13:00 PM: ERR! code ELIFECYCLE
12:13:00 PM: npm ERR!
12:13:00 PM: errno 1
12:13:00 PM: npm ERR!
12:13:00 PM: elm-pages@1.2.10 build: `cd generator && elm make src/Main.elm --output src/Main.js --optimize`
12:13:00 PM: npm ERR! Exit status 1
12:13:00 PM: npm
12:13:00 PM: ERR!
12:13:00 PM: npm
12:13:00 PM: ERR! Failed at the elm-pages@1.2.10 build script.
12:13:00 PM: npm ERR! Any ideas? I'll spend some time testing it out this weekend, would love to get this released 👍 |
@@ -57,11 +57,16 @@ dropIndexFromLast path = | |||
|> List.reverse | |||
|
|||
|
|||
chopForwardSlashes : String -> String | |||
chopForwardSlashes = | |||
String.split "/" >> List.filter ((/=) "") >> String.join "/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I want to use the Pages.Internal.String
module here, but don't know how to share that code with the generator/cli.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes. I'll keep that in mind for the future. It's pretty minor so this seems good for now to me 👍
@icidasset I pushed a couple of commits fixing the two issues I found. Link prefetchingThe link prefetching wasn't working because it was checking the
|
Thanks for all the code changes @dillonkearns !
As far as I know when using |
Yeah, I agree 👍 From my testing, that seems to be exactly what it's doing. And if I run So yeah, I think we're in good shape on that! I'll prepare this for release 👍 Thanks again for your hard work on this! And thank you @cyberglot for your work and for getting the ball rolling on this functionality! |
I got this from the spec regarding
So I guess this confirms our assumption 👍
🎉 🙌 |
Good find! So perhaps it could even cause problems to try to change it within the JS. That makes sense, sounds like our current setup is perfect 👍 |
Addresses #15 and #69
How it works
Every generated HTML file contains a
base
element.Works no matter where I put these files:
http://localhost:3000/
,https://example.io/sub-directory/
orhttp://127.0.0.1:8080/ipns/example.io/
.Example
The
href
inbase
will always point to/sub-directory/
. And thehref
in links,src
in scripts and images, etc. will always have a path that reflect the path in your project. So in other words, if we want to link toanother/nested/
, this "relative" link will be the same on every page we have, because, the base element makes it point to the right thing.Notes
current/page#id-on-page
)/
)<link rel="preload" href="content.json" as="fetch" crossorigin />
, defined before the base element, will load the content from the current directory.Issues
I'm (still) having issues with the "static http" stuff. I'm not sure my changes here broke anything relating to that.I'm noticing that the service worker loads weird paths (eg.http://localhost:3000/nested-page//content.json
). Notice the double//
beforecontent.json
. I'm not sure if that's because of my changes or just a weird workbox/service-worker thing.Icon paths inmanifest.json
are incorrect, they should not be prefix withassets/
. Still figuring out how to fix this.Switching between pages doesn't work yet. It tries to loadhttp://content.json/
.Testing
Couldn't compile example projects in this repo because of static http issues (see above)Other solutions
@cyberglot suggested a different solution, using the canonical url as a prefix for the urls. While that works great for a single domain, this requires you to compile a different version for each domain and directory you want to put your site on. Which may work for a lot of people, but not for everyone. For example, our company uses IPFS which has a browser extension that caches your site offline through a proxy. So, when you use the offline version, through the proxy, the site is on a different domain and path. We can't specify a different build for the proxied version, so it's broken in at least one place using this solution.
Another solution would be to have elm-pages make every generated path relative. This might be better because you would avoid the use of the base element, but I think implementing this would be more difficult. I could be wrong though.
Thoughts?