fix(v2): fix link items refusing attributes like target, rel etc... (#3168)

This commit is contained in:
Sébastien Lorber 2020-07-30 15:46:33 +02:00 committed by GitHub
parent 4af25cd597
commit 68f4bd00f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 16 deletions

View file

@ -92,14 +92,10 @@ module.exports = {
{
label: 'Privacy',
href: 'https://opensource.facebook.com/legal/privacy/',
target: '_blank',
rel: 'noreferrer noopener',
},
{
label: 'Terms',
href: 'https://opensource.facebook.com/legal/terms/',
target: '_blank',
rel: 'noreferrer noopener',
},
],
},

View file

@ -111,6 +111,20 @@ const ColorModeSchema = Joi.object({
respectPrefersColorScheme: false,
});
const FooterLinkItemSchema = Joi.object({
to: Joi.string(),
href: Joi.string().uri(),
html: Joi.string(),
label: Joi.string(),
})
.xor('to', 'href', 'html')
.with('to', 'label')
.with('href', 'label')
.nand('html', 'label')
// We allow any unknown attributes on the links
// (users may need additional attributes like target, aria-role, data-customAttribute...)
.unknown();
const ThemeConfigSchema = Joi.object({
// TODO temporary (@alpha-58)
disableDarkMode: Joi.any().forbidden(false).messages({
@ -158,18 +172,7 @@ const ThemeConfigSchema = Joi.object({
links: Joi.array().items(
Joi.object({
title: Joi.string().required(),
items: Joi.array().items(
Joi.object({
to: Joi.string(),
href: Joi.string().uri(),
html: Joi.string(),
label: Joi.string(),
})
.xor('to', 'href', 'html')
.with('to', 'label')
.with('href', 'label')
.nand('html', 'label'),
),
items: Joi.array().items(FooterLinkItemSchema).default([]),
}),
),
}),