Skip to content
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

prerender external links #3826

Merged
merged 6 commits into from
Feb 17, 2022
Merged

prerender external links #3826

merged 6 commits into from
Feb 17, 2022

Conversation

Rich-Harris
Copy link
Member

In #1679 we stopped crawling links with rel="external" during prerendering. rel="external" is often used to force a full page navigation (instead of a client-side navigation), and in those cases is orthogonal to the question of whether something should be prerendered (see e.g. #3331).

It seems like the simplest thing to do would simply be to follow those links, but @v1ack perhaps you can elaborate on the motivation for #1679?

The alternative would be to introduce a new construct for disabling client-side navigation on a link (i.e. a new sveltekit:blah attribute) but it would be better to avoid that unless we really need it.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2022

🦋 Changeset detected

Latest commit: 6a7f51b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Feb 10, 2022

✔️ Deploy Preview for kit-demo canceled.

🔨 Explore the source changes: 6a7f51b

🔍 Inspect the deploy log: https://app.netlify.com/sites/kit-demo/deploys/620bd81c681cf0000734b9bb

@v1ack
Copy link
Contributor

v1ack commented Feb 11, 2022

External needs when another page on the same host handled by another service.

For example, my case is

If I place link to lib site on main site without #1679 - crawler fails with 404.

Maybe the logic of crawler can be changed to something like this:

  • if we faced to external - try to crawl
  • if external page doesn't exist - make a warning (not error) and continue crawling

@Conduitry
Copy link
Member

You can control what happens when the crawler runs into a missing page with https://kit.svelte.dev/docs/configuration#prerender

@Rich-Harris
Copy link
Member Author

Yeah, I think I'm inclined to say that this can be handled via the prerender.onError option:

// svelte.config.js
export default {
  kit: {
    prerender: {
      onError: ({ status, path }) => {
        if (path.startsWith('/svelte-virtual-scroll-list')) return;
        throw new Error(`${status} ${path}`);
      }
    }
  }
};

@Rich-Harris Rich-Harris marked this pull request as ready for review February 15, 2022 16:27
@v1ack
Copy link
Contributor

v1ack commented Feb 15, 2022

Ok, it looks good
But I think it's better to be mentioned in docs, near externaloption, maybe as a link to FAQ

@Rich-Harris
Copy link
Member Author

Added some docs: 6a7f51b

@babichjacob
Copy link
Member

Partially related discussion on Discord for those curious: https://discord.com/channels/457912077277855764/750401468569354431/943224194634764369

@Rich-Harris Rich-Harris merged commit 58a480e into master Feb 17, 2022
@Rich-Harris Rich-Harris deleted the prerender-external-links branch February 17, 2022 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants