Converting vimwiki to hexo website

Vimwiki allows to create a personal wiki style documents using its own markup or markdown.
In order to have portability between other applications I opted to work using markdown :)
Also because I <3 markdown, It’s simple to write and read, it’s just plain text and its the de facto standard writting language in the Developer world to write software documentation.

Using gulp to move vimwiki documents to hexo source files

In order to pre-process our vimwiki to contents ready to be published in your hexo site we’ll use gulp.

Just create Gulpfile.js in your hexo site and install gulp itself running npm i --save gulp.

Ignore contents of vimwiki markdown

Just add this two markdown links between you content to be ignored:
(Remove escape characters \)

1
2
3
4
\[start_ignore\]: <*>
## My hidden content will be here

\[end_ignore\]: <*>

Ignoring entire pages from being moved to source folder

In order to ignore certain vimwiki pages we’ll create a hexoignore.json file in our vimwiki folder.
This file will be loaded and passed to gulp-ignore.

Example of hexoignore.json file:

1
2
3
4
5
6
{
"ignore": [
"private1.html",
"private2.html"
]
}

Also you can set your vimwiki markdown files name starting with . (dot) as unix hidden to
be ignored by gulp moving.

Final Gulpfile.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Gulpfile.js
var gulp = require('gulp')
var stripCode = require('gulp-strip-code')
var replace = require('gulp-replace')
var gulpIgnore = require('gulp-ignore')
var hexoIgnore = require('/home/genar/src/orgmode/hexoignore.json')

gulp.task('clean', () => {
gulp.src('/home/genar/src/orgmode/**/*.html')
// Ignore files specified in hexoignore.json
.pipe(gulpIgnore.exclude(hexoIgnore.ignore))
// Ignore files and folders starting with dot (.)
.pipe(gulpIgnore.exclude('**/.*'))
// Fix links between markdown files
.pipe(replace('.html', '.html'))
// Strip content between tags
.pipe(stripCode({
pattern: /\[start_ignore\][\s\S]*?(?:\[end_ignore\].*\n+?)/g
}))
.pipe(gulp.dest('./source/'))
})

gulp.task('move files', () => {
})

gulp.task('default', ['clean'])

Deploying you site

  1. Run gulp to migrate vimwiki contents to hexo source folder
  2. Generate static files running hexo generate
  3. Run hexo deploy

Comments

TOC

2017-12-22

⬆︎TOP