Skip to content

Commit

Permalink
fix(v2): fix link items refusing attributes like target, rel etc... (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber authored Jul 30, 2020
1 parent 4af25cd commit 68f4bd0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
],
},
Expand Down
27 changes: 15 additions & 12 deletions packages/docusaurus-theme-classic/src/themeConfigSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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([]),
}),
),
}),
Expand Down

0 comments on commit 68f4bd0

Please sign in to comment.