codex
codex copied to clipboard
document available template variables
I've been poking around at the default templates and using introspection like #{Object.keys(file)} to find out what built-in template variables are available for the layout files, but it'd be great to get a list of these in the README. So far I see:
file.{title,template,render-file,inPath,inFile,outPath,href,prepared,project}
files.{root,pages,posts}
Any others? I'm happy to file a pull request with a patch to the README.
Thanks, Dave
Sorry about the lack of documentation. Yes, there are a few other things that you should know about.
For the file
section.
-
title
,template
,render-file
can be over-written from the header of the markdown file being parsed using yaml. -
render-file
indicates whether an *.html file should be saved for the markdown file being parsed. -
weight
is also a valid yaml variable that impacts the order that file will show up in itsfiles
group. - Any other variable you put in the header of the markdown file will also be available.
For the files
groups.
- The groups are mostly arbitrary. The only one that is consistent is the
root
. If you were to delete theposts
folder from your data path, theposts
group would disappear fromfiles
. If you were to add a folder calledapi
to your data path, that would add a group calledapi
to yourfiles
template variable set. - The template that is default for a group is the group name
.jade
in the templates folder. With our previous example, you would need anapi.jade
in your template path.
There is also a site
global template variable which holds everything from the locals
section of the codex.json
file. Useful for things like site titles, analytics keys, etc.
A few projects you will want to check out. In addition to the skeleton that comes with codex, I have also put out codex-hub. It demonstrates some of the more advanced concepts as well as the javascript documentation parser plugin.
Also, the chaijs.com website is mostly based codex. You can check out the repo here.
Let me know if you have more questions or if any of this need clarification. Also feel free to put any of this or other things you learn into the readme :)