_CTX.currentPage empty on load

When the page is loaded, it appears that _CTX.currentPage returns nil for all metadata you can obtain from the page.

Therefore, a query such as ${_CTX.currentPage.displayName} loads as nil and must be reevaluated to obtain the correct value.

The same occurs for editor.getCurrentPageMeta() if you grab any value such as editor.getCurrentPageMeta().displayName

I’m not sure if this is a bug or I’m simply misusing these two queries so please let me know.

For reference, I found this while trying to write a query that used the current page’s frontmatter to query for other pages:

${some(template.each(query[[
    from index.tag "page"
    where table.includes(tags, _CTX.currentPage.index_of)
    ]],
  template.new
[==[
[[${name}]]
]==]
)) or "No Pages"}
2 Likes

I run into the same issue with editor.getCurrentPage() which is a bummer as my tables require an extra refresh/load. Would be great if each page, on render, refreshes each Lua Integrated Query

1 Like