Sapper: Make layout know if it's in error page or home page

Created on 20 Oct 2019  路  4Comments  路  Source: sveltejs/sapper

Is your feature request related to a problem? Please describe.
I asked this question on SO, but doesn't get much attentions.

I want to style the page differently in home and error page, but segment is undefined in both pagas.

Describe the solution you'd like
Either make segment return different values (e.g., "" vs undefined), or another variable saying if the current is error or not.

I lean toward the former.

How important is this feature to you?
Giving different layouts to home and error page layout is pretty common I think, and given there doesn't seem to be a workaround, I feel it's pretty important.

error handling proposal

Most helpful comment

$page.error is now available in 0.28.9.

All 4 comments

On a side note, the page store from @sapper/app may offer a (slightly hacky) workaround. That being said, the problem surely seems common enough to warrant a better solution. I鈥檇 go as far as to say _error.svelte should not inherit the common layout by default (we can still import and use it explicitly if we want to).

There鈥檚 a pull request https://github.com/sveltejs/sapper/pull/962

PR #1250 may be the solution to this. It separates the _layout styling from the _error styling.

$page.error is now available in 0.28.9.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SARFEX picture SARFEX  路  3Comments

Rich-Harris picture Rich-Harris  路  4Comments

keyvan-m-sadeghi picture keyvan-m-sadeghi  路  4Comments

benmccann picture benmccann  路  3Comments

BMorearty picture BMorearty  路  3Comments