generated from eblume/project-template
Some checks failed
Build / validate (pull_request) Failing after 5m3s
A single designated "home" doc (open-or-create by title, configurable via opts.home, default "Home") — a stable landing page to grow a map of content around. e2e covers create-on-first-open + idempotent reuse. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
848 B
Lua
27 lines
848 B
Lua
--- The home / index page (tech-spec §8): a single designated `doc` that is the
|
|
--- base landing page of the knowledge base — a stable place to grow a map of
|
|
--- content. Open-or-create by title, so the first `:Heph home` mints it and
|
|
--- every later one returns the same doc.
|
|
|
|
local rpc = require("heph.rpc")
|
|
|
|
local M = {}
|
|
|
|
--- Open (creating if absent) the home page titled `title` (default "Home").
|
|
--- Returns the node.
|
|
function M.open(title)
|
|
title = (title and #title > 0) and title or "Home"
|
|
local node = rpc.call("node.resolve", { title = title })
|
|
if not node then
|
|
node = rpc.call("node.create", {
|
|
kind = "doc",
|
|
title = title,
|
|
body = "# " .. title .. "\n\n",
|
|
})
|
|
require("heph.util").notify("created home page [[" .. title .. "]]")
|
|
end
|
|
require("heph.node").open(node.id)
|
|
return node
|
|
end
|
|
|
|
return M
|