Hexo Post Parser



Parse Hexo Posts To Object


  • Parsing HexoJS markdown post
  • Parsing Jekyll markdown post
  • Post Asset Folder Auto Fix for HexoJS
  • Parse shortcodes - (Show all Shortcodes)
  • Include partials files with html comments
  • Get all images from post body and push them to metadata.photos
  • Auto find meta description when not set

Configuration needed

  • file _config.yml
url: "https://domain.com/"
root: "/"
permalink: ":year/:month/:title.html"
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)

Usage Sample

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));

Project Sample



deployed to: www.webmanajemen.com

Argument Parameters

  • --nocache : disable cache
  • --verbose : show all console on verbose

Reference Repositories