Skip to content
Discussion options

You must be logged in to vote

Try this:

defineOptions({ layout: false });
createInertiaApp({
  resolve: async (name: string): Promise<DefineComponent> => {
    const importPage = pages[`./Pages/${name}.vue`];
    // Forgetful dev error handling
    if (!importPage) {
      if (import.meta.env.DEV) return PageComponentMissing as DefineComponent;
      throw new Error(
        `Unknown page ${name}. Is it located under Pages with a .vue extension?`,
      );
    }
    const page = await importPage();
    page.layout ??= BaseLayout;
    page.layout ||= null;
    return page;
  },
});

Technically, you could omit page.layout ||= null; as the adapter does check for falsey values rather than null or undefined.

Enjoy the bonu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mrleblanc101
Comment options

Answer selected by mrleblanc101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants