EDIT:
They've come up with a new component called DocCardList which you can use in version 2.3.0.
Create an index.mdx
file in your category folder.
Add the following:
import DocCardList from '@theme/DocCardList';
<DocCardList />
Swizzle or otherwise override this component in your src/theme
folder to add custom styling, etc.
ORIGINAL ANSWER:
Maybe you could try swapping the generated index component using the docCategoryGeneratedIndexComponent
prop (link to reference). That would replace all auto-generated index pages which might be what you want.
In docusaurus.config.js
, in the presets
section, add
presets: [
[
"classic",
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve("./sidebars.js"),
docCategoryGeneratedIndexComponent:
"@site/src/components/CategoryIndexPage",
},
// etc.
}),
],
],
And then try adding the following custom component under src/components/CategoryIndexPage.tsx
:
import React from "react";
export default function CategoryIndexPage(props) {
return (
<pre>
<code>{JSON.stringify(props, null, 2)}</code>
</pre>
);
}
This will just show you what the prop structure is in the component.
When I looked in the theme component which generates this page, it uses
const category = useCurrentSidebarCategory();
But when I try that to get the list of items, I get the following error:
Hook useDocsSidebar is called outside the .
Maybe you can figure out the next steps, I was not able to.
Alternatively, you can create an index.mdx
file in your category folder and import a custom React component into that. That gives me the same context violation error, though.
# My custom category page
Some Markdown content here.
import CategoryIndex from "@site/src/components/CategoryIndex.tsx";
<CategoryIndex />