UNPKG

@slashid/docusaurus-theme-slashid

Version:
33 lines (30 loc) 1.03 kB
/* ============================================================================ * Copyright (c) SlashID * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * ========================================================================== */ import React, { useMemo } from "react"; import { useSlashID } from "@slashid/react"; import DocCardList from "@theme-init/DocCardList"; import { shouldItemRender } from "../../domain"; function getSlashIDProps(item) { const props = item?.customProps?.slashid; if (!props) return undefined; return props; } /** * Filters the cards on the autogenerated category index pages. */ export default function DocCardListWrapper(props) { const { user } = useSlashID(); const updatedProps = useMemo(() => { return { ...props, items: props.items.filter((item) => shouldItemRender(getSlashIDProps(item), user) ), }; }, [props, user]); return <DocCardList {...updatedProps} />; }