fix(v2): i18n perf issue: getTranslationFile() should not load content again (#4593)

* Fix getTranslationFiles() perf issue

* improve doc
This commit is contained in:
Sébastien Lorber 2021-04-09 19:28:48 +02:00 committed by GitHub
parent e99bb43823
commit cb403afa93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 20 deletions

View file

@ -601,7 +601,7 @@ For example, the in docusaurus-plugin-content-docs:
## i18n lifecycles {#i18n-lifecycles}
### `getTranslationFiles()` {#get-translation-files}
### `getTranslationFiles({content})` {#get-translation-files}
Plugins declare the JSON translation files they want to use.
@ -619,7 +619,7 @@ module.exports = function (context, options) {
return {
name: 'my-plugin',
// highlight-start
async getTranslationFiles() {
async getTranslationFiles({content}) {
return [
{
path: 'sidebar-labels',
@ -628,6 +628,7 @@ module.exports = function (context, options) {
message: 'Some Sidebar Label',
description: 'A label used in my plugin in the sidebar',
},
someLabelFromContent: content.myLabel,
},
},
];