mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Move define extension functions to shared and expose them through extension-sdk (#6880)
* Move defineInterface to shared * Split up utils into node and browser utils * Move defineDisplay to shared * Move defineLayout to shared * Move defineModule to shared * Add defineEndpoint and defineHook to define-extensions * Expose define extension functions through extension-sdk * Make route type of defineEndpoint more specific * Simplify define extension functions * Deduplicate types and local types definition * Do not allow functional components in display handler * Make interface options nullable * Deduplicate extension types definition * Fix utils/node exports
This commit is contained in:
committed by
GitHub
parent
3a9475fba5
commit
32972f4c01
@@ -1,11 +1,14 @@
|
||||
import { defineModule } from '@/modules/define';
|
||||
import { defineModule } from '@directus/shared/utils/browser';
|
||||
import docs, { DocsRoutes } from '@directus/docs';
|
||||
import { RouteRecordRaw } from 'vue-router';
|
||||
import NotFound from './routes/not-found.vue';
|
||||
import StaticDocs from './routes/static.vue';
|
||||
|
||||
export default defineModule(() => {
|
||||
const routes: RouteRecordRaw[] = [
|
||||
export default defineModule({
|
||||
id: 'docs',
|
||||
name: '$t:documentation',
|
||||
icon: 'info',
|
||||
routes: [
|
||||
{
|
||||
path: '',
|
||||
redirect: '/docs/getting-started/introduction/',
|
||||
@@ -15,38 +18,31 @@ export default defineModule(() => {
|
||||
path: ':_(.+)+',
|
||||
component: NotFound,
|
||||
},
|
||||
];
|
||||
|
||||
return {
|
||||
id: 'docs',
|
||||
name: '$t:documentation',
|
||||
icon: 'info',
|
||||
routes,
|
||||
order: 20,
|
||||
};
|
||||
|
||||
function getRoutes(routes: DocsRoutes): RouteRecordRaw[] {
|
||||
const updatedRoutes: RouteRecordRaw[] = [];
|
||||
|
||||
for (const route of routes) {
|
||||
if (!('children' in route)) {
|
||||
updatedRoutes.push({
|
||||
path: route.path,
|
||||
component: StaticDocs,
|
||||
meta: {
|
||||
import: route.import,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
updatedRoutes.push({
|
||||
path: route.path,
|
||||
redirect: '/docs' + route.children![0].path,
|
||||
});
|
||||
|
||||
updatedRoutes.push(...getRoutes(route.children));
|
||||
}
|
||||
}
|
||||
|
||||
return updatedRoutes;
|
||||
}
|
||||
],
|
||||
order: 20,
|
||||
});
|
||||
|
||||
function getRoutes(routes: DocsRoutes): RouteRecordRaw[] {
|
||||
const updatedRoutes: RouteRecordRaw[] = [];
|
||||
|
||||
for (const route of routes) {
|
||||
if (!('children' in route)) {
|
||||
updatedRoutes.push({
|
||||
path: route.path,
|
||||
component: StaticDocs,
|
||||
meta: {
|
||||
import: route.import,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
updatedRoutes.push({
|
||||
path: route.path,
|
||||
redirect: `/docs${route.children[0].path}`,
|
||||
});
|
||||
|
||||
updatedRoutes.push(...getRoutes(route.children));
|
||||
}
|
||||
}
|
||||
|
||||
return updatedRoutes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user