Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Reset layout inheritance if there is a _reset.svelte in the directory. #1141

Closed

Conversation

joycollector
Copy link

Sometimes it is necessary to stop layout inheritance as web page has a different layout but logically needs to be inside this route path.

Example:
/[product]/[model] - Product page
/[produc]/[model]/zoom - Fullscreen page to view the product

According to the discussion in this thread #823 the feature is needed. I do agree with others that the best way would be to put a _reset.svelte file in the folder for which we need to ignore parent layouts.

@@ -145,16 +145,15 @@ export default function create_manifest_data(cwd: string, extensions: string = '

if (item.is_dir) {
const component = find_layout('_layout', `${get_slug(item.file)}__layout`, item.file);
const reset = find_layout('_reset', null, item.file);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ...

const reset = find_layout('_layout.reset', null, item.file);

...?

Seems to nestle better with our current convention, and you'd know what reset was referring to.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally prefer to keep things simple. But if that's a showstopper we can change.

Copy link
Member

@arxpoetica arxpoetica Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_layout.reset.svelte is still simple and clear at a glance. If I knew very little about Sapper, that would be convenient and clear.

@arxpoetica
Copy link
Member

@joycollector something missing from this would be documentation. Considering adding something to this file: https://github.com/sveltejs/sapper/blob/master/site/content/docs/05-layouts.md

@joycollector
Copy link
Author

@joycollector something missing from this would be documentation. Considering adding something to this file: https://github.com/sveltejs/sapper/blob/master/site/content/docs/05-layouts.md

Good catch. Updated.

```

If in some cases you would like to disable layout inheritance - you can place a file called `_reset.svelte` in the folder. In this case only root layout will be applied.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite clear to me. Is _reset.svelte an empty file? Do you put a new layout in it or if you want additional layout do you place a layout.svelte alongside it?

@arxpoetica
Copy link
Member

@joycollector I know you put some work into this, but after various other discussions about routing, I'm fairly certain we'll be heading in a different direction.

We can reopen this if we somehow decide to come back this way. Thanks.

@arxpoetica arxpoetica closed this May 27, 2020
@Escalion
Copy link

@arxpoetica what is the new proposed direction please? (I got here and hit this dead end after tracing various conversations through)
This functionality certainly is a requirement (and I looked at routify because of this, but was unsatisfied with the quality of the implementation).
Is there anywhere your ADRs are recorded? If not, would it be a good idea to document these somewhere?

@arxpoetica
Copy link
Member

arxpoetica commented Jun 23, 2020

This is just early exploration and will likely change, but conversation has been focused around having configurations somehow, whether it's implemented in the bundle via plugins or somewhere more directly integrated with Sapper itself. Here's a sample RFC, though this is, again, likely to change: sveltejs/rfcs#23

If any of you wish to bikeshed on this, maybe take it up in that RFC.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants