commit 6e74c3fa777b21cc826bdc921f7f7843b24cf69b
parent baa26137b8bf1eed60f6a62215fffa6cb3bf1b22
Author: Hugo Soucy <hugo@soucy.cc>
Date: Mon, 1 Feb 2021 11:08:11 -0500
Fix the condition for the parameters file table
Diffstat:
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/satelito/model.lua b/satelito/model.lua
@@ -6,26 +6,25 @@ local lume = require 'satelito.lib.lume.lume'
local dirtree = require 'satelito.dirtree'
local file = require 'satelito.file'
local site = require 'satelito.site'
+local inspect = require 'inspect'
function model.get(filepath)
-- The site config.lua file
local config = assert(site.set_config(filepath))
-- The metadata file of a filepath
- local parameters_file = assert(
- lfs.attributes(filepath:match('(.+)%..*') .. '.lua')
+ local parameters_file = lfs.attributes(filepath:match('(.+)%..*') .. '.lua')
and dofile(filepath:match('(.+)%..*') .. '.lua')
or {}
- )
-- If there's no parameter file for the markdown
-- Then set the minimum from the markdown file itself
- if #parameters_file == 0 then
+ if next(parameters_file) == nil then
+ print(filepath:match('(.+)%..*') .. '.lua' .. ' is missing.')
+ print('You should create it to be able to add metadata.')
+
parameters_file['title'] = file.get_basename(filepath):match('(.+)%..*')
parameters_file['date'] = os.date('%Y-%m-%d', lfs.attributes(filepath).change)
parameters_file['datetime'] = os.date('%H:%M:%S', lfs.attributes(filepath).change)
-
- -- print('There is no "' .. filepath:gsub('(.*/)(.*)', '%2'):match('(.+)%..*') .. '.lua" for the ' .. filepath .. ' file.')
- -- print('You should create one.')
end
local contentdir = site.get_root(filepath) .. '/' .. config.paths.content