site: cmd[ Array .new >pages "**/*.pstk" Directory .glob each[ if[ dup .file? :then pages .push :else void ] ] #page: module/extend[ static/style.css: File .slurp >style ] source-of: fn[ .[ Path .[ "." of[ path name ] relative ] ] ] dest-of: fn[ .[ Path .[ "." of[ path name Path .parse .name ".html" + ] relative "content/" "site/" String .replace ] ] ] Directory .[ try[ site: rmr :catch void ] static: site: copy ] File .[ NB[ Files I don't have a better way to copy in atm ] "../../stvm.js" site/stvm.js: copy "../../stkweb.js" "site/stkweb.js" copy "../../lib/browser/browser.stk" "site/browser.stk" copy "../../lib/core/core.stk" "site/core.stk" copy ] Set .of[ pages each[ dest-of Path .parse .dir ] ] >destFolders destFolders each[ Directory .ensure ] pages each[ >p p. dest-of p> source-of /t StackTalk .load-file ] ] #page: module[ "" >title "" >contents "" >imports "" >script @: fn[ write ] @title: fn[ @ title @ ] @style: fn[ @ style @ ] @contents: fn[ @ contents @ ] @imports: fn[ @ imports @ ] @script: fn[ @ script @ ] @header: fn[ "
" @ escape @ "" @ ]
quot-tag: fn[ >#tag >q "<" @ #tag. @ ">" @ q> run @ "" @ #tag> @ ">" @ ]
tag: fn[ >#tag >#def
if[ #def. proc?
:then #def> #tag> proc-tag
:else #def> #tag> quot-tag ] ]
escape: fn[ "<" "<" String .replace ">" ">" String .replace ]
---: fn[ "" @ run @ "" @ ]
]
page: fn[
>q w: File .open ask[ use[ #page #markup ] your[ q> ] run render close ]
]