diff options
| author | Stanisław Zagórowski <hasohasacz@gmail.com> | 2024-01-14 16:21:57 +0100 |
|---|---|---|
| committer | Stanisław Zagórowski <hasohasacz@gmail.com> | 2024-01-14 16:21:57 +0100 |
| commit | fe7254f7a7b7c8b95824f2d6ce2ee56709ba019d (patch) | |
| tree | 325d04c74c54d1b90b483a96be8c6b689f34137c /luax/blog/cache.lua | |
| parent | 6b068ccd9156de8515203d0000c3a2a8ecb9c5fb (diff) | |
luax: stuff
Diffstat (limited to 'luax/blog/cache.lua')
| -rw-r--r-- | luax/blog/cache.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/luax/blog/cache.lua b/luax/blog/cache.lua new file mode 100644 index 0000000..e8f5b0c --- /dev/null +++ b/luax/blog/cache.lua @@ -0,0 +1,23 @@ +local md = require "libs.markdown" + +local blog_cache = {} + +local function get_blog_post_content(post) + local slug = post.slug + if blog_cache[slug] then + return blog_cache[slug] + end + -- pull markdown content from file + local content = io.open("blog/" .. slug .. ".md", "r"):read("*a") + + if content then + -- convert markdown to html + content = md(content) + end + + blog_cache[slug] = content + + return content +end + +return get_blog_post_content |
