Linking to ALL headings
1. Identify all headings in a page, on page load
2. Generate a string out of each heading text
- Should be URL-friendly as it will be part of a URL.
- Should not start with a number as it would be an invalid
- Should be sanitized with unique values at the end (
-2) in case there are one or more headings with the same text. To keep it as clean as possible we should do this only when duplicates are detected. (We cannot use random string generators like
uuid as the links would not be the same when visiting the page again).
- Should be generated by a function that's properly tested with normal and edge-case scenarios, which always gives us what we expect. The generated
id/fragment should always be the same given we give it the same input.