Skip to content

Commit 37184e5

Browse files
authored
fix(theme): Footer Column/Link should merge provided className (#10796)
1 parent e5ed9a3 commit 37184e5

File tree

6 files changed

+27
-18
lines changed

6 files changed

+27
-18
lines changed

packages/docusaurus-theme-classic/src/options.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ const FooterLinkItemSchema = Joi.object({
308308
href: URISchema,
309309
html: Joi.string(),
310310
label: Joi.string(),
311+
className: Joi.string(),
311312
})
312313
.xor('to', 'href', 'html')
313314
.with('to', 'label')
@@ -317,6 +318,12 @@ const FooterLinkItemSchema = Joi.object({
317318
// attributes like target, aria-role, data-customAttribute...)
318319
.unknown();
319320

321+
const FooterColumnItemSchema = Joi.object({
322+
title: Joi.string().allow(null).default(null),
323+
className: Joi.string(),
324+
items: Joi.array().items(FooterLinkItemSchema).default([]),
325+
});
326+
320327
const LogoSchema = Joi.object({
321328
alt: Joi.string().allow(''),
322329
src: Joi.string().required(),
@@ -384,12 +391,7 @@ export const ThemeConfigSchema = Joi.object<ThemeConfig>({
384391
logo: LogoSchema,
385392
copyright: Joi.string(),
386393
links: Joi.alternatives(
387-
Joi.array().items(
388-
Joi.object({
389-
title: Joi.string().allow(null).default(null),
390-
items: Joi.array().items(FooterLinkItemSchema).default([]),
391-
}),
392-
),
394+
Joi.array().items(FooterColumnItemSchema),
393395
Joi.array().items(FooterLinkItemSchema),
394396
)
395397
.messages({

packages/docusaurus-theme-classic/src/theme/Footer/LinkItem/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
*/
77

88
import React, {type ReactNode} from 'react';
9-
9+
import clsx from 'clsx';
1010
import Link from '@docusaurus/Link';
1111
import useBaseUrl from '@docusaurus/useBaseUrl';
1212
import isInternalUrl from '@docusaurus/isInternalUrl';
1313
import IconExternalLink from '@theme/Icon/ExternalLink';
1414
import type {Props} from '@theme/Footer/LinkItem';
1515

1616
export default function FooterLinkItem({item}: Props): ReactNode {
17-
const {to, href, label, prependBaseUrlToHref, ...props} = item;
17+
const {to, href, label, prependBaseUrlToHref, className, ...props} = item;
1818
const toUrl = useBaseUrl(to);
1919
const normalizedHref = useBaseUrl(href, {forcePrependBaseUrl: true});
2020

2121
return (
2222
<Link
23-
className="footer__link-item"
23+
className={clsx('footer__link-item', className)}
2424
{...(href
2525
? {
2626
href: prependBaseUrlToHref ? normalizedHref : href,

packages/docusaurus-theme-classic/src/theme/Footer/Links/MultiColumn/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import React, {type ReactNode} from 'react';
9+
import clsx from 'clsx';
910
import LinkItem from '@theme/Footer/LinkItem';
1011
import type {Props} from '@theme/Footer/Links/MultiColumn';
1112

@@ -15,7 +16,7 @@ type ColumnItemType = ColumnType['items'][number];
1516
function ColumnLinkItem({item}: {item: ColumnItemType}) {
1617
return item.html ? (
1718
<li
18-
className="footer__item"
19+
className={clsx('footer__item', item.className)}
1920
// Developer provided the HTML, so assume it's safe.
2021
// eslint-disable-next-line react/no-danger
2122
dangerouslySetInnerHTML={{__html: item.html}}
@@ -29,7 +30,7 @@ function ColumnLinkItem({item}: {item: ColumnItemType}) {
2930

3031
function Column({column}: {column: ColumnType}) {
3132
return (
32-
<div className="col footer__col">
33+
<div className={clsx('col footer__col', column.className)}>
3334
<div className="footer__title">{column.title}</div>
3435
<ul className="footer__items clean-list">
3536
{column.items.map((item, i) => (

packages/docusaurus-theme-classic/src/theme/Footer/Links/Simple/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import React, {type ReactNode} from 'react';
9+
import clsx from 'clsx';
910
import LinkItem from '@theme/Footer/LinkItem';
1011
import type {Props} from '@theme/Footer/Links/Simple';
1112

@@ -16,7 +17,7 @@ function Separator() {
1617
function SimpleLinkItem({item}: {item: Props['links'][number]}) {
1718
return item.html ? (
1819
<span
19-
className="footer__link-item"
20+
className={clsx('footer__link-item', item.className)}
2021
// Developer provided the HTML, so assume it's safe.
2122
// eslint-disable-next-line react/no-danger
2223
dangerouslySetInnerHTML={{__html: item.html}}

packages/docusaurus-theme-common/src/utils/useThemeConfig.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,19 @@ export type PrismConfig = {
6767

6868
export type FooterLinkItem = {
6969
label?: string;
70+
className?: string;
7071
to?: string;
7172
href?: string;
7273
html?: string;
7374
prependBaseUrlToHref?: string;
7475
} & {[key: string]: unknown};
7576

77+
export type FooterColumnItem = {
78+
title: string | null;
79+
className?: string;
80+
items: FooterLinkItem[];
81+
};
82+
7683
export type FooterLogo = BaseLogo;
7784

7885
export type FooterBase = {
@@ -82,10 +89,7 @@ export type FooterBase = {
8289
};
8390

8491
export type MultiColumnFooter = FooterBase & {
85-
links: {
86-
title: string | null;
87-
items: FooterLinkItem[];
88-
}[];
92+
links: FooterColumnItem[];
8993
};
9094

9195
export type SimpleFooter = FooterBase & {

website/docusaurus.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,11 +804,12 @@ export default async function createConfigAsync() {
804804
},
805805
{
806806
title: 'Legal',
807-
// Please don't remove the privacy and terms, it's a legal
808-
// requirement.
807+
className: 'footer-column-legal',
808+
// Don't remove the privacy and terms, it's a legal requirement.
809809
items: [
810810
{
811811
label: 'Privacy',
812+
className: 'footer-item-privacy',
812813
href: 'https://opensource.facebook.com/legal/privacy/',
813814
},
814815
{

0 commit comments

Comments
 (0)