document tag filtering pitfall: always use table.includes()
This commit is contained in:
parent
8c73b8fd8a
commit
37002b305e
1 changed files with 5 additions and 0 deletions
|
|
@ -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`)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue