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

Support __error.reset.svelte #2694

Closed
drobati opened this issue Oct 27, 2021 · 5 comments
Closed

Support __error.reset.svelte #2694

drobati opened this issue Oct 27, 2021 · 5 comments
Labels
feature request New feature or request

Comments

@drobati
Copy link

drobati commented Oct 27, 2021

Describe the problem

I want the error page at /routes to not contain the __layout.svelte code.

I would like my error page to be a fullscreen background image without the navbar that exists across the site.

Describe the proposed solution

Allow error pages to be reset with .reset like __layout.reset.svelte

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

@yousufiqbal
Copy link
Contributor

I second this. This is a need

@rmunn rmunn added the feature request New feature or request label Nov 2, 2021
@mihaon
Copy link

mihaon commented Dec 12, 2021

I need it too. Moreover I think it can be useful for any page (for example, index.reset.svelte; see #2999)

Without __error.reset.svelte feature I don't see a good way to create a root error page with its own layout, and the only way I can see is:

hooks.js

export async function handle({request, resolve}) {
	request.locals.error = false
	let response = await resolve(request)

	if (response.status != 200) {
		request.locals.error = true
		response = await resolve(request)
	}

	return {
		...response,
	}
}

export async function getSession(request) {
	return {
		error: request.locals.error,
	}
}

routes/__layout.svelte

<script>
	import {session} from '$app/stores'
</script>

{#if $session.error}
	<slot></slot>
{:else}
	<header>Layout header</header>
	<main>
		<slot></slot>
	</main>
	<footer>Layout footer</footer>
{/if}

routes/index.svelte

<p>Content of index.svelte</p>

routes/__error.svelte

<p>Content of __error.svelte</p>

Results

http://localhost:3000/

<header>Layout header</header>
<main>
	<p>Content of index.svelte</p>
</main>
<footer>Layout footer</footer>

http://localhost:3000/qweqweqwe

<p>Content of __error.svelte</p>

@pzuraq
Copy link
Contributor

pzuraq commented Feb 8, 2022

This would be useful for us as well. It would also be useful to be able to reset the layout for index.svelte, specifically because index.svelte is a completely different page design for us.

@lukaszpolowczyk
Copy link
Contributor

I am pasting my proposal - __error folder z __layout.reset.svelte:

A __error directory that can have its own __layout.reset.svelte. This can be multi-level. For the first level: routes/__error/index.svelte - error page routes/__error/__layout.reset.svelte - layout reset page

The file /routes/__error/index.svelte, is equivalent to /routes/__error.svelte - so it works on all subpages e.g. on routes/about also this error works.

Of course this should also work: routes/todos/__error/index.svelte - error page routes/todos/__error/__layout.reset.svelte - layout reset page

Then the /routes/todos/__error/index.svelte file is equivalent to /routes/todos/__error.svelte.

@Rich-Harris
Copy link
Member

closing in favour of #4582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants