Skip to content

Commit 514fbed

Browse files
committed
docs: update plugin development guide to clarify component registration and import paths
1 parent 0157cd1 commit 514fbed

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

adminforth/documentation/docs/tutorial/09-Advanced/01-plugin-development.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -507,22 +507,11 @@ To ensure that plugin activates before some other plugins set `activationOrder`
507507
508508
## Splitting frontend logic into multiple files
509509
510-
In case your plugin `.vue` files getting too big, you can split them into multiple files (components)
511-
Unfortunately when developing plugin, you should register such components(files) manually by calling `componentPath` in `modifyResourceConfig` method:
510+
In case your plugin `.vue` files getting too big, you can split them into multiple files (components).
512511
512+
Just create a new file `subComponent.vue` in `custom` folder and add your code there.
513513
514-
```ts title='./af-plugin-chatgpt/index.ts'
515-
async modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
516-
super.modifyResourceConfig(adminforth, resourceConfig);
517-
//diff-add
518-
// we just call componentPath method to register component, not using it's result
519-
//diff-add
520-
this.componentPath('subComponent.vue'),
521-
};
522-
}
523-
```
524-
525-
Now to import `subComponent.vue` in `completionInput.vue` file you should use `@@/plugins/<plugin-class-name>/subComponent.vue` path:
514+
Then import it as a component:
526515
527516
```html title='./af-plugin-chatgpt/custom/completionInput.vue'
528517
<template>
@@ -534,12 +523,10 @@ Now to import `subComponent.vue` in `completionInput.vue` file you should use `@
534523

535524
<script setup lang="ts">
536525
//diff-add
537-
import SubComponent from '@@/plugins/ChatGptPlugin/subComponent.vue';
526+
import SubComponent from './subComponent.vue';
538527
</script>
539528
```
540529
541-
Pay attention that `ChatGptPlugin` is a class name of your plugin so it should be used in path.
542-
543530
544531
## Using Adapters
545532

0 commit comments

Comments
 (0)