hexo-renderer-markojs
Version:
Use marko v4 template in Hexo.
50 lines (40 loc) • 1.4 kB
Markdown
## hexo-renderer-marko
[](https://npmjs.com/package/hexo-renderer-markojs) [](https://npmjs.com/package/hexo-renderer-markojs)
Use [marko](https://github.com/marko-js/marko/) template in Hexo.
### Install
```bash
$ npm install --save hexo-renderer-markojs
```
### Usage
Create a layout file `index.marko`.
```html
class {
onCreate() {
this.state = {
name: 'hello',
};
}
}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>Home</title>
</head>
<body>
<h1>Hello Word</h1>
<p>${data.page.total}</p>
<p>${state.name}</p>
</body>
</html>
```
All hexo local variables are in the data property.
```js
${data.page} Page specific information and custom variables set in front-matter.
${data.site} Sitewide information.
${data.config} Site configuration.
${data.theme} Theme configuration. Inherits from site configuration.
${data.env} Environment variables
...
```
Please read the hexo related documentation: https://hexo.io/docs/variables.html