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

changed handle_error and index segments #962

Closed
wants to merge 1 commit into from

Conversation

thebells1111
Copy link

Right now, the 'segment' prop that is passed to _layout.svelte will be undefined for both the index page, and for the error handling page. This will change the segments to ['index'] and ['_error'] respectively. Being able to differentiate between the two pages in the segment prop will allow the designer greater control over determining how the page is displayed, such as changing the Nav appearance based upon the segment sent.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases features are absent for a reason.
  • This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them.
  • Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to npm run lint!)

Tests

  • Run the tests tests with npm test or yarn test)

Right now, the 'segment' prop that is passed to `_layout.svelte` will be undefined for both the index page, and for the error handling page. This will change the segments to `['index']` and `['_error']` respectively. Being able to differentiate between the two pages in the `segment` prop will allow the designer greater control over determining how the page is displayed, such as changing the Nav appearance based upon the segment sent.
@@ -274,7 +274,8 @@ export async function hydrate_target(target: Target): Promise<{
branch?: Array<{ Component: ComponentConstructor, preload: (page) => Promise<any>, segment: string }>;
}> {
const { route, page } = target;
const segments = page.path.split('/').filter(Boolean);
const segments = page.path === '/' ? ['index'] : page.path.split('/').filter(Boolean);
Copy link

Choose a reason for hiding this comment

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

Hi! I would also like to have this feature/fix.
So, this change will not allow us to have a route like index? Why not just pass the empty string '' instead? It's basically what we have in url.

@Conduitry
Copy link
Member

Given that we're probably going to be removing or at least deprecating segment (#824), I don't think this is the proper solution to #948, or at least isn't the entire solution. We probably want an additional field on the $page store that indicates whether this is an error page (and possibly also what the error is? I have a less strong opinion about that).

@krzysztof-grzybek
Copy link

@Conduitry Sounds reasonable, thank You!

@thebells1111
Copy link
Author

It seems like it would be easy enough to put error and status inside of the $page object. If this is done, the need for an error prop and status prop is probably eliminated, since they would be accessible in the $page object.

@benmccann benmccann added this to Error handling in Roadmap Triage Aug 20, 2020
@benmccann benmccann linked an issue Aug 26, 2020 that may be closed by this pull request
@benmccann
Copy link
Member

I'll go ahead and close this given the feedback above. We can consider #1498 as an alternative

@benmccann benmccann closed this Sep 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Roadmap Triage
Error handling
Development

Successfully merging this pull request may close these issues.

Make layout know if it's in error page or home page
4 participants