document tag filtering pitfall: always use table.includes()

This commit is contained in:
Connor Rhodes 2026-05-22 14:15:05 -05:00
parent 8c73b8fd8a
commit 37002b305e

View file

@ -45,6 +45,9 @@ where p.name:startsWith("proj/")
-- Pages with a specific tag -- Pages with a specific tag
where table.includes(p.tags, "account") where table.includes(p.tags, "account")
-- Pages WITHOUT a specific tag
where not table.includes(p.tags, "account")
-- Pages matching name -- Pages matching name
where p.name:startsWith("Person") where p.name:startsWith("Person")
@ -55,6 +58,8 @@ where t.page == _CTX.currentPage.name
where p.name:startsWith("proj/") and table.includes(p.tags, "active") where p.name:startsWith("proj/") and table.includes(p.tags, "active")
``` ```
> **Important:** `p.tags` is always an array (possibly empty) on every page. Do NOT use `p.tags` or `not p.tags` as a boolean check — an empty array is still truthy in Lua, so `not p.tags` is always false. Always use `table.includes()` to check for specific tags.
### Sorting (`order by`) ### Sorting (`order by`)
``` ```