Skip to content

Commit

Permalink
0.0.43 add momentjs support, lastupdate template - #7
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixlzx committed Aug 9, 2017
1 parent 16c4752 commit e47b50f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
7 changes: 6 additions & 1 deletion assets/init/config.yml
Expand Up @@ -30,7 +30,7 @@ dir:

# Custom
custom:
time: YYYY-MM-DD HH:mm:ss
time: dddd, MMMM Do YYYY, h:mm:ss a # moment js format https://momentjs.com/docs/#/displaying/format/
disqus: minoriwiki # your disqus short link, leave blank to disable comment
category: Uncategoried # default category when creating new page
markdown:
Expand All @@ -48,6 +48,11 @@ custom:
mathjax: false # enable MathJax TeX support, you need markdown.html set to true (allow html) to work
autospacing: true # use `pangunode` library to add space between CJK and Western characters automatically
editor: vim # auto open your note after command
# last update template, placeholders:
# %n% = newline
# %mtime% = file mtime in custom.time format
# %sourcepath% = raw file path
lastupdate: '%n%%n%_Last Update: %mtime%_ [Source File](%sourcepath%)%n%'

# Deployment
deploy:
Expand Down
9 changes: 7 additions & 2 deletions lib/done.js
Expand Up @@ -8,6 +8,7 @@ var ejs = require('ejs');
var ncp = require('ncp');
var recursive = require('recursive-readdir');
var mkdirp = require('mkdirp');
var moment = require('moment');
var fs = require('fs');
var path = require('path');
var crypto = require('crypto');
Expand Down Expand Up @@ -314,8 +315,12 @@ var mdParse = function (data) {
var lastUpdate = function (file, content) {
var fstat = fs.statSync(file);
var sourcepath = file.replace(path.resolve(cwd + '/' + config['dir'].source), config['base'].path + config['dir'].raw + '');
return content + '\n\n_Last Update: ' + fstat.mtime + '_' +
' [Source File](' + sourcepath + ')\n';
var lastupdate = config['custom'].lastupdate ?
config['custom'].lastupdate : '%n%%n%_Last Update: %mtime%_ [Source File](%sourcepath%)%n%';
return content +
lastupdate.replace(/%n%/g, '\n')
.replace(/%mtime%/g, moment(fstat.mtimeMs).format(config['custom'].time))
.replace(/%sourcepath%/g, sourcepath);
};


Expand Down
7 changes: 6 additions & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "minori",
"version": "0.0.42",
"version": "0.0.43",
"description": "Minori is a static Wiki site generator",
"author": "Phoenix Nemo <i@phoenixlzx.com>",
"bin": {
Expand Down Expand Up @@ -29,6 +29,7 @@
"mime": "1.2.11",
"minimist": "1.1.1",
"mkdirp": "0.5.0",
"moment": "^2.18.1",
"ncp": "2.0.0",
"pangu": "^3.0.0",
"prompt": "^0.2.14",
Expand Down

0 comments on commit e47b50f

Please sign in to comment.