fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Plugin routes should be able to change the route config

Open epangelias opened this issue 1 year ago • 1 comments

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

epangelias avatar Mar 08 '24 20:03 epangelias

duplicate of #2296

deer avatar Mar 08 '24 22:03 deer