I am currently working on integrating heading links on my website's sidebar that are linked to the main content using scrollspy. This allows users to easily navigate to different sections of the main content by clicking on the corresponding headings in the sidebar. The challenge I am facing is how to dynamically update the URL when a user clicks on a specific heading, based on the data retrieved from a JSON file.
For example, let's consider the headings available in my JSON object:
- Heading 1
- Heading 2
- Heading 4
The goal is to update the current URL www.something.com
to something like www.something.com/Heading1
when the user clicks on "Heading 1", and similarly for the other headings.
I am using Vue to implement this functionality, and below is a snippet of my code:
<b-list-group-item :href="`#heading-${headingHash(headings.text)}`"> <--Reference to Heading.
<span>
<b>{{ index + 1 }}.</b> {{ headings.text }} <-- Heading Label.
</span>
</b-list-group-item>
If anyone has suggestions or tips on how to achieve this dynamic URL updating feature in Vue, I would greatly appreciate your assistance. Thank you!