Rewrite compiler and scanner
This commit is contained in:
parent
7b0e3a65fc
commit
1bc2c187df
|
@ -7,10 +7,6 @@ const async = require('async');
|
||||||
const fm = require('front-matter');
|
const fm = require('front-matter');
|
||||||
const config = require('../static/config/config.json');
|
const config = require('../static/config/config.json');
|
||||||
|
|
||||||
function readFile(filepath, callback) {
|
|
||||||
fs.readFile(filepath, 'utf-8', callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
function render(file) {
|
function render(file) {
|
||||||
const md = new MarkdownIt();
|
const md = new MarkdownIt();
|
||||||
return md.render(file);
|
return md.render(file);
|
||||||
|
@ -30,7 +26,7 @@ function fileMetadata(filepath) {
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
function compile(fileData, callback) {
|
function compile(filepath, data, fileData, callback) {
|
||||||
const frontMatter = fm(fileData);
|
const frontMatter = fm(fileData);
|
||||||
const rendered = render(frontMatter.body);
|
const rendered = render(frontMatter.body);
|
||||||
const metadata = fileMetadata(filepath);
|
const metadata = fileMetadata(filepath);
|
||||||
|
@ -44,7 +40,7 @@ function compile(fileData, callback) {
|
||||||
|
|
||||||
const renderedpath = path.join(process.cwd(), config.renderPath, `${metadata.filename}.html`);
|
const renderedpath = path.join(process.cwd(), config.renderPath, `${metadata.filename}.html`);
|
||||||
|
|
||||||
this.data.posts.push(post);
|
data.posts.push(post);
|
||||||
|
|
||||||
fs.writeFile(renderedpath, rendered, callback);
|
fs.writeFile(renderedpath, rendered, callback);
|
||||||
}
|
}
|
||||||
|
@ -55,9 +51,11 @@ function Compiler(data) {
|
||||||
|
|
||||||
Compiler.prototype.addFile = function (filepath) {
|
Compiler.prototype.addFile = function (filepath) {
|
||||||
|
|
||||||
|
console.log("Foo", this.data);
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
readFile,
|
fs.readFile.bind(fs, filepath, 'utf8'),
|
||||||
compile,
|
compile.bind(compile, filepath, this.data),
|
||||||
], (err) => {
|
], (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
});
|
});
|
||||||
|
@ -65,8 +63,8 @@ Compiler.prototype.addFile = function (filepath) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Compiler.prototype.writeData = function (callback) {
|
Compiler.prototype.writeData = function (callback) {
|
||||||
|
console.log('Bar', this.data);
|
||||||
const dataPath = path.join(process.cwd(), 'src/utils/data.json');
|
const dataPath = path.join(process.cwd(), 'src/utils/data.json');
|
||||||
console.log(JSON.stringify(this.data));
|
|
||||||
jsonfile.writeFile(dataPath, this.data, callback);
|
jsonfile.writeFile(dataPath, this.data, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
76
yarn.lock
76
yarn.lock
|
@ -39,13 +39,13 @@ ajv@^4.7.0, ajv@^4.9.1:
|
||||||
json-stable-stringify "^1.0.1"
|
json-stable-stringify "^1.0.1"
|
||||||
|
|
||||||
ajv@^5.0.0, ajv@^5.1.0:
|
ajv@^5.0.0, ajv@^5.1.0:
|
||||||
version "5.2.3"
|
version "5.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.3.tgz#c06f598778c44c6b161abafe3466b81ad1814ed2"
|
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.3.0.tgz#4414ff74a50879c208ee5fdc826e32c303549eda"
|
||||||
dependencies:
|
dependencies:
|
||||||
co "^4.6.0"
|
co "^4.6.0"
|
||||||
fast-deep-equal "^1.0.0"
|
fast-deep-equal "^1.0.0"
|
||||||
|
fast-json-stable-stringify "^2.0.0"
|
||||||
json-schema-traverse "^0.3.0"
|
json-schema-traverse "^0.3.0"
|
||||||
json-stable-stringify "^1.0.1"
|
|
||||||
|
|
||||||
align-text@^0.1.1, align-text@^0.1.3:
|
align-text@^0.1.1, align-text@^0.1.3:
|
||||||
version "0.1.4"
|
version "0.1.4"
|
||||||
|
@ -1054,8 +1054,8 @@ brorand@^1.0.1:
|
||||||
resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f"
|
resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f"
|
||||||
|
|
||||||
browserify-aes@^1.0.0, browserify-aes@^1.0.4:
|
browserify-aes@^1.0.0, browserify-aes@^1.0.4:
|
||||||
version "1.0.8"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.0.8.tgz#c8fa3b1b7585bb7ba77c5560b60996ddec6d5309"
|
resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.1.1.tgz#38b7ab55edb806ff2dcda1a7f1620773a477c49f"
|
||||||
dependencies:
|
dependencies:
|
||||||
buffer-xor "^1.0.3"
|
buffer-xor "^1.0.3"
|
||||||
cipher-base "^1.0.0"
|
cipher-base "^1.0.0"
|
||||||
|
@ -1165,8 +1165,8 @@ caniuse-api@^1.5.2:
|
||||||
lodash.uniq "^4.5.0"
|
lodash.uniq "^4.5.0"
|
||||||
|
|
||||||
caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
|
caniuse-db@^1.0.30000529, caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
|
||||||
version "1.0.30000744"
|
version "1.0.30000752"
|
||||||
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000744.tgz#00758ff7dd5f7138d34a15608dccf71a59656ffe"
|
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000752.tgz#daa129d54ce700e94ad14388bdef514ec1e2dd54"
|
||||||
|
|
||||||
caseless@~0.12.0:
|
caseless@~0.12.0:
|
||||||
version "0.12.0"
|
version "0.12.0"
|
||||||
|
@ -1190,8 +1190,8 @@ chalk@^1.1.1, chalk@^1.1.3:
|
||||||
supports-color "^2.0.0"
|
supports-color "^2.0.0"
|
||||||
|
|
||||||
chalk@^2.1.0:
|
chalk@^2.1.0:
|
||||||
version "2.1.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e"
|
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba"
|
||||||
dependencies:
|
dependencies:
|
||||||
ansi-styles "^3.1.0"
|
ansi-styles "^3.1.0"
|
||||||
escape-string-regexp "^1.0.5"
|
escape-string-regexp "^1.0.5"
|
||||||
|
@ -1623,8 +1623,8 @@ ee-first@1.1.1:
|
||||||
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
|
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
|
||||||
|
|
||||||
electron-to-chromium@^1.2.7:
|
electron-to-chromium@^1.2.7:
|
||||||
version "1.3.24"
|
version "1.3.27"
|
||||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.24.tgz#9b7b88bb05ceb9fa016a177833cc2dde388f21b6"
|
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.27.tgz#78ecb8a399066187bb374eede35d9c70565a803d"
|
||||||
|
|
||||||
elliptic@^6.0.0:
|
elliptic@^6.0.0:
|
||||||
version "6.4.0"
|
version "6.4.0"
|
||||||
|
@ -1731,8 +1731,8 @@ expand-range@^1.8.1:
|
||||||
fill-range "^2.1.0"
|
fill-range "^2.1.0"
|
||||||
|
|
||||||
express@^4.13.4:
|
express@^4.13.4:
|
||||||
version "4.16.1"
|
version "4.16.2"
|
||||||
resolved "https://registry.yarnpkg.com/express/-/express-4.16.1.tgz#6b33b560183c9b253b7b62144df33a4654ac9ed0"
|
resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c"
|
||||||
dependencies:
|
dependencies:
|
||||||
accepts "~1.3.4"
|
accepts "~1.3.4"
|
||||||
array-flatten "1.1.1"
|
array-flatten "1.1.1"
|
||||||
|
@ -1792,6 +1792,10 @@ fast-deep-equal@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff"
|
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff"
|
||||||
|
|
||||||
|
fast-json-stable-stringify@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
|
||||||
|
|
||||||
fastparse@^1.1.1:
|
fastparse@^1.1.1:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/fastparse/-/fastparse-1.1.1.tgz#d1e2643b38a94d7583b479060e6c4affc94071f8"
|
resolved "https://registry.yarnpkg.com/fastparse/-/fastparse-1.1.1.tgz#d1e2643b38a94d7583b479060e6c4affc94071f8"
|
||||||
|
@ -2305,8 +2309,8 @@ is-binary-path@^1.0.0:
|
||||||
binary-extensions "^1.0.0"
|
binary-extensions "^1.0.0"
|
||||||
|
|
||||||
is-buffer@^1.0.2, is-buffer@^1.1.5:
|
is-buffer@^1.0.2, is-buffer@^1.1.5:
|
||||||
version "1.1.5"
|
version "1.1.6"
|
||||||
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
|
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
|
||||||
|
|
||||||
is-builtin-module@^1.0.0:
|
is-builtin-module@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
|
@ -2436,8 +2440,8 @@ istanbul-lib-coverage@^1.1.1:
|
||||||
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da"
|
resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da"
|
||||||
|
|
||||||
istanbul-lib-instrument@^1.7.5:
|
istanbul-lib-instrument@^1.7.5:
|
||||||
version "1.8.0"
|
version "1.9.1"
|
||||||
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.8.0.tgz#66f6c9421cc9ec4704f76f2db084ba9078a2b532"
|
resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.1.tgz#250b30b3531e5d3251299fdd64b0b2c9db6b558e"
|
||||||
dependencies:
|
dependencies:
|
||||||
babel-generator "^6.18.0"
|
babel-generator "^6.18.0"
|
||||||
babel-template "^6.16.0"
|
babel-template "^6.16.0"
|
||||||
|
@ -3418,8 +3422,8 @@ preserve@^0.2.0:
|
||||||
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
|
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
|
||||||
|
|
||||||
private@^0.1.6, private@^0.1.7:
|
private@^0.1.6, private@^0.1.7:
|
||||||
version "0.1.7"
|
version "0.1.8"
|
||||||
resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1"
|
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
|
||||||
|
|
||||||
process-nextick-args@~1.0.6:
|
process-nextick-args@~1.0.6:
|
||||||
version "1.0.7"
|
version "1.0.7"
|
||||||
|
@ -3481,8 +3485,8 @@ punycode@^1.2.4, punycode@^1.4.1:
|
||||||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
|
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
|
||||||
|
|
||||||
q@^1.1.2:
|
q@^1.1.2:
|
||||||
version "1.5.0"
|
version "1.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/q/-/q-1.5.0.tgz#dd01bac9d06d30e6f219aecb8253ee9ebdc308f1"
|
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
|
||||||
|
|
||||||
qs@6.5.1, qs@~6.5.1:
|
qs@6.5.1, qs@~6.5.1:
|
||||||
version "6.5.1"
|
version "6.5.1"
|
||||||
|
@ -3534,8 +3538,8 @@ raw-body@2.3.2:
|
||||||
unpipe "1.0.0"
|
unpipe "1.0.0"
|
||||||
|
|
||||||
rc@^1.1.7:
|
rc@^1.1.7:
|
||||||
version "1.2.1"
|
version "1.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95"
|
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.2.tgz#d8ce9cb57e8d64d9c7badd9876c7c34cbe3c7077"
|
||||||
dependencies:
|
dependencies:
|
||||||
deep-extend "~0.4.0"
|
deep-extend "~0.4.0"
|
||||||
ini "~1.3.0"
|
ini "~1.3.0"
|
||||||
|
@ -3968,8 +3972,8 @@ sntp@1.x.x:
|
||||||
hoek "2.x.x"
|
hoek "2.x.x"
|
||||||
|
|
||||||
sntp@2.x.x:
|
sntp@2.x.x:
|
||||||
version "2.0.2"
|
version "2.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.0.2.tgz#5064110f0af85f7cfdb7d6b67a40028ce52b4b2b"
|
resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8"
|
||||||
dependencies:
|
dependencies:
|
||||||
hoek "4.x.x"
|
hoek "4.x.x"
|
||||||
|
|
||||||
|
@ -4049,7 +4053,11 @@ stackframe@^0.3.1:
|
||||||
version "0.3.1"
|
version "0.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-0.3.1.tgz#33aa84f1177a5548c8935533cbfeb3420975f5a4"
|
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-0.3.1.tgz#33aa84f1177a5548c8935533cbfeb3420975f5a4"
|
||||||
|
|
||||||
"statuses@>= 1.3.1 < 2", statuses@~1.3.1:
|
"statuses@>= 1.3.1 < 2":
|
||||||
|
version "1.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087"
|
||||||
|
|
||||||
|
statuses@~1.3.1:
|
||||||
version "1.3.1"
|
version "1.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e"
|
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e"
|
||||||
|
|
||||||
|
@ -4142,8 +4150,8 @@ supports-color@^3.1.0, supports-color@^3.2.3:
|
||||||
has-flag "^1.0.0"
|
has-flag "^1.0.0"
|
||||||
|
|
||||||
supports-color@^4.0.0, supports-color@^4.4.0:
|
supports-color@^4.0.0, supports-color@^4.4.0:
|
||||||
version "4.4.0"
|
version "4.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e"
|
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b"
|
||||||
dependencies:
|
dependencies:
|
||||||
has-flag "^2.0.0"
|
has-flag "^2.0.0"
|
||||||
|
|
||||||
|
@ -4164,8 +4172,8 @@ tapable@^0.2.7, tapable@~0.2.5:
|
||||||
resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.8.tgz#99372a5c999bf2df160afc0d74bed4f47948cd22"
|
resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.2.8.tgz#99372a5c999bf2df160afc0d74bed4f47948cd22"
|
||||||
|
|
||||||
tar-pack@^3.4.0:
|
tar-pack@^3.4.0:
|
||||||
version "3.4.0"
|
version "3.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984"
|
resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f"
|
||||||
dependencies:
|
dependencies:
|
||||||
debug "^2.2.0"
|
debug "^2.2.0"
|
||||||
fstream "^1.0.10"
|
fstream "^1.0.10"
|
||||||
|
@ -4248,8 +4256,8 @@ type-is@~1.6.15:
|
||||||
mime-types "~2.1.15"
|
mime-types "~2.1.15"
|
||||||
|
|
||||||
ua-parser-js@^0.7.9:
|
ua-parser-js@^0.7.9:
|
||||||
version "0.7.14"
|
version "0.7.17"
|
||||||
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.14.tgz#110d53fa4c3f326c121292bbeac904d2e03387ca"
|
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
|
||||||
|
|
||||||
uc.micro@^1.0.1, uc.micro@^1.0.3:
|
uc.micro@^1.0.1, uc.micro@^1.0.3:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
|
@ -4390,8 +4398,8 @@ webpack-dev-middleware@^1.10.2:
|
||||||
time-stamp "^2.0.0"
|
time-stamp "^2.0.0"
|
||||||
|
|
||||||
webpack-hot-middleware@^2.18.0:
|
webpack-hot-middleware@^2.18.0:
|
||||||
version "2.19.1"
|
version "2.20.0"
|
||||||
resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.19.1.tgz#5db32c31c955c1ead114d37c7519ea554da0d405"
|
resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.20.0.tgz#cb896d837758b6408fe0afeeafdc0e5316b15319"
|
||||||
dependencies:
|
dependencies:
|
||||||
ansi-html "0.0.7"
|
ansi-html "0.0.7"
|
||||||
html-entities "^1.2.0"
|
html-entities "^1.2.0"
|
||||||
|
|
Loading…
Reference in New Issue