-
Notifications
You must be signed in to change notification settings - Fork 1
Data Structure
This documentation describes the data structure wanna parses the site to. The data can be accessed in templates as you wish.
-
wanna - you can get everything about Wanna you are using. The full list of fields
wannacontains can be found in 'package.json' of wanna repo.{ name: 'Wanna', version: '1.0.0', description: 'Wanna is a blog-aware, static site generator in Node.js.', homepage: 'http://wannajs.org', author: 'Shawn <[email protected]> (http://shaoshuai.me)', contributors: ['Shawn <[email protected] (http://shaoshuai.me)'], 'repository': { type: 'git', url: 'https://github.com/shaoshuai0102/wanna.git' }, ... }When you create your own theme, you should add copyright of Wanna by:
Powered by <a href="{{wanna.homepage}}">{{wanna.name}}</a> {{wanna.version}}The exact code above depends on what template engine you choose.
-
site - everything you define as
sitein 'config.json' file can be accessed via this variable.{ site: { "title": "ShaoShuai.me", "subtitle": "若为自由故", "author": "Shawn", "keywords": "博客, 邵帅", "description": "邵帅的博客,对互联网、思维感兴趣,热爱生活,一直在路上", "theme": "default", "disqus_shortname": "shaoshuaime", "registry": "http://registry.wannajs.org", "rsync_username": "root", "rsync_host": "shaoshuai.me", "rsync_path": "/var/www/shaoshuai.me/wanna" } } -
theme - everything defined in 'theme.json' by theme creator.
{ "name": "default", "version": "0.9", "viewEngine": { "name": "mustache", "version": ">=0.4.0" }, "vars": { "dateFormat": "YYYY-MM-DD" } }All fields defined in
varscan be overridden in the 'config.json' file like this:{ theme: { vars: { dateFormat: 'YY-MM-DD' } } }It's very useful to change the default settings of a theme.
The global object:
{
title: 'blog title',
subtitle: 'blog subtitle',
author: 'author',
keywords: 'keyword1, keyword2, keyword3',
description: 'this is the blog description',
favicon: 'raw/favicon.ico',
root: 'http://your/blog/root/url', //If omitted, use relative path instead.
posts: [
// these post objects below are sorted by date
{ //this is a post object
title: 'post1 title',
// date format specified in the config.js located in the root directory of theme.
date: 'YYYY/MM/DD',
// If comments is allowed
comments: true,
// the categories of current post. It must be an array.
categories: ['category1', 'category2'],
filename: 'filename.html',
// parsed from markdown
content: '<section>post content.....</section>'
},
...
],
pages: [
// same with posts but without date
],
categories: [
{
name: 'category1',
filename: 'category1.html',
posts: [
{
//reference to post obj
},
...
],
pages: [
]
},
...
]
}
-
When processing a layout template of post, page or category, it will be rendered with the the post, page, or category object. And the
__dir__andglobalobject are added too.{ global: globalObj, __dir__: 'path/to/blog/root', title: 'title', path: 'path to current page, eg. posts/abc.html', ... } -
When processing a layout template of blog index, categories index, or page index, the template will be rendered with an object like this:
{ global: globalObj, __dir__: 'path/to/blog/root', title: 'title', url: 'url to current page, eg. categories.html' }