Does anyone know why I would get an parse error here?
function widgets.headerMention(pageName)
pageName = pageName or editor.getCurrentPage()
editor.flashNotification(pageName)
local DAILY_BASE_PATH = "Journal/Day/" -- Define base path locally
if not string.startsWith(pageName, DAILY_BASE_PATH) then
-- Not a daily note, return empty widget
return widget.new { markdown = "" }
end
local dateStr = string.sub(pageName, #DAILY_BASE_PATH + 1)
-- Query for headers matching the date string
local query_str = string.format([[
from index.tag "header"
where _.name == "%s"
]], dateStr)
local headers = query query_str
local md = ""
if #headers > 0 then
-- Assuming templates.header exists and formats a single header item
md = "## Pages Today\n"
.. template.each(headers, templates.header)
else
md = "" -- No matching headers found
end
return widget.new {
markdown = md
}
end
From my understanding (as well as the documentation), query[[]]
is the same as query some_str
. Why would it not work here?