return environment.apiUrl + `${pathPrefix}/${plugin.name}/${plugin.version}/static`
},
+ getBaseRouterRoute: () => {
+ const pathPrefix = this.getPluginPathPrefix(pluginInfo.isTheme)
+ return environment.apiUrl + `${pathPrefix}/${plugin.name}/${plugin.version}/router`
+ },
+
getSettings: () => {
const path = PluginService.BASE_PLUGIN_API_URL + '/' + npmName + '/public-settings'
return {
getBaseStaticRoute: unimplemented,
+ getBaseRouterRoute: unimplemented,
+
getSettings: unimplemented,
isLoggedIn: unimplemented,
export type RegisterClientHelpers = {
getBaseStaticRoute: () => string
+ getBaseRouterRoute: () => string
+
isLoggedIn: () => boolean
getAuthHeader: () => { 'Authorization': string } | undefined
- [Notifier](#notifier)
- [Markdown Renderer](#markdown-renderer)
- [Auth header](#auth-header)
+ - [Plugin router route](#plugin-router-route)
- [Custom Modal](#custom-modal)
- [Translate](#translate)
- [Get public settings](#get-public-settings)
}
```
+#### Plugin router route
+
+**PeerTube >= 3.3**
+
+To get your plugin router route, you can use `peertubeHelpers.getBaseRouterRoute()`:
+
+```js
+function register (...) {
+ registerHook({
+ target: 'action:video-watch.video.loaded',
+ handler: ({ video }) => {
+ fetch(peertubeHelpers.getBaseRouterRoute() + '/my/plugin/api', {
+ method: 'GET',
+ headers: peertubeHelpers.getAuthHeader()
+ }).then(res => res.json())
+ .then(data => console.log('Hi %s.', data))
+ }
+ })
+}
+```
+
#### Custom Modal
To show a custom modal: