diff options
Diffstat (limited to 'support/doc/plugins/guide.md')
-rw-r--r-- | support/doc/plugins/guide.md | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 4a0d318a7..5c96d1b03 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md | |||
@@ -883,6 +883,39 @@ Now you can register hooks or settings, write CSS and add static directories to | |||
883 | **Caution:** It's up to you to check the code you write will be compatible with the PeerTube NodeJS version, | 883 | **Caution:** It's up to you to check the code you write will be compatible with the PeerTube NodeJS version, |
884 | and will be supported by web browsers. | 884 | and will be supported by web browsers. |
885 | If you want to write modern JavaScript, please use a transpiler like [Babel](https://babeljs.io/). | 885 | If you want to write modern JavaScript, please use a transpiler like [Babel](https://babeljs.io/). |
886 | If you want to use __Typescript__ see section below. | ||
887 | |||
888 | ### Typescript | ||
889 | |||
890 | You can add __PeerTube__ types as dev dependencies: | ||
891 | ``` | ||
892 | npm install --dev @peertube/peertube-types | ||
893 | ``` | ||
894 | |||
895 | This package exposes *server* definition files by default: | ||
896 | ```ts | ||
897 | import { RegisterServerOptions } from '@peertube/peertube-types' | ||
898 | |||
899 | export async function register ({ registerHook }: RegisterServerOptions) { | ||
900 | registerHook({ | ||
901 | target: 'action:application.listening', | ||
902 | handler: () => displayHelloWorld() | ||
903 | }) | ||
904 | } | ||
905 | ``` | ||
906 | |||
907 | But it also exposes client types and various models used in __PeerTube__: | ||
908 | ```ts | ||
909 | import { RegisterClientOptions } from '@peertube/peertube-types/client' | ||
910 | |||
911 | export function register ({ registerHook, peertubeHelpers }: RegisterClientOptions) { | ||
912 | registerHook({ | ||
913 | target: 'action:application.init', | ||
914 | handler: () => onApplicationInit(peertubeHelpers) | ||
915 | }) | ||
916 | } | ||
917 | ``` | ||
918 | > Other types are accessible from the shared path `@peertube/peertube-types/shared`. | ||
886 | 919 | ||
887 | ### Add translations | 920 | ### Add translations |
888 | 921 | ||