-
-
Notifications
You must be signed in to change notification settings - Fork 432
Allow export to take multiple entrypoints to use when crawling. #825
Conversation
What does the |
From what I can tell, nothing, I probably just thought it was more descriptive. I don't really remember, I wrote this code quite a while ago. In terms of implementation, It's just running |
src/api/export.ts
Outdated
@@ -201,7 +212,7 @@ async function _export({ | |||
type = 'text/html'; | |||
body = `<script>window.location.href = "${location.replace(origin, '')}"</script>`; | |||
|
|||
tasks.push(handle(resolve(root.href, location))); | |||
tasks.push(handle(resolve(entryPoints[currentRoot].href, location))); |
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.
What's the reason for resolving this relative to the current entry point? I think this should still always be relative to root
. My understanding is that the multiple entry points is just so that the crawler can find pages it wouldn't ordinarily find. All of them should still have the same base href value.
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.
The test you wrote still passes when using root.href
, fwiw
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.
Yeah, I think you're right. I don't think I looked too deeply into this but I guess this clause is handling redirects/ 300s? I think it's using the Location
header and building a new url to handle
from that. My tests definitely don't test this behaviour, I don't know if any of the existing ones do either but resolving with anything but the root url would fail, I think.
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.
Yeah, looking back this clears up some of the confusion I had at the time with the whole entryPoints[currentRoot]
thing, I wondered why that was necessary. This correction removes the need for that entirely. I probably should have taken more time to understand the code before implementing this.
It looks like this was broken recently |
@onionhammer I also thought this was broken; I was using the wrong syntax. I tried comma-separation and multiple |
I am PRing this again because I'm a genius and the original PR was from the master of my svelte fork. I was then too terrified to actually try to do anything on another branch in-case I broke something.
Original PR: #756.
This PR allows you to pass a list of entry points to export, which allows users to fully export apps that are not entirely linked by anchor tags.
I'm not sure if this is the best way to do it but it seems to work, I've added a test that provides a few unlinked entry points in the various styles people might try to pass in. I've done my best to handle unnecessary
index.html
s and/
s (I'm no regex expert so that might need looking at). I also moved theoninfo
call so users get a console message for each entry point, followed by the list of saved files for that 'crawl'.I added
.vscode
to the gitignore as I was having trouble disabling my autoformatting with out it. I don't know what has happened with thepackage-lock.json
it just seems to add some stuff when I install it.Closes #749.