83 lines
2.3 KiB
JavaScript
Raw Normal View History

// NOTE TO PLUGINS DEVELOPERS:
// If you modify this file by adding new options to the plugin entry point
// Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md
// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md
// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated
// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED
import { prefixPluginTranslations } from '@strapi/helper-plugin';
2023-06-12 16:22:11 +02:00
2019-04-16 18:05:12 +02:00
import pluginPkg from '../../package.json';
2023-06-12 16:22:11 +02:00
import PluginIcon from './components/PluginIcon';
import { PERMISSIONS } from './constants';
2019-04-16 18:05:12 +02:00
import pluginId from './pluginId';
const name = pluginPkg.strapi.name;
export default {
register(app) {
app.addMenuLink({
to: `/plugins/${pluginId}`,
icon: PluginIcon,
intlLabel: {
id: `${pluginId}.plugin.name`,
defaultMessage: 'Documentation',
},
permissions: PERMISSIONS.main,
2022-08-08 23:33:39 +02:00
async Component() {
2021-10-14 10:48:29 -04:00
const component = await import(
/* webpackChunkName: "documentation-page" */ './pages/PluginPage'
);
return component;
},
});
app.registerPlugin({
id: pluginId,
name,
});
},
2021-10-14 10:48:29 -04:00
bootstrap(app) {
app.addSettingsLink('global', {
intlLabel: {
id: `${pluginId}.plugin.name`,
defaultMessage: 'Documentation',
},
id: 'documentation',
to: `/settings/${pluginId}`,
2022-08-08 23:33:39 +02:00
async Component() {
2021-10-14 10:48:29 -04:00
const component = await import(
/* webpackChunkName: "documentation-settings" */ './pages/SettingsPage'
);
return component;
},
permissions: PERMISSIONS.main,
2021-10-14 10:48:29 -04:00
});
},
async registerTrads({ locales }) {
const importedTrads = await Promise.all(
2022-08-08 23:33:39 +02:00
locales.map((locale) => {
return import(
/* webpackChunkName: "documentation-translation-[request]" */ `./translations/${locale}.json`
)
.then(({ default: data }) => {
return {
data: prefixPluginTranslations(data, pluginId),
locale,
};
})
.catch(() => {
return {
data: {},
locale,
};
});
})
);
return Promise.resolve(importedTrads);
},
2019-04-16 18:05:12 +02:00
};