description: Implements the tag page
Implements a virtual tag page, that renders when navigating to a hashtag: #meta based on the tag:
prefix.
You can override the tag page with a custom implementation as follows:
virtualPage.define {
-- Using the same pattern as the built-in definition
pattern = "tag:(.+)",
run = function(tagName)
return "# Custom tag page for " .. tagName
end
}
-- priority: 10
virtualPage.define {
pattern = "tag:(.+)",
run = function(tagName)
local text = "# Objects tagged with " .. tagName .. "\n"
local allObjects = query[
from index.tag(tagName)
order by ref
](
from index.tag(tagName)
order by ref
)
local taggedPages = query[
from allObjects where table.includes(_.itags, "page")
](
from allObjects where table.includes(_.itags, "page")
)
if #taggedPages > 0 then
text = text .. "## Pages\n"
.. template.each(taggedPages, templates.pageItem)
end
local taggedTasks = query[
from allObjects where table.includes(_.itags, "task")
](
from allObjects where table.includes(_.itags, "task")
)
if #taggedTasks > 0 then
text = text .. "## Tasks\n"
.. template.each(taggedTasks, templates.taskItem)
end
local taggedItems = query[
from allObjects where table.includes(_.itags, "item")
](
from allObjects where table.includes(_.itags, "item")
)
if #taggedItems > 0 then
text = text .. "## Items\n"
.. template.each(taggedItems, templates.itemItem)
end
local taggedData = query[
from allObjects where table.includes(_.itags, "data")
](
from allObjects where table.includes(_.itags, "data")
)
if #taggedData > 0 then
text = text .. "## Data\n"
.. markdown.objectsToTable(taggedData) .. "\n"
end
local taggedParagraphs = query[
from allObjects where table.includes(_.itags, "paragraph")
](
from allObjects where table.includes(_.itags, "paragraph")
)
if #taggedParagraphs > 0 then
text = text .. "## Paragraphs\n"
.. template.each(taggedParagraphs, templates.paragraphItem)
end
return text
end
}