-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
132 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { useDoc, useDocsSidebar } from '@docusaurus/theme-common/internal'; | ||
import DocCardList, { type Props as DocCardListProps } from '@theme/DocCardList'; | ||
|
||
export interface Props extends Omit<DocCardListProps, 'items'> {} | ||
|
||
export default function SidebarDocCardList(props: Props) { | ||
const doc = useDoc(); | ||
const sidebar = useDocsSidebar(); | ||
const items = sidebar.items | ||
// Hide the current doc page from list | ||
.filter((item) => !(item.type === 'link' && item.docId === doc.metadata.id)); | ||
return <DocCardList items={items} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import { filterDocCardListItems, useCurrentSidebarCategory } from '@docusaurus/theme-common'; | ||
import type { PropSidebarItem } from '@docusaurus/plugin-content-docs'; | ||
import type { Props } from '@theme/DocCardList'; | ||
import DocCard from '@theme/DocCard'; | ||
|
||
function DocCardListForCurrentSidebarCategory({ className }: Props) { | ||
const category = useCurrentSidebarCategory(); | ||
return <DocCardList items={category.items} className={className} />; | ||
} | ||
|
||
function isIndexLink(item: PropSidebarItem): boolean { | ||
return item.type === 'link' && item.docId && item.docId.endsWith('/index'); | ||
} | ||
|
||
export default function DocCardList(props: Props) { | ||
const { items, className } = props; | ||
if (!items) { | ||
return <DocCardListForCurrentSidebarCategory {...props} />; | ||
} | ||
const filteredItems = filterDocCardListItems(items) | ||
// Remove link to index page | ||
.filter((item) => !isIndexLink(item)); | ||
return ( | ||
<section className={clsx('row', className)}> | ||
{filteredItems.map((item, index) => ( | ||
<article key={index} className="col col--6 margin-bottom--lg"> | ||
<DocCard item={item} /> | ||
</article> | ||
))} | ||
</section> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters