mirror of
https://github.com/RaisFast/raisfast.git
synced 2026-09-24 16:02:44 +00:00
25 lines
688 B
Lua
25 lines
688 B
Lua
Plugin = {
|
|
on_post_creating = function(input)
|
|
if not input.excerpt or input.excerpt == "" then
|
|
local plain = input.content
|
|
:gsub("```[\0-\255]*?```", "")
|
|
:gsub("[#*_`]", "")
|
|
:gsub("%s+", " ")
|
|
plain = plain:match("^%s*(.-)%s*$") or plain
|
|
|
|
if #plain > 200 then
|
|
input.excerpt = plain:sub(1, 200) .. "..."
|
|
else
|
|
input.excerpt = plain
|
|
end
|
|
end
|
|
|
|
local env = Host.getConfig("app.env")
|
|
if env == "development" then
|
|
Host.log("info", "excerpt generated in dev mode")
|
|
end
|
|
|
|
return input
|
|
end,
|
|
}
|