I am making a simple react/next js application where I am having totally three pages.
-> index.js
-> jobsearch.js
-> jobdescription.js
Scenario:
-> In home page there is two option for user,
One: They can directly click on any job and go to job description page.
Two: They can go to job search page and the by cliking on any job in search page, they can go to job description page
And finally when user reached the job description page, the breadcrumb is shown like,
<nav className="container">
<ol className="list-reset py-4 pl-4 rounded flex bg-grey-light text-grey">
<li className="px-2">
<Link
href={{
pathname: "/"
}}
>
<a className="text-gray-600 no-underline text-indigo">Home</a>
</Link>
</li>
<li>/</li>
<li className="px-2">
<Link
href={{
pathname: "/jobsearch"
}}
>
<a className="text-gray-600 no-underline text-indigo">
Search Page
</a>
</Link>
</li>
<li>/</li>
<li className="px-2"> Job - {router.query.jobId} </li>
</ol>
</nav>
And this results in displaying Home / Job Search / JobId
.
Requirement:
If navigated to job description page directly from home page then the middle breadcrumb (Search Page) Should not be displayed and the breadcrumb needs to be like Home / Job - JobId
Else the breadcrumb is valid if navigated from Home to search page then to job descrition page.
Working Snippet:
Is there any possibility to track the previous page url while visiting job description page? As I am entirely new to this scenario, kindly please help me to achieve the result of managing breadcrumb.
Big thanks in advance..
Edit:
Would like to edit the question and clarify expected result bit more clear.
Expected Result:
Scenario 1:
-> Click any job from home page, eg..,
Job -Three
(Please note here I didn't go to job search page) then it will redirected to job description page.-> So now the breadcrumb needs to be like
Home/ Job - Three
Scenario 2:
-> Click on search page link from the text in home page
Click here to go to Search Page
and navigate to search page and click on any job from search page, eg..,Job -Three
(Please note here I gone to job search page) then it will redirected to job description page.-> So now the breadcrumb needs to be like
Home / Job Search / Job - Three