Skip to content

Commit

Permalink
fix breadcrumbs in contents
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Dec 11, 2023
1 parent a4a614b commit fc3821d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Breadcrumbs components.
* @module components/theme/Breadcrumbs/Breadcrumbs
*/

import React, { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';

import { useLocation } from 'react-router';
import { getBaseUrl, hasApiExpander } from '@plone/volto/helpers';
import { getBreadcrumbs } from '@plone/volto/actions';

import EEABreadcrumbs from '@eeacms/volto-eea-design-system/ui/Breadcrumbs/Breadcrumbs';

const Breadcrumbs = (props) => {
const dispatch = useDispatch();
const { items = [], root = '/' } = useSelector((state) => state?.breadcrumbs);
// const pathname = useSelector((state) => state.location.pathname);
const location = useLocation();
const { pathname } = location;

const sections = items.map((item) => ({
title: item.title,
href: item.url,
key: item.title,
}));

useEffect(() => {
if (!hasApiExpander('breadcrumbs', getBaseUrl(pathname))) {
dispatch(getBreadcrumbs(getBaseUrl(pathname)));
}
}, [dispatch, pathname]);

return (
<React.Fragment>
<div id="page-header" />
<EEABreadcrumbs pathname={pathname} sections={sections} root={root} />
</React.Fragment>
);
};

export default Breadcrumbs;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The only customization here is the removal of isContentRoute helper from https://github.com/eea/volto-eea-website-theme/blob/bf2707262a3d3bf4d0ab90656e69a1babe8dad54/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.jsx#L16
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ const applyConfig = (config) => {
];
}

// do not expand breadcrumbs
config.settings.apiExpanders = [...config.settings.apiExpanders].filter(
(item) => !item.GET_CONTENT.includes('breadcrumbs'),
);

return config;
};

Expand Down

0 comments on commit fc3821d

Please sign in to comment.