Add module preloading
This commit is contained in:
parent
099343fa33
commit
82ad12ba8f
3 changed files with 10 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
local arrr = require 'arrr'
|
||||
local cmark = require 'cmark'
|
||||
local csv = require 'streamcsv'
|
||||
local fun = require 'fun'
|
||||
local json = require 'cjson'
|
||||
local restia = require 'restia'
|
||||
|
@ -63,6 +64,10 @@ local function read_post(file)
|
|||
}
|
||||
end
|
||||
|
||||
-- Handle JS modules
|
||||
local modules = csv.file(io.open("modules.csv"), {header = true})
|
||||
package.loaded.modules = modules
|
||||
|
||||
local posts = {}
|
||||
package.loaded.posts = posts
|
||||
|
||||
|
|
3
modules.csv
Normal file
3
modules.csv
Normal file
|
@ -0,0 +1,3 @@
|
|||
name,preload,url
|
||||
skooma,false,https://cdn.jsdelivr.net/gh/darkwiiplayer/js@cdaeac1/skooma.js
|
||||
element,false,https://cdn.jsdelivr.net/gh/darkwiiplayer/js@3724b3e/element.js
|
|
|
@ -1,4 +1,5 @@
|
|||
import output from require 'params'
|
||||
import 'modules'
|
||||
|
||||
(...) =>
|
||||
head_content, body_content = @(...)
|
||||
|
@ -9,6 +10,7 @@ import output from require 'params'
|
|||
link rel: "stylesheet", href: "/#{output}/css/site.css"
|
||||
meta charset: "UTF-8"
|
||||
head_content
|
||||
[ link rel: "modulepreload", href: module.url for module in *modules when module.preload ]
|
||||
}
|
||||
body {
|
||||
body_content
|
||||
|
|
Loading…
Reference in a new issue