Querying Authorships

Hi Zef, can we currently query according to authorship, e.g. query for all pages that are authored by the admin? I tried something like

${query[[
  from p = index.contentPages()
  where table.includes(p.authors, "admin")
  select templates.pageItem(p)
]]}

but this does not seem to work.

This should work if all your pages have a frontmatter attribute "authors" with "admin" in that list. If you don't, there's currently no way to do this because SilverBullet actually doesn't really know who authored what right now. With revisions this could indeed become available by inspecting version history I suppose, but that's not currently accessible via the object index. Is this what you're after?

I'm not asking for silverbullet to know who authored which and register in the object index; instead, I would like to manually write in the frontmatter something like

authors: admin pete

and be able to query for the pages who are authored by admin (or pete).

Specifically, the error returned by the query is Cannot use includes on a non-table or non-array value.

yes, because "admin pete" is not an array, it's a string, you'd have to write it like this:

authors:
- admin
- pete

or:

authors: [admin, pete]

Fixed! Sorry for a silly question, I assumed maybe authorship works in a special manner different from ordinary attributes.

no, but to be honest I do have "hacks" in place for e.g. tags where I support both this "spaced out" version as well as lists, even with # in there, just for convenience. But that's specifically done for tags, not for everything.