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

Page Anchor links do not have a discernable name #21

Open
jenweber opened this issue Jun 26, 2019 · 1 comment
Open

Page Anchor links do not have a discernable name #21

jenweber opened this issue Jun 26, 2019 · 1 comment

Comments

@jenweber
Copy link
Contributor

This markup causes a "links do not have a discernable name" error:

<h3 id="toc_introducing-ember-objects" class="anchorable-toc">
   Introducing: Ember Objects
   <a class="toc-anchor" href="#toc_introducing-ember-objects"></a>
</h3>

Screen Shot 2019-06-26 at 6 35 19 PM

This fix below works to put the text inside a link, but shipping it requires changes to styling. Since the headers become proper links, they need work to make them look like normal headers again.

In guides-article.js:

    for (var element of allHeaders) {
      if (element.id) {
        element.className = 'anchorable-toc'
        let link = document.createElement('a');
        link.className = 'toc-anchor';
        link.href = `#${element.id}`;
        link.innerText = element.textContent;
        element.innerText = '';
        element.appendChild(link, element.firstElementChild);
      }
    }

Results in

<h2 id="some-text" class="anchorable-toc"><a class="toc-anchor" href="#sometext">Some Text</a></h2>
@jenweber
Copy link
Contributor Author

This should be upstreamed to the guidemaker default template

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

1 participant