mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 11:47:23 +02:00
fix(theme-classic): fix translation when footer has no links (#6144)
This commit is contained in:
parent
287292497d
commit
0384a7919e
2 changed files with 23 additions and 23 deletions
|
@ -74,21 +74,21 @@ function translateNavbar(
|
||||||
function isMultiColumnFooterLinks(
|
function isMultiColumnFooterLinks(
|
||||||
links: MultiColumnFooter['links'] | SimpleFooter['links'],
|
links: MultiColumnFooter['links'] | SimpleFooter['links'],
|
||||||
): links is MultiColumnFooter['links'] {
|
): links is MultiColumnFooter['links'] {
|
||||||
return 'title' in links[0];
|
return links.length > 0 && 'title' in links[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFooterTranslationFile(footer: Footer): TranslationFileContent {
|
function getFooterTranslationFile(footer: Footer): TranslationFileContent {
|
||||||
const footerLinkTitles: TranslationFileContent = isMultiColumnFooterLinks(
|
const footerLinkTitles: TranslationFileContent = chain(
|
||||||
footer.links,
|
isMultiColumnFooterLinks(footer.links)
|
||||||
|
? footer.links.filter((link) => !!link.title)
|
||||||
|
: [],
|
||||||
)
|
)
|
||||||
? chain(footer.links.filter((link) => !!link.title))
|
.keyBy((link) => `link.title.${link.title}`)
|
||||||
.keyBy((link) => `link.title.${link.title}`)
|
.mapValues((link) => ({
|
||||||
.mapValues((link) => ({
|
message: link.title!,
|
||||||
message: link.title!,
|
description: `The title of the footer links column with title=${link.title} in the footer`,
|
||||||
description: `The title of the footer links column with title=${link.title} in the footer`,
|
}))
|
||||||
}))
|
.value();
|
||||||
.value()
|
|
||||||
: {};
|
|
||||||
|
|
||||||
const footerLinkLabels: TranslationFileContent = chain(
|
const footerLinkLabels: TranslationFileContent = chain(
|
||||||
isMultiColumnFooterLinks(footer.links)
|
isMultiColumnFooterLinks(footer.links)
|
||||||
|
|
|
@ -312,18 +312,18 @@ const ThemeConfigSchema = Joi.object({
|
||||||
}),
|
}),
|
||||||
copyright: Joi.string(),
|
copyright: Joi.string(),
|
||||||
links: Joi.alternatives(
|
links: Joi.alternatives(
|
||||||
Joi.array()
|
Joi.array().items(
|
||||||
.items(
|
Joi.object({
|
||||||
Joi.object({
|
title: Joi.string().allow(null).default(null),
|
||||||
title: Joi.string().allow(null).default(null),
|
items: Joi.array().items(FooterLinkItemSchema).default([]),
|
||||||
items: Joi.array().items(FooterLinkItemSchema).default([]),
|
}),
|
||||||
}),
|
),
|
||||||
)
|
Joi.array().items(FooterLinkItemSchema),
|
||||||
.default([]),
|
)
|
||||||
Joi.array().items(FooterLinkItemSchema).default([]),
|
.messages({
|
||||||
).messages({
|
'alternatives.match': `The footer must be either simple or multi-column, and not a mix of the two. See: https://docusaurus.io/docs/api/themes/configuration#footer-links`,
|
||||||
'alternatives.match': `The footer must be either simple or multi-column, and not a mix of the two. See: https://docusaurus.io/docs/api/themes/configuration#footer-links`,
|
})
|
||||||
}),
|
.default([]),
|
||||||
}).optional(),
|
}).optional(),
|
||||||
prism: Joi.object({
|
prism: Joi.object({
|
||||||
theme: Joi.object({
|
theme: Joi.object({
|
||||||
|
|
Loading…
Add table
Reference in a new issue