Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin routes should be able to change the route config #2352

Open
epangelias opened this issue Mar 8, 2024 · 1 comment
Open

Plugin routes should be able to change the route config #2352

epangelias opened this issue Mar 8, 2024 · 1 comment

Comments

@epangelias
Copy link
Contributor

Routes in a plugin should allow configuring the route configuration options. This would allow plugins to add pages without the app's layout or app wrapper to effect it. This would allow easier integration of plugins without need to do any changes to layout or app wrappers on the app.

An example of this is in the KV Insights plugin, additional configuration must be done on any layout wrappers. The plugin provides the following code as a work-around:

// routes/_app.tsx

import { AppProps } from '$fresh/server.ts';

export default function App(props: AppProps) {
  if (context.url.pathname.startsWith('/kv-insights/')) {
    return <props.Component />;
  }

  return (
    <div class='wrapper'>
      <props.Component />
    </div>
  );
}

This is how this feature could be implemented:

export default {
  name: 'plugin',
  routes: [
	  {
		  path: '/admin',
		  handler: handler,
		  component: component,
                  config: { skipInheritedLayouts: true },
	  },
  ],
} as Plugin
@deer
Copy link
Contributor

deer commented Mar 8, 2024

duplicate of #2296

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

No branches or pull requests

2 participants