Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If several "h" have the same content, the same id gets generated, which breaks scrollspy #13

Open
fnicollet opened this issue Feb 3, 2015 · 4 comments

Comments

@fnicollet
Copy link

Hello and thanks for this useful library,

I have an issue, in my page i have several h4 which have exactly the same title. Anchrofic generates the exact same slug and because of that, the spy option will open several nodes (set as active) at the same time, which is not what I intended

If would be nice if slugs could be unique within one page such as "some-id" and "some-id2" or something

Fabien

fnicollet added a commit to fnicollet/anchorific.js that referenced this issue Feb 3, 2015
Quick fix for issue
renettarenula#13

An array of names is kept in memory. Unique slugs are generated by appending "_" because there might not be other ways to distinguish 2 content parts.
Also had to invert the order of anchor and navigations so that the unique ids are set on the "h" titles before the navigations function is executed. This way, navigations is grabbing the newly generated ids

Fabien
@renettarenula
Copy link
Owner

Why would you set the title to the same name in the first place? Wouldn't that be confusing to your users? Just sayin'.

@fnicollet
Copy link
Author

Hello,

It happens in like h4 or different h1s. Say you describe different parts of the interface in h1 and both have a way to "Add a filter". Then your subsection will have the same names

@andrekako
Copy link

We manage a site for a health department. Headings do repeat. It's inescapable.

@Fanstastic
Copy link
Contributor

Hello,
I have built upon @fnicollet 's functionality to handle headings with identical content and add a suffix to the slug.
I needed this to work on all heading levels not just one level i.e. h2#identical and h2#identical-1, now we can have h2#identical and h2#identical-1 and also h3#identical-2.
#43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants