hypra

SEM-012: id used more than once

Warning: the page still builds, but this is most likely a mistake.

An id names one element. Links to #reviews, labels, scripts and ARIA references all find only the first of two, so the second one silently doesn't work.

Fails

page(title: "Shoes", description: "All our running shoes, from light racers to trail shoes.") {
  h1 "Shoes"
  section(id: "reviews") { h2 "Reviews" }
  section(id: "reviews") { h2 "Questions" }
}
warning[SEM-012]: id `reviews` is used more than once
 --> page.hypra:4:15
  |
4 |   section(id: "reviews") { h2 "Questions" }
  |               ^^^^^^^^^
  = help: ids must be unique on a page; build it from data in a loop, e.g. id: "item-{item.id}"
  = docs: https://hypralang.dev/rules/sem-012/

0 errors, 1 warning

Fixed

page(title: "Shoes", description: "All our running shoes, from light racers to trail shoes.") {
  h1 "Shoes"
  section(id: "reviews") { h2 "Reviews" }
  section(id: "questions") { h2 "Questions" }
}

In a loop, build the id from data: id: "shoe-{shoe.id}".