mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-28 05:58:38 +02:00
feat(theme-classic): new 'html' type navbar item (#7058)
* feat(theme-classic): allow using html in dropdown items * Fix tests * Introduce HTML type for navbar item * Update packages/docusaurus-theme-classic/src/theme/NavbarItem/HtmlNavbarItem.tsx Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com> Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
5273a534d3
commit
84d04ed6ed
8 changed files with 135 additions and 1 deletions
|
@ -93,6 +93,12 @@ const DocSidebarItemSchema = NavbarItemBaseSchema.append({
|
|||
docsPluginId: Joi.string(),
|
||||
});
|
||||
|
||||
const HtmlNavbarItemSchema = Joi.object({
|
||||
className: Joi.string(),
|
||||
type: Joi.string().equal('html').required(),
|
||||
value: Joi.string().required(),
|
||||
});
|
||||
|
||||
const itemWithType = (type: string | undefined) => {
|
||||
// because equal(undefined) is not supported :/
|
||||
const typeSchema = type
|
||||
|
@ -125,6 +131,10 @@ const DropdownSubitemSchema = Joi.object({
|
|||
is: itemWithType(undefined),
|
||||
then: DefaultNavbarItemSchema,
|
||||
},
|
||||
{
|
||||
is: itemWithType('html'),
|
||||
then: HtmlNavbarItemSchema,
|
||||
},
|
||||
{
|
||||
is: Joi.alternatives().try(
|
||||
itemWithType('dropdown'),
|
||||
|
@ -196,6 +206,10 @@ const NavbarItemSchema = Joi.object({
|
|||
is: itemWithType('search'),
|
||||
then: SearchItemSchema,
|
||||
},
|
||||
{
|
||||
is: itemWithType('html'),
|
||||
then: HtmlNavbarItemSchema,
|
||||
},
|
||||
{
|
||||
is: itemWithType(undefined),
|
||||
then: Joi.object().when('.', {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue