possibility of resetting the first path if it is changed
Closed this issue · 4 comments
I was using the plugin, but I ended up encountering a problem in my usage scenario.
Whenever the product URL changes, I would necessarily have to reset the accumulated crumbs, for example:
product-1/blank
product-2/blank
When changing the initial path, I needed to reset the crumbs to this new "first path". Did you understand? Me implementing this, I can open a PR, does it make sense? And enabling this via props in the plugin settings.
const indexOfDiffPath = crumbs.findIndex(
(crumb) =>
crumb.pathname.split("/")[1] === location.pathname.split("/")[1]
)
if (indexOfDiffPath === -1) {
setCrumbs([
{ pathname: defaultCrumb.location.pathname, ...defaultCrumb },
{
...location,
crumbLabel,
crumbSeparator,
},
])
}
Thanks for creating an issue! I try to respond as quickly as possible to all issues. If it has been a while feel free to mention me to get my attention.
@rodrigoreeis, thanks for the issue. Which way are you using the plugin? Click Tracking or AutoGen? I'm not 100% sure I understand the issue.
@rodrigoreeis, thanks for the issue. Which way are you using the plugin? Click Tracking or AutoGen? I'm not 100% sure I understand the issue.
Hi @sbardian, how are u ? I was using click tracking.
So... let me try explain again. When we are using the plugin in mode: click tracking. All pages that we browse and visit are accumulated in breadcrumb, even we visite other page in the same category eg: category-1/product-1
. I would like to reset the items in breadcrumb when we visite other category eg: category-2/product-1
.
I was trying to do something like that but I not find in plugin some option for it. The solution was to add the code on issue above.
@rodrigoreeis I think what you want would happen if you were using AutoGen instead of click tracking? Maybe check out the docs/demo on that?