elixirschool / school_house

The new era of Elixir School now powered by @phoenixframework
https://elixirschool.com/
Apache License 2.0
152 stars 48 forks source link

Duplicate IDs in table of contents #99

Closed jaimeiniesta closed 2 years ago

jaimeiniesta commented 3 years ago

There are some duplicate IDs generated by the table of contents for the lessons:

https://rocketvalidator.com/s/0bdee490-cff7-495a-95a3-40211cd2b5cd/i?search=duplicate+ID

For example, in https://beta.elixirschool.com/en/ecto/associations there are 2 sections titled "Many to Many":

Captura de pantalla 2021-07-25 a las 18 45 44

Clicking on those will always get you to the first one, as the second is a duplicate.

In order to fix this we need to give a unique ID to each section. I'm not sure how to do that, maybe including numbers, like:

  1. Set Up
  2. Types of Associations 2.1 Belongs To/Has Many 2.2.1 The Has Many Migration 2.2.1 The Has Many Schema

...

sbinlondon commented 3 years ago

I'd be interested in this if it's still up for grabs.

How are the ids generated now for the lessons?

kinson commented 3 years ago

Totally up for grabs!

The ids are generated in the content/lesson.ex file by the link_fragment/1 function. Essentially, as the table of contents is built, the link_fragment/1 function accepts the section name and generates an id to use in the link to the section. The same id is ultimately used in the _section_header.html.eex template.

If you have any questions or want more clarification, let me know and thanks for taking a stab at this 🎊

jaimeiniesta commented 2 years ago

I've just checked and this issue is now fixed! 🚀

Thank you @vclayton 👏 👏 👏