diff options
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/helpers/pages.tsx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils/helpers/pages.tsx b/src/utils/helpers/pages.tsx index 9e015db..24f5503 100644 --- a/src/utils/helpers/pages.tsx +++ b/src/utils/helpers/pages.tsx @@ -3,6 +3,14 @@ import type { LinksWidgetItemData, PostData } from '../../components'; import type { ArticlePreview, PageLink } from '../../types'; import { ROUTES } from '../constants'; +export const getUniquePageLinks = (pageLinks: PageLink[]): PageLink[] => { + const pageLinksIds = pageLinks.map((pageLink) => pageLink.id); + + return pageLinks.filter( + ({ id }, index) => !pageLinksIds.includes(id, index + 1) + ); +}; + /** * Method to sort PageLink objects by name. * |
