pothi.love/0119-load_metadata

15 lines
386 B
Plaintext

load_metadata = function(filename)
local mfile = metadata_file(filename)
local mpath = full_path(mfile)
if not App.file_info(mpath) then
-- comments will always have metadata,
-- so we only get here for top-level posts with no parent
return {replies={}}
end
local contents, err = App.read_file(mpath)
if not contents then
error(err)
end
return json.decode(contents)
end