Parse Hexo Posts To Object
_config.yml
url: "https://domain.com/"
root: "/"
permalink: ":year/:month/:title.html"
generator:
type: 'hexo' # or jekyll
cache: true # enable caching
verbose: false # enable verbose
amp: false # transform shortcodes to amp html
parse post overriden options
const { parsePost } = require('hexo-post-parser');
parsePost('/path/to/file.md', {
shortcodes: {
youtube: true,
css: true,
include: true,
link: true,
now: true,
script: true,
text: true,
codeblock: true
},
config: {
generator: {
cache: false,
verbose: false,
amp: false,
type: 'hexo'
}
},
formatDate: true,
fix: true,
sourceFile: file.path
})
Shortcode | Description |
---|---|
<!-- include folder/path.txt --> |
Include partial files |
<!-- script folder/script.js --> |
Include JS file as html script <script>codes</script> |
{% youtube video_id %} |
transform youtube tag (AMP Supported) |
const fs = require('fs');
(async function(){
const { parsePost, buildPost } = require('hexo-post-parser');
const parse = await parsePost('path/to/markdown/file.md');
// dump parsed post to json
fs.writeFileSync('path/to/file.json', JSON.stringify(parse, null, 2));
// build parsed post
fs.writeFileSync('path/to/file.md', buildPost(parse));
})();
https://github.com/dimaslanjaka/static-blog-generator-hexo
https://github.com/dimaslanjaka/chimeraland
deployed to: www.webmanajemen.com
--nocache
: disable cache--verbose
: show all console on verbose