feat: make blog config options and navbar versions dropdown label translatable (#5371)

* Translate versions dropdown label

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Make blog options tranlatable

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Fix names

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Rename functions

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Rename translations path

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Update docs

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Update Chinese translations

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Remove space

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Update docs

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Add jest test

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Fix copyright typing

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Update test

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Update options

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Fix test

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
This commit is contained in:
Joshua Chen 2021-08-20 23:11:59 +08:00 committed by GitHub
parent 08597045ed
commit 8e1cde135c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 293 additions and 17 deletions

View file

@ -22,6 +22,7 @@ import {
STATIC_DIR_NAME,
DEFAULT_PLUGIN_ID,
} from '@docusaurus/core/lib/constants';
import {translateContent, getTranslationFiles} from './translations';
import {flatten, take} from 'lodash';
import {
@ -102,6 +103,10 @@ export default function pluginContentBlog(
);
},
async getTranslationFiles() {
return getTranslationFiles(options);
},
// Fetches blog contents and returns metadata for the necessary routes.
async loadContent() {
const {
@ -109,6 +114,7 @@ export default function pluginContentBlog(
routeBasePath,
blogDescription,
blogTitle,
blogSidebarTitle,
} = options;
const blogPosts: BlogPost[] = await generateBlogPosts(
@ -119,6 +125,7 @@ export default function pluginContentBlog(
if (!blogPosts.length) {
return {
blogSidebarTitle,
blogPosts: [],
blogListPaginated: [],
blogTags: {},
@ -192,6 +199,7 @@ export default function pluginContentBlog(
Object.keys(blogTags).length > 0 ? tagsPath : null;
return {
blogSidebarTitle,
blogPosts,
blogListPaginated,
blogTags,
@ -213,6 +221,7 @@ export default function pluginContentBlog(
const {addRoute, createData} = actions;
const {
blogSidebarTitle,
blogPosts,
blogListPaginated,
blogTags,
@ -233,7 +242,7 @@ export default function pluginContentBlog(
`blog-post-list-prop-${pluginId}.json`,
JSON.stringify(
{
title: options.blogSidebarTitle,
title: blogSidebarTitle,
items: sidebarBlogPosts.map((blogPost) => ({
title: blogPost.metadata.title,
permalink: blogPost.metadata.permalink,
@ -371,6 +380,10 @@ export default function pluginContentBlog(
}
},
translateContent({content, translationFiles}) {
return translateContent(content, translationFiles);
},
configureWebpack(
_config: Configuration,
isServer: boolean,
@ -461,7 +474,7 @@ export default function pluginContentBlog(
},
async postBuild({outDir}: Props) {
if (!options.feedOptions?.type) {
if (!options.feedOptions.type) {
return;
}