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

Add config level option for not rendering 404 for routes not handled by sveltekit. #10010

Open
nisarhassan12 opened this issue May 22, 2023 · 4 comments

Comments

@nisarhassan12
Copy link

nisarhassan12 commented May 22, 2023

Describe the problem

We recently migrated our site to Svelte/SvelteKit we're using the adapter-static and hosting the site on an S3 bucket.

We have the docs in a separate repo using Hugo as the site generator deployed on S3 as well available at https://materialize.com/docs/

On the deployed Sveltekit site when one visits a link pointing to https://materialize.com/docs/ it renders the 404 page as the docs route is not defined in the kit site.

For the links that are within the Svelte components, I can use data-sveltekit-reload but for the links that are within the markdown content coming from CMS it is not feasible to add data-sveltekit-reload to every link pointing to the docs.

Describe the proposed solution

Some way in the config to let Sveltekit add data-sveltekit-reload to all the links pointing to https://materialize.com/docs/ or another URL instead of manually doing it in all places.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

@nisarhassan12 nisarhassan12 changed the title Add config level option for not rendering 404 for a routes not handled by sveltekit. Add config level option for not rendering 404 for routes not handled by sveltekit. May 22, 2023
@tcc-sejohnson
Copy link
Contributor

@geoffrich

Was it you I remember who was doing something in a layout that would solve this problem?

@geoffrich
Copy link
Member

You can put data-sveltekit-reload on a wrapper element (e.g. in a layout) and it will apply to all links in that element.

<div data-sveltekit-reload>
	<p>
		All the links in here will behave as if data-sveltekit-reload was applied to them directly.
	</p>
	<p>
		<a href="/docs">docs</a> and <a href="/tutorial">tutorial</a>
	</p>
</div>

Though that will apply to all links - I think what's being asked for here is a way to conditionally apply data-sveltekit-reload to some links based on whether they start with /docs/ or not.

@nisarhassan12 can you provide a repo that shows your setup? It's hard to identify a good solution without some code to look at

@nisarhassan12
Copy link
Author

nisarhassan12 commented May 24, 2023

Thanks @geoffrich for the response.

The original repo is private but here is a clone https://github.com/nisarhassan12/stackbit-sveltekit Let me know incase you have any specific questions about it.

The way all the pages are built is from markdown in src/content/pages/ the files within src/content/pages/blog/ or other post types can have links that point to https://materialize.com/docs/ or /docs/.

I think what's being asked for here is a way to conditionally apply data-sveltekit-reload to some links based on whether they start with /docs/ or not.

Yeah exactly this is what I'm looking for 👍🏿on top of it I want to do this conditionally for the links within the markdown.

@nisarhassan12
Copy link
Author

Yeah exactly this is what I'm looking for 👍🏿on top of it I want to do this conditionally for the links within the markdown.

@geoffrich Sorry for the ping. Do you know about any solution for this? Thanks

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

No branches or pull requests

3 participants