📝 Write hook docs

This commit is contained in:
Freeze455
2021-08-17 21:38:42 +02:00
parent 04f62c2162
commit 8bdaad0ae8
3 changed files with 53 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ import Structure from './base/Structure.vue'
import Command from './base/Command.vue'
import Event from './base/Event.vue'
import Middleware from './base/Middleware.vue'
import Hook from './base/Hook.vue'
const routes: RouteRecordRaw[] = [
{ path: '/documentation/getting-started', component: GettingStarted },
@@ -15,6 +16,7 @@ const routes: RouteRecordRaw[] = [
{ path: '/documentation/commands', component: Command },
{ path: '/documentation/events', component: Event },
{ path: '/documentation/middlewares', component: Middleware },
{ path: '/documentation/hooks', component: Hook },
]
export default routes

View File

@@ -0,0 +1,50 @@
<template>
<Documentation title="Hooks">
<p>
Hooks are hooks at certain points in the application's life cycle. You can add specific behaviours to them according to your needs, such as a filter that allows you to delete any message that contains an insult.
Creating a command with the framework is very simple.
</p>
<div class="space-y-5">
<h2>Create new command from CLI</h2>
<p>
Open a new terminal in your project and write the following command :
</p>
<CodeHighlight class="w-min" code="$ factory make:file" />
<AlertInfo>
<template v-slot:label>
Info
</template>
<template v-slot:message>
Choose to create a hook and then answer the questions you will be asked. It is important to note that when you define the file name, you can "place" the file in folders by specifying a path directory in addition to the file name as in the following example :
</template>
</AlertInfo>
</div>
<div class="space-y-5">
<h2>Default command file</h2>
<p>
A file will be created in the specified location otherwise in the root of your project with the following structure :
</p>
<CodeHighlight class="w-min" :code="file" />
</div>
</Documentation>
</template>
<script setup lang="ts">
import Documentation from '../../../../components/Documentation.vue'
import CodeHighlight from '../../../../components/CodeHighlight.vue'
import Divider from '../../../../components/Divider.vue'
import LinkExternal from '../../../../components/LinkExternal.vue'
import AlertInfo from '../../../../components/AlertInfo.vue'
const file = `
import { Hook, BaseHook, HookContext } from '@discord-factory/core'
@Hook('app::command::received')
export default class FooHook implements BaseHook {
public async run(context: HookContext): Promise<void> {
// Your code here
}
}`
</script>

View File

@@ -25,6 +25,7 @@ export const documentation = [
{ label: 'Commands', href: '/documentation/commands', isMenu: false },
{ label: 'Events', href: '/documentation/events', isMenu: false },
{ label: 'Middlewares', href: '/documentation/middlewares', isMenu: false },
{ label: 'Hooks', href: '/documentation/hooks', isMenu: false },
]
},
]