-
I'd like to hide this component. ![]() |
Beta Was this translation helpful? Give feedback.
Answered by
slorber
Jan 22, 2025
Replies: 1 comment 2 replies
-
Swizzle import React, {type ReactNode} from 'react';
import clsx from 'clsx';
import Layout from '@theme/Layout';
import BlogSidebar from '@theme/BlogSidebar';
import type {Props} from '@theme/BlogLayout';
export default function BlogLayout(props: Props): ReactNode {
const {sidebar, toc, children, ...layoutProps} = props;
const hasSidebar = sidebar && sidebar.items.length > 0;
return (
<Layout {...layoutProps}>
<div className="container margin-vert--lg">
<div className="row">
<BlogSidebar sidebar={sidebar} />
<main
className={clsx('col', {
'col--7': hasSidebar,
'col--9 col--offset-1': !hasSidebar,
})}>
{children}
</main>
{toc && <div className="col col--2">{toc}</div>}
</div>
</div>
</Layout>
);
} Less efficient but easier: you can also hide the sidebar using custom CSS. If you want to disable it globally, have you tried |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
tisonkun
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Swizzle
BlogLayout
and customize it to your needs, for example removing the<BlogSidebar>
component usage depending on your own custom logic (you show for some pages, and hide for others for example)