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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion site/content/docs/05-layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ Layout components receive a `segment` property which is useful for things like s
+ href="settings/notifications"
+ >Notifications</a>
</div>
```
```

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?

5 changes: 2 additions & 3 deletions src/core/create_manifest_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.


if (component) components.push(component);

walk(
path.join(dir, item.basename),
segments,
params,
component
? stack.concat({ component, params })
: stack.concat(null)
(reset ? [] : stack).concat(component ? { component, params } : null)
);
}

Expand Down